Why is my Tk button being pressed automatically?

前端 未结 2 1396
南笙
南笙 2021-01-28 07:28

In the code below, clicking the button should change the black text from Hello to Goodbye. But when I run the program, it immediately says Goodbye.

2条回答
  •  忘掉有多难
    2021-01-28 08:05

    For future reference:

    If you want to send parameters to the function, simply add lambda:

    Example for a button with the command callback():

    yourButton = Tkinter.Button(root, text="Go!", command= lambda: callback(variableOne, variableTwo, variableThree)).pack()
    

提交回复
热议问题