In Python, how do I assign a Tkinter button to a piece of code? -


i cannot work out code , wondering if of do. want assign button in tkinter menu defined function in piece of python code (or have way of linking them). have tried numerous different websites cannot find easily.

websites have tried:

-https://docs.python.org/3/library/tkinter.ttk.html

-www.tutorialspoint.com/python/tk_button.htm

this first result in google:

from tkinter import *  master = tk()  def callback():     print "click!"  b = button(master, text="ok", command=callback) b.pack()  mainloop() 

as can see, command used assign callback function run when user clicks button.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Add class to another page attribute using URL id - Jquery -