Python
中使用
Tkinter
子產品建立
GUI
程式執行個體
這篇文章主要介紹了
Python
中使用
Tkinter
子產品建立
GUI
程式執行個體
,
本文給出了建立視窗、
文
本框、按鈕等執行個體
,
需要的朋友可以參考下
使用
Tkinter
子產品來建立簡單的
GUI
程式。
Tkinter
的
Widgets
有:
Button
、
Canvas
、
Checkbutton
、
Entry
、
Frame
、
Label
、
Listbox
、
Menu
、
Menubutton
、
Message
、
Radiobutton
、
Scales
、
Scrollbar
、
TEXT
、
Toplevel
等。
例:
複制代碼
代碼如下
:
#
This
program
displays
an
empty
window.
import
Tkinter
def
main():
main_window
=
Tkinter.Tk()
Tkinter.mainloop()
main()
例
2
:
複制代碼
代碼如下
:
import
Tkinter
class
MyGUI:
def
__init__(self):
#
Create
the
main
window
widget.
self.main_window
=
Tkinter.Tk()
#
Enter
the
Tkinter
main
loop.
Tkinter.mainloop()
#
Create
an
instance
of
the
MyGUI
class.
my_gui
=
MyGUI()
例
3
: