spechal.com | [spesh-uhl]

TAG | Tkinter

411 views
Dec/09

2

Python Button Command Parameter

Here is a crude example of how to pass a parameter to the command of your Tkinter Button.

import Tkinter

def command(text):
    ButtonText.set(text)

root = Tkinter.Tk()

ButtonText = Tkinter.StringVar()
ButtonText.set("Do Callback")
Tkinter.Button(root, textvariable=ButtonText, command=lambda x="Hello World!": command(x)).pack()

root.mainloop()

, ,

Find it!

Theme Design by devolux.org