Graphical User Interfaces with Tk使用Tk的图形用户界面¶
Tk/Tcl has long been an integral part of Python. Tk/Tcl长期以来都是Python不可或缺的一部分。It provides a robust and platform independent windowing toolkit, that is available to Python programmers using the 它提供了一个健壮且独立于平台的窗口工具包,可供使用tkinter
package, and its extension, the tkinter.tix
and the tkinter.ttk
modules.tkinter
包及其扩展、tkinter.tix
和tkinter.ttk
模块的Python程序员使用。
The tkinter
package is a thin object-oriented layer on top of Tcl/Tk. tkinter
包是Tcl/Tk之上的一个薄薄的面向对象层。To use 要使用tkinter
, you don’t need to write Tcl code, but you will need to consult the Tk documentation, and occasionally the Tcl documentation. tkinter
,您不需要编写Tcl代码,但需要参考Tk文档,有时还需要参考Tcl文档。tkinter
is a set of wrappers that implement the Tk widgets as Python classes.是一组将Tk小部件实现为Python类的包装器。
tkinter
’s chief virtues are that it is fast, and that it usually comes bundled with Python. 的主要优点是速度快,并且通常与Python捆绑在一起。Although its standard documentation is weak, good material is available, which includes: references, tutorials, a book and others. 虽然它的标准文档很弱,但有很好的资料,包括:参考资料、教程、一本书和其他。tkinter
is also famous for having an outdated look and feel, which has been vastly improved in Tk 8.5. tkinter
还因其过时的外观和感觉而闻名,这在Tk 8.5中得到了极大的改进。Nevertheless, there are many other GUI libraries that you could be interested in. 然而,您可能会对许多其他GUI库感兴趣。The Python wiki lists several alternative GUI frameworks and tools.Python wiki列出了几种可选的GUI框架和工具。
tkinter
—Python interface to Tcl/TkTcl/Tk的Python接口tkinter.colorchooser
—Color choosing dialog颜色选择对话框tkinter.font
—Tkinter font wrapperTkinter字体包装器- Tkinter
Dialogs对话框 tkinter.messagebox
—Tkinter message promptsTkinter消息提示tkinter.scrolledtext
—Scrolled Text Widget滚动文本小部件tkinter.dnd
—Drag and drop support拖放支持tkinter.ttk
—Tk themed widgetsTk主题小部件tkinter.tix
—Extension widgets for TkTk的扩展小部件- IDLE
Menus菜单File menu文件菜单 (Shell and Editor)Edit menu编辑菜单 (Shell and Editor)Format menu格式菜单 (Editor window only)Run menu运行菜单 (Editor window only)- Shell
menu菜单 (Shell window only) Debug menu调试菜单 (Shell window only)Options menu选项菜单 (Shell and Editor)Window menu窗口菜单 (Shell and Editor)Help menu帮助菜单 (Shell and Editor)Context Menus上下文菜单
Editing and navigation编辑和导航Startup and code execution启动和代码执行Help and preferences帮助和偏好