Tuesday, 22 January 2008

Create class for GUI , Python

from Tkinter import *

class MyDialog:
def __init__(self, top):
Label(top, text="Value").pack()

self.e = Entry(top)
self.e.pack(padx=5)

b = Button(top, text="OK", command=self.ok)
b.pack(pady=5)

def ok(self):
print "value is", self.e.get()

root = Tk()
d = MyDialog(root)
root.mainloop()

No comments:

My photo
London, United Kingdom
twitter.com/zhengxin

Facebook & Twitter