en:tkk
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
en:tkk [2022/03/04 11:30] – [Canvas] roehner | en:tkk [2022/08/23 19:02] (aktuell) – [Treeview] roehner | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
===== TKK ===== | ===== TKK ===== | ||
+ | TTK widgets look more like operating system widgets and better than Tkinter widgets. On the other hand, the Tkinter widgets are easier to configure. The Combobox, Notebook, Treeview, Progressbar, | ||
+ | |||
A GUI form is built with the help of widgets. These are the graphical components available in the Tkinter or TTK toolbar. In the following, basic information about the use of widgets is given, which is sufficient in many cases. More detailed information can be found in the [[https:// | A GUI form is built with the help of widgets. These are the graphical components available in the Tkinter or TTK toolbar. In the following, basic information about the use of widgets is given, which is sufficient in many cases. More detailed information can be found in the [[https:// | ||
- | A GUI program can be created with the {{:tkinter.png}} icon for new Tk/TTK application on the Program tab. Widgets can be placed by dragging and dropping or by clicking on a widget and then clicking in the GUI form. Only absolute layout is supported. This is perfectly sufficient for most purposes. Designing a GUI interface with layout managers is much more difficult. | + | A GUI program can be created with the {{:tkapp.png}} icon for new Tk/TTK application on the Program tab. Widgets can be placed by dragging and dropping or by clicking on a widget and then clicking in the GUI form. Only absolute layout is supported. This is perfectly sufficient for most purposes. Designing a GUI interface with layout managers is much more difficult. |
Attributes and events of a widget are configured in the Object Inspector. Initially, only the most important attributes and events are displayed. This filtering simplifies the work with the Object Inspector. You can display more or all attributes and methods in two further stages. | Attributes and events of a widget are configured in the Object Inspector. Initially, only the most important attributes and events are displayed. This filtering simplifies the work with the Object Inspector. You can display more or all attributes and methods in two further stages. | ||
Zeile 148: | Zeile 150: | ||
==== Frame ==== | ==== Frame ==== | ||
{{: | {{: | ||
- | A Frame is a container for other widgets. For example, the RadiobuttonGroup is a Frame that contains radio buttons. Frames are a good way to structure | + | A Frame is a container for other widgets. For example, the RadiobuttonGroup is a Frame that contains radio buttons. Frames are a good way to structure |
- | To place a widget | + | Frames are used, for example, in the Notebook widget. |
+ | ---- | ||
+ | ==== LabelFrame ==== | ||
+ | {{: | ||
+ | A LabelFrame is a Frame that also has an additional border with an integrated label. | ||
+ | ---- | ||
+ | ==== Scale ==== | ||
+ | {{: | ||
+ | The purpose of a scale widget is to specify a numerical value within a certain range. | ||
+ | |||
+ | A scale widget has a control variable CV to read or write the current value. | ||
+ | |||
+ | <code python> | ||
+ | print(self.scale1CV.get()) | ||
+ | </ | ||
+ | ---- | ||
+ | ==== LabeledScale ==== | ||
+ | {{: | ||
+ | Unlike the Scale widget, the LabeledScale displays the numerical value as a number. | ||
+ | |||
+ | {{: | ||
+ | ---- | ||
+ | ==== PanedWindow ==== | ||
+ | {{: | ||
+ | A PanedWindow is a container for child widgets. Each PanedWindow contains a horizontal or vertical stack of child widgets. Using the mouse, the user can drag the boundaries between the child widgets back and forth. In the example, there is a canvas at the top and a text widget at the bottom. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | To insert | ||
+ | ---- | ||
+ | ==== Menu ==== | ||
+ | {{: | ||
+ | A Menu widget is a menu bar with collapsible submenus. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | The Menu is defined via the // | ||
+ | < | ||
+ | File | ||
+ | New | ||
+ | Python | ||
+ | XML | ||
+ | Load | ||
+ | Save | ||
+ | Edit | ||
+ | Copy | ||
+ | Paste | ||
+ | - | ||
+ | Delete | ||
+ | </ | ||
+ | |||
+ | Event methods are created for the menu items, which are called when the menu item is selected. | ||
+ | |||
+ | <code python> | ||
+ | def menu1FileNewPython_Command(self): | ||
+ | # ToDo insert source code here | ||
+ | pass | ||
+ | </ | ||
+ | ---- | ||
+ | ==== PopupMenu ==== | ||
+ | {{: | ||
+ | A PopupMenu is a context menu that is invoked with the right mouse button. As with the Menu widget, it is defined via the // | ||
+ | |||
+ | You can assign a PopupMenu to each widget. To do this, open the //Events// tab in the object inspector and select Button " | ||
+ | |||
+ | {{: | ||
+ | |||
+ | In the event method that is created, you program the display of the PopupMenu at the clicked position. | ||
+ | |||
+ | <code python> | ||
+ | def root_ButtonPress(self, | ||
+ | self.popupMenu1.post(event.x_root, | ||
+ | pass | ||
+ | </ | ||
+ | ---- | ||
+ | ==== Menubutton ==== | ||
+ | {{: | ||
+ | The PopupMenu must also be created and then entered in the //Menu// attribute of the Menubutton. | ||
+ | ---- | ||
+ | ==== OptionMenu ==== | ||
+ | {{: | ||
+ | |||
+ | The selected option is accessed via the CV control variable. | ||
+ | |||
+ | <code python> | ||
+ | print(self.optionMenu1CV.get()) | ||
+ | </ | ||
+ | ---- | ||
+ | ==== Notebook==== | ||
+ | {{: | ||
+ | |||
+ | {{: | ||
+ | ---- | ||
+ | ==== Treeview==== | ||
+ | {{: | ||
+ | |||
+ | By appropriate indentation, | ||
+ | |||
+ | < | ||
+ | First | ||
+ | node A | ||
+ | node B | ||
+ | Second | ||
+ | node C | ||
+ | node D | ||
+ | </ | ||
+ | ---- | ||
+ | ==== Progressbar ==== | ||
+ | {{: | ||
+ | ---- | ||
+ | ==== Separator ==== | ||
+ | {{: | ||
+ | ---- | ||
+ | ==== Sizegrip ==== | ||
+ | {{: | ||
---- | ---- |
en/tkk.1646389800.txt.gz · Zuletzt geändert: 2022/03/04 11:30 von roehner