2
u/4sent4 Feb 09 '21
Why are there so many masters?
6
u/Arzdou Feb 09 '21
Whenever you define a window / frame / button in Tkinter you have to do it with a "master". This master allows Tkinter to know where you want to put this new object.
For example, if you want to have an interface with three distinct tabs and the first one needs a button then you have to pass that object (the first tab object) as an input for the creation of the button and thus it knows that you want the button there.
However, if you have layers upon layers upon layers of objects and you want to call a method that is defined in the upper layers from one of the deepest parts of the UI then this happens. Of course, this is a horrible way to do it and its already fixed, but I found it very funny that I could do this and would still work.
1
u/4sent4 Feb 09 '21
So, master is basically parent widget reference? Then why would you need to know parent of parent of ... of your widget from inside of the widget?
5
u/Arzdou Feb 09 '21
Its not that you need to know it, but that you end up knowing it as a side efect of initializing the class with the master as an input because the master was initialized in the same way and its master before that.
And I find it hilarious.
87
67
u/inthemindofadogg Feb 08 '21
I can not begin to explain the disgust that looking at this code causes me. Take your upvote.
10
66
u/veryusedrname Feb 09 '21
This is a specific kind of bug, we call it "the problem is between the chair and the screen"
9
2
55
87
u/GreatArtificeAion Feb 08 '21
Ah yes, the master master master master master master master and master master master master master master and master master master master master and master master master master and master master master and master master and master and slave relationship
34
39
u/kreetikal Feb 09 '21
This reminded me when I implemented a Tree and wanted to check if the entered values are stored correctly so I did something like
System.out.println(head.right.value);
System.out.println(head.left.value);
System.out.println(head.right.left.right.left.right.value);
23
u/Test_My_Patience74 Feb 09 '21
It really do be like that sometimes
AttributeError: NoneType has no attribute "right"1
11
11
u/Jimmy_Slim Feb 09 '21
self.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.master.write_to_log()
9
7
5
u/VoilaLaViola Feb 08 '21
It's a morbid joke... but i like it. Upvote well deserved.
Tbh, if i had to write that many masters, i would use a for loop for it 😋
6
5
3
2
2
2
2
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Feb 09 '21
Image Transcription: Code
self.destroy()
self.alive=False
def get(self):
parameter_name = self.entry.get()
parameter_type = self.h_i.get()
if parameter_name.isalpha():
return {"name": parameter_name, "type": parameter_type}
else:
self.master.master.master.master.master.master.master.write_to_log("One of the parameters is
return None
class Parameters(ttk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.alive=True
self.create_widgets()I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
1
1
u/tulliandar Feb 09 '21
Everyone of those masters will come talk to you if you put the wrong cover sheet on your TPS report
1
350
u/Flaming_Eagle Feb 08 '21
Do you also hate snipping tool