First of all my english is not the best so excuse me for writing bad. I am new to programming oop with tkinter and I looked up 3 methods to initialise the main program. My question with this what are the difference between these and are there any advantages or is this just personal preference?
The first Method is to create the Frame in if block
from tkinter import *
from tkinter import ttk
class ConverterFrame(Frame):
def __init__(self, container):
super().__init__(container)
self.grid()
# Create Frame
class App(Tk):
def __init__(self):
super().__init__()
#Set options for main window
if __name__ == "__main__":
app = App()
ConverterFrame(app)
app.mainloop()
The second Method creates the Frame inside the App Class in a def block
from tkinter import *
from tkinter import ttk
class ConverterFrame(Frame):
def __init__(self, container):
super().__init__(container)
# Create Frame
class App(Tk):
def __init__(self):
super().__init__()
self.createwidgets()
def createwidgets(self):
frame1 = ConverterFrame
frame1.grid()
if __name__ == "__main__":
app = App()
app.mainloop()
and then there is this
from tkinter import *
from tkinter import ttk
def main():
program = CounterProgram()
program.mainloop()
class CounterProgram:
def __init__(self):
#Programm
if __name__ == "__main__":
main()
I hope it is understandable what I mean.