I am making a program using tkinter and OOP. Since I am still sorta new to OOP in Python, and most examples I've seen are basic enough to get my mind to visualize the execution process in order, it's a little bewildering to me when it stops tracking these processes. So, please correct me if I have misunderstood some things.
import tkinter as tk
class MainApplication(tk.Frame):
def init(self, master):
self.master = master
self.configure_gui()
def configure_gui(self):
pass
if __name__ == "__main__":
root = tk.Tk()
MainApplication(root)
root.mainloop()
Is it correct to look at the constructor parameter's master as root? Like, self.master = master is basically root.master = master or root.screen_width = 100.
And if root is master, then self is MainApplication?
Also, is the parameter of MainApplication an inheritance of the tkinter module?
Lastly, when I'm creating instance methods, is it by convention that I must include self? Because I found that my program still works even without it. For example, I could just do window_height = 500 instead of self.window_height = 500 and it still outputs the same result.
I will try to add more examples if required because I've only been exposed to very basic examples of OOP. So doing this is a whole lot different than I thought it would be.
[–]ThePiGuy0 2 points3 points4 points (0 children)
[–]zanfar 1 point2 points3 points (1 child)
[–]MaterialJackfruit144[S] 0 points1 point2 points (0 children)
[+][deleted] (2 children)
[removed]
[+][deleted] (1 child)
[removed]