使用tkinter 简单实现界面化
1 from tkinter import * 2 import tkinter.messagebox as messagebox 3 4 class Application(Frame): 5 def __init__(self, master=None): 6 Frame.__init__(self, master) 7 self.pack() 8 self.createWidgets() 9 10 11 def createWidgets(self): 12 self.namelabel=Label(self,text="What's your name?") 13 self.namelabel.pack() 14 self.nameInput = Entry(self) 15 self.nameInput.pack() 16 self.alertButton = Button(self, text='Hello', command=self.hello) 17 self.alertButton.pack() 18 19 def hello(self): 20 name = self.nameInput.get() or 'world' 21 messagebox.showinfo('Message', 'Hello, {}'.format(name)) 22 23 app = Application() 24 # 设置窗口标题: 25 app.master.title('Hello World') 26 # print(app.master.size) 27 # 主消息循环: 28 app.mainloop()