Created
April 16, 2013 11:44
-
-
Save timtan/5395308 to your computer and use it in GitHub Desktop.
a version that remember all widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __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