-1

I'm using python 3.5, and searching Tkinter.

I'm trying to append command to button, but it's working once time.

enter image description here

Here is my code. This part is in init method of Calculator1 class. I want to add row when I click the button1. The problem is when I execute this code, result is nine rows. And the button1 doesn't working..

enter image description here

Um.. And here is make_row method. How can I do for using that button? I'm waiting your answer.. master

I'm testing this program. So, this code is not complete. Plese don't mention it about svar :)

김대원
  • 1
  • 1

1 Answers1

0

When you're adding a command to the button, you either put the function name only, or if you want to adjust the arguments passed to the function, use a lambda. Try this:

button1 = Button(window, text = "some text", command = lambda *x: self.make_row(f3, self.rows)).grid(row=0,column=0))
yelsayed
  • 5,236
  • 3
  • 27
  • 38
  • Oh my.. Lambda method is exist in ver 3.5.. Thank you so much~! – 김대원 May 06 '16 at 10:35
  • lambdas have always been in Python, as old as I can remember. – yelsayed May 06 '16 at 10:36
  • Ah ha... I have a long way to go. And I have more question to know. That code using pointer at lambda, Right? That is because, parameter is method, not field. Am I correct? – 김대원 May 06 '16 at 10:49
  • if you're talking about the asterisk (*), it's there to absorb any positional arguments, and because i don't know how many arguments the Button.command will send to this lambda. if you want to be more accurate you should remove it and resolve any error by adding more arguments to the lambda if necessary. – yelsayed May 06 '16 at 10:52
  • Okay. I'll try it ! Programming is so attractive as days go by. Then, I hope to meet you someday. – 김대원 May 06 '16 at 11:01