"""Ttk Theme Selector. Although it is a theme selector, you won't notice many changes since there is only a combobox and a frame around. """ import ttk class App(ttk.Frame): def __init__(self): ttk.Frame.__init__(self) self.style = ttk.Style() self._setup_widgets() def _change_theme(self, event): if event.widget.current(): # value #0 is not a theme newtheme = event.widget.get() # change to the new theme and refresh all the widgets self.style.theme_use(newtheme) def _setup_widgets(self): themes = list(self.style.theme_names()) themes.insert(0, "Pick a theme") # Create a readonly Combobox which will display 4 values at max, # which will cause it to create a scrollbar if there are more # than 4 values in total. themes_combo = ttk.Combobox(self, values=themes, state="readonly", height=4) themes_combo.set(themes[0]) # sets the combobox value to "Pick a theme" # Combobox widget generates a <<ComboboxSelected>> virtual event # when the user selects an element. This event is generated after # the listbox is unposted (after you select an item, the combobox's # listbox disappears, then it is said that listbox is now unposted). themes_combo.bind("<<ComboboxSelected>>", self._change_theme) themes_combo.pack(fill='x') self.pack(fill='both', expand=1) def main(): app = App() app.master.title("Ttk Combobox") app.mainloop() if __name__ == "__main__": main()
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
img | Folder | 0755 |
|
|
combo_themes.py | File | 1.58 KB | 0644 |
|
combo_themes.pyc | File | 1.88 KB | 0644 |
|
combo_themes.pyo | File | 1.88 KB | 0644 |
|
dirbrowser.py | File | 2.65 KB | 0644 |
|
dirbrowser.pyc | File | 3.88 KB | 0644 |
|
dirbrowser.pyo | File | 3.88 KB | 0644 |
|
listbox_scrollcmd.py | File | 1.13 KB | 0644 |
|
listbox_scrollcmd.pyc | File | 1.56 KB | 0644 |
|
listbox_scrollcmd.pyo | File | 1.56 KB | 0644 |
|
mac_searchentry.py | File | 3.63 KB | 0644 |
|
mac_searchentry.pyc | File | 3.88 KB | 0644 |
|
mac_searchentry.pyo | File | 3.88 KB | 0644 |
|
notebook_closebtn.py | File | 2.47 KB | 0644 |
|
notebook_closebtn.pyc | File | 2.91 KB | 0644 |
|
notebook_closebtn.pyo | File | 2.91 KB | 0644 |
|
plastik_theme.py | File | 9.36 KB | 0644 |
|
plastik_theme.pyc | File | 7.34 KB | 0644 |
|
plastik_theme.pyo | File | 7.34 KB | 0644 |
|
roundframe.py | File | 5.47 KB | 0644 |
|
roundframe.pyc | File | 6.28 KB | 0644 |
|
roundframe.pyo | File | 6.28 KB | 0644 |
|
theme_selector.py | File | 1.92 KB | 0644 |
|
theme_selector.pyc | File | 2.81 KB | 0644 |
|
theme_selector.pyo | File | 2.81 KB | 0644 |
|
treeview_multicolumn.py | File | 4.15 KB | 0644 |
|
treeview_multicolumn.pyc | File | 5.35 KB | 0644 |
|
treeview_multicolumn.pyo | File | 5.35 KB | 0644 |
|
ttkcalendar.py | File | 8.12 KB | 0644 |
|
ttkcalendar.pyc | File | 9.54 KB | 0644 |
|
ttkcalendar.pyo | File | 9.54 KB | 0644 |
|
widget_state.py | File | 2.66 KB | 0644 |
|
widget_state.pyc | File | 3.33 KB | 0644 |
|
widget_state.pyo | File | 3.33 KB | 0644 |
|