Python 图形界面 GUI Tkinter 实例

Python  实现图形化界面 

# -*- coding: cp936 -*-
from Tkinter import *
import tkMessageBox

class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

    def createWidgets(self):
        self.nameInput = Entry(self) #
        self.nameInput.pack()
        self.alertButton = Button(self, text=u'请输入文件路径,并确认', command=self.hello)
        self.alertButton.pack()

    def hello(self):
        print self.nameInput.get() # 获取createWidgets里nameInput  输入的值

        name = self.nameInput.get() or 'world'
        tkMessageBox.showinfo('Message', 'Hello, %s' % name)

app = Application()
# 设置窗口标题
app.master.title(u'格式转换')
# 主消息循环:
app.mainloop()


Python 图形界面 GUI Tkinter 实例