import tkinter class simpleapp_tk(tkinter.Tk): def init(self,parent): tkinter.Tk.init(self,parent) self.parent = parent self.initialize()
def initialize(self):
self.grid()
self.entry = tkinter.Entry(self)
self.entry.grid(column=0,row=0,sticky='EW')
self.entry.bind("<Return>", self.OnPressEnter)
button = tkinter.Button(self,text=u"Click me !", command = self.OnButtonClick)
button.grid(column=1,row=0)
label = tkinter.Label(self,
anchor="w",fg="white",bg="blue")
label.grid(column=0,row=1,columnspan=2,sticky='EW')
self.grid_columnconfigure(0,weight=1)
self.resizable(True,False)
def OnButtonClick(self):
print="You clicked the button !"
def OnPressEnter(self,event):
print="You pressed enter !"
if name == "main": app = simpleapp_tk(None) app.title('my application') app.mainloop()