r/learnpython • • Nov 19 '19

My first application!

In October I started my Python-journey, with a full time job and a 2yo kid the spare time is scarce.
I've been following a Udemy-course and also used some android-apps to just study something every day.
2 weeks ago I made my first real script from scratch, I had a idea of automating / helping with a tedious task at work. I'm a train driver, and every train we start we fill a paper form, check some values from 2 different paper lists and enter some of that data into the control computer.

The script were terminal based and did all the calculations I wanted, checked up the values from those 2 lists (one which is short, so I just made an elseif of it, the other is long so I made a .txt with the values) and gave a summarized result.

Now 2 weeks later I've deployed it on the web with Flask to be able to share with my colleges!
With dropdowns, forms to fill and a button to run the scripts and show the result.

Thanks to inspiration from this subreddit (and others) I made it working! It's plain ugly, but the functionality is there. Guess I'll come back and sort the design with bootstrap or at least some css'ing next time I feel a dip in the studying.

I dno if there's a better way to post a image, but here's one:
Image of the result with explanations

407 Upvotes

72 comments sorted by

View all comments

1

u/johnne86 Nov 19 '19

Awesome! I’m attempting a similar project for myself to help organize some work stuff. I’m in Tech Support and right now all our documentation about the various sites we manage is spread across multiple spreadsheets and word docs. I’m basically trying to create a directory of information to help pull this info quicker. Enter a site name, select a few options and it spits out all the relevant information. It could probably all be in a database, but I want it to be in Python. I actually like that my gui is just CLI right now, it makes it seem like a smaller portable tool which is what I want right now.

How did you program the buttons, combo box drop down menus and such in your flask app? Is that coded in HTML/JS logic?

I wouldn’t mind to learn how to populate combo box’s with choices and then have the info you select show up in a text box.

2

u/Mag37 Nov 20 '19

Oh that's a great idea! There's a bunch of smart ways of gathering information in Python that I think will come in handy. You can always populate your own csv file or database with collected information as well, depending on if it's changing or static. And then work from that csv/database with your app.

The dropdowns and forms are in html with a variable that's get sent to the python side to be used in the calculations, like this:

<select class="form-control" id="engine_1" name="engine_1">

        <option value="1" selected>RC4/RD2</option>

        <option value="2">RM</option>

        <option value="3">RE</option>

    </select>

And then in the python code you can use it however you want, like I've used it: if engine_1 ="1": do this.

I'd love to share this learning experience with other people in the same general level. I think you learn a lot by bouncing ideas and solving stuff. Give it a go! Just try with something that seems the easiest and build up from there.

2

u/johnne86 Nov 20 '19

Thanks a lot! I'll have to look more into that HTML web interfacing for Python. Seems great for building UIs. I have a lot of HW to do, but it has been fun learning Python!