0
I have the following code:
class Tela:
def __init__(self, master=None):
self.fontePadrao = ("Arial", "10")
master = Toplevel(self.root)
self.primeiroContainer = Frame(master)
self.primeiroContainer["pady"] = 10
self.primeiroContainer["padx"] = 30
self.primeiroContainer.pack()
self.segundoContainer = Frame(master)
self.segundoContainer["pady"] = 10
self.segundoContainer.pack()
self.titulo = Label(self.primeiroContainer, text="Client")
self.titulo["font"] = ("Arial", "10", "bold")
self.titulo.pack()
self.btnMessage = Button(self.segundoContainer)
self.btnMessage.pack(side=LEFT)
self.btnMessage["text"] = "imprimir mensagem"
self.btnMessage["font"] = ("Calibri", "10")
self.btnMessage["width"] = 15
self.btnMessage["command"] = self.printMessage("Olá!")
self.btnMessage.pack()
def printMessage(message):
print(message)
But I can’t get the argument to function... as I should?
Which function you refer to?
– Woss
I refer to printMessage function()
– dani
She’s a method, so she shouldn’t get
self
as first parameter, just as you did in__init__
?– Woss
Oops, I’ve seen it now too, and fixed it. But my problem here is that the way it is, when the program runs it already calls this function. But I want it to be called only when I click the button. Without passing the parameters and leaving a message sinking there, it works. ai at the time of calling her by the button, I put only printMessage, without the parentheses.
– dani