master parameter = None within the class in the tkinter module (python)

1

I'm learning the tkinter module in the course of Professor Neri Neitzke, however, I did not understand what the (master = None) parameter is in __init__(self, master=None) of the class below, could anyone explain the functionality of this parameter in the class? , follow the code below:

from tkinter import *


class App(Frame):
    def __init__(self, master=None): #esse parametro, para que serve?
        Frame.__init__(self, master)
        self.pack()
        self.criarBotoes()
        self.criarLabels()
        self.entradaDados()

    def criarBotoes(self):
        # primeira forma de criar botões
        self.botao = Button(self)
        self.botao['text'] = 'Bem vindo ao Python'
        self.botao['fg'] = 'red'
        self.botao['bg'] = 'yellow'
        self.botao.pack(side='top')

        # segunda forma de criar botões
        self.botao1 = Button(self, text='Segundo botão', fg='blue', bg='red')
        self.botao1.pack(side='top')

    def criarLabels(self):
        self.label = Label(self)
        self.label['text'] = 'Bem vindo ao Python'
        self.label.pack(side='top')

    def entradaDados(self):
        self.edit = Entry(self)
        self.edit.pack(side='top')


#criando a aplicação
minhaAplicacao = App()

minhaAplicacao.master.title('videoaulas Neri')
minhaAplicacao.master.maxsize(1024, 768)

#inicia a aplicação
minhaAplicacao.mainloop()
    
asked by anonymous 03.09.2017 / 21:33

1 answer

0

Simply put. Your class is heir to a frame and this frame should have a window where it will fit, the master means exactly that, the place where it will be placed.

Leaving the master argument as None means that the frame will be positioned in the main window (known as root). You can also do this with any other widget and point the master to a frame and so on.

Note: First time posting here.

    
10.09.2017 / 01:34