Skip to content

Instantly share code, notes, and snippets.

@timtan
Created April 16, 2013 11:44
Show Gist options
  • Select an option

  • Save timtan/5395308 to your computer and use it in GitHub Desktop.

Select an option

Save timtan/5395308 to your computer and use it in GitHub Desktop.
a version that remember all widget
__author__ = 'tim'
import Tkinter
root = Tkinter.Tk()
screen = Tkinter.Label(root)
screen.pack()
buttons = Tkinter.Frame(root)
buttons.pack()
class Command:
def __init__(self, screen, button):
self.button = button
self.screen = screen
def action(self):
self.screen['text'] = self.button['text']
for i in range(10):
button = Tkinter.Button(buttons, text=str(i))
trigger = Command(screen, button)
button.config(command=trigger.action)
button.grid(row=(i/3), column=(i%3))
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment