Answer the question
In order to leave comments, you need to log in
What does this simple code mean?
I am learning python. Here is a simple implementation of a GUI and a button using OOP. I can't figure out what this line means.
from tkinter import*
class Application(Frame):
def __init__(self, master):
super(Application, self).__init__(master) #что делает эта строка, для чего она????? Разжуйте, пожалуйста.
self.grid()
self.create_widgets()
def create_widgets(self):
self.bttn = Button(self, text = '111')
self.bttn.grid()
root = Tk()
root.title('Buttons')
root.geometry('200x85')
app = Application(root)
root.mainloop()
Answer the question
In order to leave comments, you need to log in
I'll add an example to the other answer. This is pretty much the same thing:
class Ancestor(object):
def method(self):
print("Hello from", self)
class Descendant(Ancestor):
def __init__(self):
super(Descendant, self).method()
class Descendant2(Ancestor):
def __init__(self):
super().method()
class Descendant3(Ancestor):
def __init__(self):
Ancestor.method(self)
d = Descendant()
d2 = Descendant2()
d3 = Descendant3()
Hello from <__main__.Descendant object at 0x00F2FAD0>
Hello from <__main__.Descendant2 object at 0x00F2FB70>
Hello from <__main__.Descendant3 object at 0x00F2FB50>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question