🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](tkinter.xhtml "tkinter --- Tcl/Tk的Python接口") | - [上一页](shlex.xhtml "shlex --- Simple lexical analysis") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - $('.inline-search').show(0); | # Tk图形用户界面(GUI) Tcl/Tk集成到Python中已经有一些年头了。Python程序员可以通过 [`tkinter`](tkinter.xhtml#module-tkinter "tkinter: Interface to Tcl/Tk for graphical user interfaces") 包和它的扩展, [`tkinter.tix`](tkinter.tix.xhtml#module-tkinter.tix "tkinter.tix: Tk Extension Widgets for Tkinter") 模块和 [`tkinter.ttk`](tkinter.ttk.xhtml#module-tkinter.ttk "tkinter.ttk: Tk themed widget set") 模块,来使用这套鲁棒的、平台无关的窗口工具集。 [`tkinter`](tkinter.xhtml#module-tkinter "tkinter: Interface to Tcl/Tk for graphical user interfaces") 包使用面向对象的方式对Tcl/Tk进行了一层薄包装。使用 [`tkinter`](tkinter.xhtml#module-tkinter "tkinter: Interface to Tcl/Tk for graphical user interfaces") ,你不需要写Tcl代码,但可能需要参考Tk文档,甚至Tcl文档。 [`tkinter`](tkinter.xhtml#module-tkinter "tkinter: Interface to Tcl/Tk for graphical user interfaces") 使用Python类,对Tk的窗体小部件(Widgets)进行了一系列的封装。除此之外,内部模块 `_tkinter` 针对Python和Tcl之间的交互,提供了一套线程安全的机制。 [`tkinter`](tkinter.xhtml#module-tkinter "tkinter: Interface to Tcl/Tk for graphical user interfaces") 最大的优点就一个字:快,再一个,是Python自带的。尽管官方文档不太完整,但有其他资源可以参考,比如Tk手册,教程等。 [`tkinter`](tkinter.xhtml#module-tkinter "tkinter: Interface to Tcl/Tk for graphical user interfaces") 也以比较过时的外观为人所知,但在Tk 8.5中,这一点得到了极大的改观。除此之外,如果有兴趣,还有其他的一些GUI库可供使用。更多信息,请参考 [其他图形用户界面(GUI)包](othergui.xhtml#other-gui-packages) 小节。 - [`tkinter` --- Tcl/Tk的Python接口](tkinter.xhtml) - [Tkinter 模块](tkinter.xhtml#tkinter-modules) - [Tkinter Life Preserver](tkinter.xhtml#tkinter-life-preserver) - [How To Use This Section](tkinter.xhtml#how-to-use-this-section) - [A Simple Hello World Program](tkinter.xhtml#a-simple-hello-world-program) - [A (Very) Quick Look at Tcl/Tk](tkinter.xhtml#a-very-quick-look-at-tcl-tk) - [Mapping Basic Tk into Tkinter](tkinter.xhtml#mapping-basic-tk-into-tkinter) - [How Tk and Tkinter are Related](tkinter.xhtml#how-tk-and-tkinter-are-related) - [Handy Reference](tkinter.xhtml#handy-reference) - [Setting Options](tkinter.xhtml#setting-options) - [The Packer](tkinter.xhtml#the-packer) - [Packer Options](tkinter.xhtml#packer-options) - [Coupling Widget Variables](tkinter.xhtml#coupling-widget-variables) - [The Window Manager](tkinter.xhtml#the-window-manager) - [Tk Option Data Types](tkinter.xhtml#tk-option-data-types) - [Bindings and Events](tkinter.xhtml#bindings-and-events) - [The index Parameter](tkinter.xhtml#the-index-parameter) - [Images](tkinter.xhtml#images) - [File Handlers](tkinter.xhtml#file-handlers) - [`tkinter.ttk` --- Tk themed widgets](tkinter.ttk.xhtml) - [Using Ttk](tkinter.ttk.xhtml#using-ttk) - [Ttk Widgets](tkinter.ttk.xhtml#ttk-widgets) - [Widget](tkinter.ttk.xhtml#widget) - [Standard Options](tkinter.ttk.xhtml#standard-options) - [Scrollable Widget Options](tkinter.ttk.xhtml#scrollable-widget-options) - [Label Options](tkinter.ttk.xhtml#label-options) - [Compatibility Options](tkinter.ttk.xhtml#compatibility-options) - [Widget States](tkinter.ttk.xhtml#widget-states) - [ttk.Widget](tkinter.ttk.xhtml#ttk-widget) - [Combobox](tkinter.ttk.xhtml#combobox) - [选项](tkinter.ttk.xhtml#options) - [Virtual events](tkinter.ttk.xhtml#virtual-events) - [ttk.Combobox](tkinter.ttk.xhtml#ttk-combobox) - [Spinbox](tkinter.ttk.xhtml#spinbox) - [选项](tkinter.ttk.xhtml#id1) - [Virtual events](tkinter.ttk.xhtml#id2) - [ttk.Spinbox](tkinter.ttk.xhtml#ttk-spinbox) - [Notebook](tkinter.ttk.xhtml#notebook) - [选项](tkinter.ttk.xhtml#id3) - [Tab Options](tkinter.ttk.xhtml#tab-options) - [Tab Identifiers](tkinter.ttk.xhtml#tab-identifiers) - [Virtual Events](tkinter.ttk.xhtml#id4) - [ttk.Notebook](tkinter.ttk.xhtml#ttk-notebook) - [Progressbar](tkinter.ttk.xhtml#progressbar) - [选项](tkinter.ttk.xhtml#id5) - [ttk.Progressbar](tkinter.ttk.xhtml#ttk-progressbar) - [Separator](tkinter.ttk.xhtml#separator) - [选项](tkinter.ttk.xhtml#id6) - [Sizegrip](tkinter.ttk.xhtml#sizegrip) - [Platform-specific notes](tkinter.ttk.xhtml#platform-specific-notes) - [Bugs](tkinter.ttk.xhtml#bugs) - [Treeview](tkinter.ttk.xhtml#treeview) - [选项](tkinter.ttk.xhtml#id7) - [Item Options](tkinter.ttk.xhtml#item-options) - [Tag Options](tkinter.ttk.xhtml#tag-options) - [Column Identifiers](tkinter.ttk.xhtml#column-identifiers) - [Virtual Events](tkinter.ttk.xhtml#id8) - [ttk.Treeview](tkinter.ttk.xhtml#ttk-treeview) - [Ttk Styling](tkinter.ttk.xhtml#ttk-styling) - [Layouts](tkinter.ttk.xhtml#layouts) - [`tkinter.tix` --- Extension widgets for Tk](tkinter.tix.xhtml) - [Using Tix](tkinter.tix.xhtml#using-tix) - [Tix Widgets](tkinter.tix.xhtml#tix-widgets) - [Basic Widgets](tkinter.tix.xhtml#basic-widgets) - [File Selectors](tkinter.tix.xhtml#file-selectors) - [Hierarchical ListBox](tkinter.tix.xhtml#hierarchical-listbox) - [Tabular ListBox](tkinter.tix.xhtml#tabular-listbox) - [Manager Widgets](tkinter.tix.xhtml#manager-widgets) - [Image Types](tkinter.tix.xhtml#image-types) - [Miscellaneous Widgets](tkinter.tix.xhtml#miscellaneous-widgets) - [Form Geometry Manager](tkinter.tix.xhtml#form-geometry-manager) - [Tix Commands](tkinter.tix.xhtml#tix-commands) - [`tkinter.scrolledtext` --- 滚动文字控件](tkinter.scrolledtext.xhtml) - [IDLE](idle.xhtml) - [目录](idle.xhtml#menus) - [文件目录 (命令行和编辑器)](idle.xhtml#file-menu-shell-and-editor) - [编辑目录(命令行和编辑器)](idle.xhtml#edit-menu-shell-and-editor) - [Format menu (Editor window only)](idle.xhtml#format-menu-editor-window-only) - [Run menu (Editor window only)](idle.xhtml#run-menu-editor-window-only) - [Shell menu (Shell window only)](idle.xhtml#shell-menu-shell-window-only) - [Debug menu (Shell window only)](idle.xhtml#debug-menu-shell-window-only) - [Options menu (Shell and Editor)](idle.xhtml#options-menu-shell-and-editor) - [Window menu (Shell and Editor)](idle.xhtml#window-menu-shell-and-editor) - [Help menu (Shell and Editor)](idle.xhtml#help-menu-shell-and-editor) - [Context Menus](idle.xhtml#context-menus) - [Editing and navigation](idle.xhtml#editing-and-navigation) - [Editor windows](idle.xhtml#editor-windows) - [Key bindings](idle.xhtml#key-bindings) - [Automatic indentation](idle.xhtml#automatic-indentation) - [Completions](idle.xhtml#completions) - [Calltips](idle.xhtml#calltips) - [Code Context](idle.xhtml#code-context) - [Python Shell window](idle.xhtml#python-shell-window) - [Text colors](idle.xhtml#text-colors) - [Startup and code execution](idle.xhtml#startup-and-code-execution) - [Command line usage](idle.xhtml#command-line-usage) - [Startup failure](idle.xhtml#startup-failure) - [Running user code](idle.xhtml#running-user-code) - [User output in Shell](idle.xhtml#user-output-in-shell) - [Developing tkinter applications](idle.xhtml#developing-tkinter-applications) - [Running without a subprocess](idle.xhtml#running-without-a-subprocess) - [Help and preferences](idle.xhtml#help-and-preferences) - [Help sources](idle.xhtml#help-sources) - [Setting preferences](idle.xhtml#setting-preferences) - [IDLE on macOS](idle.xhtml#idle-on-macos) - [Extensions](idle.xhtml#extensions) - [其他图形用户界面(GUI)包](othergui.xhtml) ### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](tkinter.xhtml "tkinter --- Tcl/Tk的Python接口") | - [上一页](shlex.xhtml "shlex --- Simple lexical analysis") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - $('.inline-search').show(0); | © [版权所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 软件基金会是一个非盈利组织。 [请捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [发现了问题](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 创建。