Last active
August 29, 2015 14:15
-
-
Save FredrikAugust/d3e6022b229da235f04b to your computer and use it in GitHub Desktop.
Tinkering with Tkinter
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
from Tkinter import * | |
class MyApp: | |
def callback(self): | |
print self.inputValue.get() | |
def key(self, event): | |
# print "debug: pressed char {}".format(repr(event.char)) | |
if event.char == "\r": | |
self.myParent.destroy() | |
# print "debug: close" | |
def __init__(self, parent): | |
self.heading = Label(text="hoi wereld") | |
self.heading.pack() | |
self.myParent = parent | |
self.container = Frame(parent) | |
self.container.pack() | |
self.inputValue = StringVar() | |
self.input = Entry(parent, textvariable=self.inputValue) | |
self.input.pack() | |
self.input.bind("<Key>", self.key) | |
self.input.focus() | |
self.getInputButton = Button(self.container, text="Print Input", background="white", height=4, width=16, command=self.callback) | |
self.getInputButton.pack(side=LEFT) | |
root = Tk() | |
myapp = MyApp(root) | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment