- Messages
- 29,411
- Name
- Marcel
- Edit My Images
- Yes
I've taken my hand to Python.
So far I've cobbled together a project I'm working on. Basically it's a wage calculator which will be tailored and very specific to me.
It will eventually take regular input of shift times, and will calculate an exact expected wage based on those times, pay periods, my own pay rate, my employer's pay rules (regarding rounding up/down times etc).
At the moment it's functional (to a fashion). It has a main GUI, a data file, it loads, sorts, and edits the data (resaving it is next), and some calculations on that data.
Before I go any further, I want to structure it properly (so I'm not doing too much refactoring later on).
I've tried reading up on proper Python structure, with packages and modules and it's just got me confused.
At the moment, there's pretty much one main wagecalc.py file which holds all the methods, classes and class methods.
It imports the following modules : ttk, tkinter, datetime and a couple of others.
The application itself is a class.
Here is a snippet of wagecalc.py
In this same file we have my own created gui classes (based off tkinter widgets), the gui event callbacks etc.
Also the data manipulation methods, sorting, editing etc.
Also the file loading method too, and the app options.
My question is how should I split this code up using packages and modules? In a general sense. I know I can do it pretty much any way I like, but I'd like to do it properly.....pythonic if you like (especially to save issues later on).
Would things like all the GUI objects go in one file. What about the callbacks for events on those objects? (When a button is pressed etc). Same file? Different one?
Hope I've not rambled on too much. I wouldn't dare post this sort of question on stackexchange, they tear you a new one on there!
BTW, yes, I'm googling a lot of this stuff as I go along, it's how I learn.
So far I've cobbled together a project I'm working on. Basically it's a wage calculator which will be tailored and very specific to me.
It will eventually take regular input of shift times, and will calculate an exact expected wage based on those times, pay periods, my own pay rate, my employer's pay rules (regarding rounding up/down times etc).
At the moment it's functional (to a fashion). It has a main GUI, a data file, it loads, sorts, and edits the data (resaving it is next), and some calculations on that data.
Before I go any further, I want to structure it properly (so I'm not doing too much refactoring later on).
I've tried reading up on proper Python structure, with packages and modules and it's just got me confused.
At the moment, there's pretty much one main wagecalc.py file which holds all the methods, classes and class methods.
It imports the following modules : ttk, tkinter, datetime and a couple of others.
The application itself is a class.
Here is a snippet of wagecalc.py
Code:
class App(object):
root=tkinter.Tk()
...
....
def main():
wage_calculator = App()
os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')
wage_calculator.root.mainloop()
try:
wage_calculator.root.destroy()
except:
pass
if __name__=='__main__;:
main()
In this same file we have my own created gui classes (based off tkinter widgets), the gui event callbacks etc.
Also the data manipulation methods, sorting, editing etc.
Also the file loading method too, and the app options.
My question is how should I split this code up using packages and modules? In a general sense. I know I can do it pretty much any way I like, but I'd like to do it properly.....pythonic if you like (especially to save issues later on).
Would things like all the GUI objects go in one file. What about the callbacks for events on those objects? (When a button is pressed etc). Same file? Different one?
Hope I've not rambled on too much. I wouldn't dare post this sort of question on stackexchange, they tear you a new one on there!
BTW, yes, I'm googling a lot of this stuff as I go along, it's how I learn.