python 学习笔记14-----图像用户界面开发

来源:互联网 发布:safari for windows 64 编辑:程序博客网 时间:2024/04/29 20:54

python同样也可以用来开发GUI,常采用的模块有TKinter。下面给出一些例子用于简单说明python是如何开发gui的,当然这还远远不够。

例子1:

#!/usr/bin/env pythonimport Tkintertop = Tkinter.Tk()label = Tkinter.Label(top, text='Hello World!')label.pack()Tkinter.mainloop()

例子2:

#!/usr/bin/env pythonimport Tkintertop = Tkinter.Tk()quit = Tkinter.Button(top, text='Hello World!',    command=top.quit)quit.pack()Tkinter.mainloop()

作为替代,我们其它4 种比较流行且可用的工具集来编写同一个GUI 程序示例:Tix(Tk Interface eXtensions)、Pmw(Python MegaWidgets的Tkinter 扩展)、wxPython(wxWidgets 的Python 绑定)、和PyGTK(GTK+的Python 绑定)

0 0
原创粉丝点击