24. 以 Tk 打造 GUI¶
Tk/Tcl has long been an integral part of Python. It provides a robust and
platform independent windowing toolkit, that is available to Python programmers
using the Tkinter
module, and its extensions, the Tix
and
the ttk
modules.
The Tkinter
module is a thin object-oriented layer on top of 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
is a set of wrappers that implement the Tk widgets as Python
classes. In addition, the internal module _tkinter
provides a threadsafe
mechanism which allows Python and Tcl to interact.
Tkinter
’s chief virtues are that it is fast, and that it usually comes
bundled with 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. Nevertheless, there are many other
GUI libraries that you could be interested in. For more information about
alternatives, see the 其它的 GUI section.
- 24.1.
Tkinter
— Python interface to Tcl/Tk - 24.2.
ttk
— Tk themed widgets - 24.3.
Tix
— Extension widgets for Tk - 24.4.
ScrolledText
— Scrolled Text Widget - 24.5.
turtle
— Turtle graphics for Tk- 24.5.1. 介紹
- 24.5.2. Overview over available Turtle and Screen methods
- 24.5.3. Methods of RawTurtle/Turtle and corresponding functions
- 24.5.4. Methods of TurtleScreen/Screen and corresponding functions
- 24.5.5. The public classes of the module
turtle
- 24.5.6. Help and configuration
- 24.5.7. Demo scripts
- 24.6. IDLE
- 24.6.1. Menus
- 24.6.1.1. File menu (Shell and Editor)
- 24.6.1.2. Edit menu (Shell and Editor)
- 24.6.1.3. Format menu (Editor window only)
- 24.6.1.4. Run menu (Editor window only)
- 24.6.1.5. Shell menu (Shell window only)
- 24.6.1.6. Debug menu (Shell window only)
- 24.6.1.7. Options menu (Shell and Editor)
- 24.6.1.8. Window menu (Shell and Editor)
- 24.6.1.9. Help menu (Shell and Editor)
- 24.6.1.10. Context Menus
- 24.6.2. Editing and navigation
- 24.6.3. Startup and code execution
- 24.6.4. Help and preferences
- 24.6.1. Menus
- 24.7. 其它的 GUI