python3-tkinter官方文档
Table of Contents
1. A cross-platform graphical user interface builder for Python ...................................................... 3
2. A minimal application .............................................................................................................. 4
3. Definitions .............................................................................................................................. 5
4. Layout management ................................................................................................................ 5
4.1. The .grid() method .................................................................................................... 6
4.2. Other grid management methods ................................................................................... 7
4.3. Configuring column and row sizes ................................................................................. 7
4.4. Making the root window resizeable ................................................................................ 8
5. Standard attributes .................................................................................................................. 9
5.1. Dimensions ................................................................................................................... 9
5.2. The coordinate system ................................................................................................. 10
5.3. Colors ......................................................................................................................... 10
5.4. Type fonts ................................................................................................................... 10
5.5. Anchors ...................................................................................................................... 12
5.6. Relief styles ................................................................................................................. 12
5.7. Bitmaps ....................................................................................................................... 12
5.8. Cursors ....................................................................................................................... 13
5.9. Images ........................................................................................................................ 14
5.10. Geometry strings ....................................................................................................... 15
5.11. Window names .......................................................................................................... 16
5.12. Cap and join styles ..................................................................................................... 16
5.13. Dash patterns ............................................................................................................ 17
5.14. Matching stipple patterns ........................................................................................... 17
6. Exception handling ................................................................................................................ 18
7. The Button widget ................................................................................................................ 18
8. The Canvas widget ................................................................................................................ 20
8.1. Canvas coordinates ..................................................................................................... 22
8.2. The Canvas display list ............................................................................................... 22
8.3. Canvas object IDs ....................................................................................................... 22
8.4. Canvas tags ................................................................................................................ 22
8.5. Canvas tagOrId arguments ...................................................................................... 22
8.6. Methods on Canvas widgets ........................................................................................ 22
8.7. Canvas arc objects ...................................................................................................... 28
8.8. Canvas bitmap objects ................................................................................................ 29
8.9. Canvas image objects .................................................................................................. 30
8.10. Canvas line objects .................................................................................................... 30
8.11. Canvas oval objects ................................................................................................... 32
8.12. Canvas polygon objects ............................................................................................. 33
8.13. Canvas rectangle objects ............................................................................................ 35
8.14. Canvas text objects .................................................................................................... 37
8.15. Canvas window objects ............................................................................................. 38
9. The Checkbutton widget ...................................................................................................... 38
10. The Entry widget ................................................................................................................ 41
10.1. Scrolling an Entry widget ......................................................................................... 45
10.2. Adding validation to an Entry widget ........................................................................ 45
11. The Frame widget ................................................................................................................ 47
12. The Label widget ................................................................................................................ 48
13. The LabelFrame widget ...................................................................................................... 50
14. The Listbox widget ............................................................................................................ 52
14.1. Scrolling a Listbox widget ....................................................................................... 56
15. The Menu widget .................................................................................................................. 56
15.1. Menu item creation (coption) options ........................................................................ 59
15.2. Top-level menus ........................................................................................................ 60
16. The Menubutton widget ...................................................................................................... 61
17. The Message widget ............................................................................................................ 63
18. The OptionMenu widget ...................................................................................................... 64
19. The PanedWindow widget .................................................................................................... 65
19.1. PanedWindow child configuration options .................................................................. 67
20. The Radiobutton widget .................................................................................................... 68
21. The Scale widget ................................................................................................................ 71
22. The Scrollbar widget ........................................................................................................ 74
22.1. The Scrollbar command callback ............................................................................ 77
22.2. Connecting a Scrollbar to another widget ................................................................ 77
23. The Spinbox widget ............................................................................................................ 78
24. The Text widget .................................................................................................................. 82
24.1. Text widget indices ................................................................................................... 84
24.2. Text widget marks .................................................................................................... 86
24.3. Text widget images ................................................................................................... 86
24.4. Text widget windows ............................................................................................... 87
24.5. Text widget tags ....................................................................................................... 87
24.6. Setting tabs in a Text widget ...................................................................................... 87
24.7. The Text widget undo/redo stack .............................................................................. 88
24.8. Methods on Text widgets .......................................................................................... 88
25. Toplevel: Top-level window methods ................................................................................. 95
26. Universal widget methods .................................................................................................... 97
27. Standardizing appearance ................................................................................................... 105
27.1. How to name a widget class ...................................................................................... 106
27.2. How to name a widget instance ................................................................................. 107
27.3. Resource specification lines ....................................................................................... 107
27.4. Rules for resource matching ...................................................................................... 108
28. ttk: Themed widgets ........................................................................................................... 108
28.1. Importing ttk ........................................................................................................... 109
28.2. The ttk widget set ..................................................................................................... 110
29. ttk.Button ........................................................................................................................ 110
30. ttk.Checkbutton .............................................................................................................. 112
31. ttk.Combobox .................................................................................................................... 115
32. ttk.Entry .......................................................................................................................... 116
33. ttk.Frame .......................................................................................................................... 118
34. ttk.Label .......................................................................................................................... 119
35. ttk.LabelFrame ................................................................................................................ 122
36. ttk.Menubutton ................................................................................................................ 124
37. ttk.Notebook .................................................................................................................... 126
37.1. Virtual events for the ttk.Notebook widget .............................................................. 128
38. ttk.PanedWindow .............................................................................................................. 129
39. ttk.Progressbar .............................................................................................................. 130
40. ttk.Radiobutton .............................................................................................................. 131
41. ttk.Scale .......................................................................................................................... 133
42. ttk.Scrollbar .................................................................................................................. 135
43. ttk.Separator .................................................................................................................. 137
44. ttk.Sizegrip .................................................................................................................... 137
45. ttk.Treeview .................................................................................................................... 137
45.1. Virtual events for the ttk.Treeview widget .............................................................. 145
46. Methods common to all ttk widgets ..................................................................................... 145
46.1. Specifying widget states in ttk ................................................................................... 146
47. Customizing and creating ttk themes and styles .................................................................... 146
48. Finding and using ttk themes ............................................................................................... 147
49. Using and customizing ttk styles .......................................................................................... 147
50. The ttk element layer ........................................................................................................... 149
50.1. ttk layouts: Structuring a style ................................................................................... 149
50.2. ttk style maps: dynamic appearance changes .............................................................. 151
51. Connecting your application logic to the widgets .................................................................. 153
52. Control variables: the values behind the widgets ................................................................... 153
53. Focus: routing keyboard input ............................................................................................. 155
53.1. Focus in ttk widgets .................................................................................................. 156
54. Events ................................................................................................................................ 157
54.1. Levels of binding ...................................................................................................... 157
54.2. Event sequences ....................................................................................................... 158
54.3. Event types .............................................................................................................. 158
54.4. Event modifiers ........................................................................................................ 160
54.5. Key names ............................................................................................................... 160
54.6. Writing your handler: The Event class ...................................................................... 162
54.7. The extra arguments trick ......................................................................................... 164
54.8. Virtual events ........................................................................................................... 165
55. Pop-up dialogs ................................................................................................................... 165
55.1. The tkMessageBox dialogs module ......................................................................... 165
55.2. The tkFileDialog module ..................................................................................... 167
55.3. The tkColorChooser module ................................................................................. 168
下载地址
上一篇:返回列表