Mar-12-2019, 01:12 PM
Question about this part... (pseudo-code):
Anyway, is this essentially saying something like, "when you create an instance of this class, give it a variable called 'parent' [or rather, 'nameOfInstancedThing_parent' behind the scenes], and set it equal to whatever was passed in upon creation"? Would a variable equal to that class in the example above, without a parent value assigned to it, default to "None" or throw an error?
Also (and in relation to Tk), would it be correct to say that if you have another instanced object of the same "Tk() type", with parent set to "None" by default, that this is how "pop-up" menus are constructed? A sub-class of the "Tk() class" whose value of the parent variable is "None" but still part of the program?
Thank you!
class IsntImportant(Object): def __init__(self, parent): self.parent = parentSpecifically lines 2 and 3, if it were not clear. 100% not sarcastic, just new and learning this stuff, and don't want to try and attempt to look like I know what I'm doing, because I don't. But some times attempting to explain what I think is going on can help me understand it...
Anyway, is this essentially saying something like, "when you create an instance of this class, give it a variable called 'parent' [or rather, 'nameOfInstancedThing_parent' behind the scenes], and set it equal to whatever was passed in upon creation"? Would a variable equal to that class in the example above, without a parent value assigned to it, default to "None" or throw an error?
Also (and in relation to Tk), would it be correct to say that if you have another instanced object of the same "Tk() type", with parent set to "None" by default, that this is how "pop-up" menus are constructed? A sub-class of the "Tk() class" whose value of the parent variable is "None" but still part of the program?
Thank you!