But this doesn’t solve the problem of having the business logic inside the class at all
@REDO_79 creating classes in python is just a step above the basic programming tutorials, I suggest you spend some time to learn about classes and OOP (Object Oriented Programming).
Here I define a class that can hold the data you need to pass to the logic
class TankData:
def __init__(self, a, b, h, ep, contrainte):
self.a = a
self.b = b
self.h = h
self.ep = ep
self.contrainte = contrainte
that you can use in the form like that
class TankInputForm(Window):
def __init__(self):
self.data = None
# rest of the init method...
def ok_button(self, sender, e):
# calcualte A, B, H, ep and contrainte... then:
self.data = TankData(A, B, H, ep, contrainte)
self.close()
in the main script (i prefer to use a main
function and just call main()
as the last line of my script so I can exit early):
def main():
tank_form = TankInputForm()
if not tank_form.data:
return
# call the logic that does the transactions and reads the data from tank_form.data
Note that you can do the same without the data class and using a dictionary:
self.data = {"a": A, "b": B, ...}
The key point here is when you Close()
a window, the instance is still in memory and you can access any of its attributes/properties to read the data it contains.