Apr-25-2020, 03:57 AM
My first example would be something you could add to your machine class. My last example is something that would be used only if you couldn't modify the machine class. Since it is short you could include it (only the MachineParameter class) in you GUI file. I would write a function that created an instance of the class, created a label, an increment and a decrement button. Something kind of like this:
Be aware I have no idea how the database connection stuff would look. I haven't made it to using databases in python (yet). You might also want to save the buttons and the title in the MachineParameter class so everything would be in one place. I hate throwing things away and not being able to get to them again
def new_machine_control(title, param_name, db_field_name, row): title_lbl = Label(master=settingsPage, 'text'=title) title_lbl.grid('row' = row, 'column' = 0) value_lbl = Label(master=settingsPage) value_lbl.grid('row' = row, 'column' = 3) param = MachineParameter(machineProgram.machineClass, param_name, 1, value_lbl, \ sqlite3Connection, db_field_name) param.incr(0) incr_btn = Button(master=settingsPage, text="+", command=partial(param.incr)) incr_btn.grid('row' = row, 'column' = 1) decr_btn = Button(master=settingsPage, text="-", command=partial(param.decr)) incr_btn.grid('row' = row, 'column' = 2) return param new_machine_control('Rinse TIme', 'rinseTime', db_stuff, 1) new_machine_control('Tumble TIme', 'tumbleTime', db_stuff, 2)That would make a fairly compact GUI file even if you have many parameters to control.
Be aware I have no idea how the database connection stuff would look. I haven't made it to using databases in python (yet). You might also want to save the buttons and the title in the MachineParameter class so everything would be in one place. I hate throwing things away and not being able to get to them again