I'm currently writing a tiny windowed app using python and tkinter
.
I have very little experience with tkinter
and I asked myself whether it would be best to:
- make my window a class inheriting from
tkinter.Tk
- initialise all objects and variables
do all the processes in its
__init__
method as if it was amain
likewise:class Main_Frame(tkinter.Tk): def __init__(self): super().__init__() self.grid = Grid(60, 40) can_width, can_height = self.canvas_dim() self.can = tk.Canvas(self, width = can_width, height = can_height) self.can.bind('<Button-1>', self.color_1) self.can.pack()
Also, all the functions would be translated to become methods of that class.
Or should I just instantiate the Tk
class and put all treatments, variables and instances in the main
?
If you need a more detailed look on the code here are the two versions of the code: gist