'图形界面'
from tkinter import *
import tkinter.messagebox as messagebox
class (Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
def createWidgets(self):
self.helloLabel = Label(self, text='Hello World')
self.helloLabel.pack()
self.quitButton = Button(self, text='Quit', command=self.quit)
self.quitButton.pack()
self.nameInput = Entry(self)
self.nameInput.pack()
self.alertButton = Button(self,text='发送',command = self.hello)
self.alertButton.pack()
def hello(self):
name = self.nameInput.get() or 'world'
messagebox.showinfo('Message','Hello, %s'%name)
app = Applicaction()
app.master.title('Hello World')
app.mainloop()
近期评论