| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6cbb225 commit 27148d0
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2016,6 +2016,16 @@ If you don't know the class name of a widget, use the method | |||
| 2016 | 2016 | Returns a tuple of all known themes. | |
| 2017 | 2017 | ||
| 2018 | 2018 | ||
| 2019 | + .. method:: theme_styles(themename=None) | ||
| 2020 | + | ||
| 2021 | + Returns a tuple of all styles in *themename*. | ||
| 2022 | + If *themename* is not given, the current theme is used. | ||
| 2023 | + | ||
| 2024 | + .. versionadded:: next | ||
| 2025 | + | ||
| 2026 | + Availability: Tk 9.0. | ||
| 2027 | + | ||
| 2028 | + | ||
| 2019 | 2029 | .. method:: theme_use(themename=None) | |
| 2020 | 2030 | ||
| 2021 | 2031 | If *themename* is not given, returns the theme in use. Otherwise, sets | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,6 +173,11 @@ tkinter | |||
| 173 | 173 | synchronization of the displayed view with the underlying text. | |
| 174 | 174 | (Contributed by Serhiy Storchaka in :gh:`151675`.) | |
| 175 | 175 | ||
| 176 | + * Added the :meth:`ttk.Style.theme_styles | ||
| 177 | + <tkinter.ttk.Style.theme_styles>` method which returns the list of styles | ||
| 178 | + defined in a theme. | ||
| 179 | + (Contributed by Serhiy Storchaka in :gh:`151920`.) | ||
| 180 | + | ||
| 176 | 181 | * Added new :class:`!tkinter.Canvas` methods :meth:`~tkinter.Canvas.rchars` | |
| 177 | 182 | which replaces the text or coordinates of canvas items, and | |
| 178 | 183 | :meth:`~tkinter.Canvas.rotate` which rotates the coordinates of canvas items. | |
@@ -211,7 +216,6 @@ tkinter | |||
| 211 | 216 | dithered image when its data was supplied in pieces. | |
| 212 | 217 | (Contributed by Serhiy Storchaka in :gh:`151888`.) | |
| 213 | 218 | ||
| 214 | - | ||
| 215 | 219 | xml | |
| 216 | 220 | --- | |
| 217 | 221 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,8 @@ | |||
| 6 | 6 | from test import support | |
| 7 | 7 | from test.support import requires | |
| 8 | 8 | from test.test_tkinter.support import setUpModule # noqa: F401 | |
| 9 | - from test.test_tkinter.support import AbstractTkTest, get_tk_patchlevel | ||
| 9 | + from test.test_tkinter.support import (AbstractTkTest, get_tk_patchlevel, | ||
| 10 | + requires_tk) | ||
| 10 | 11 | ||
| 11 | 12 | requires('gui') | |
| 12 | 13 | ||
@@ -124,6 +125,25 @@ def test_theme_use(self): | |||
| 124 | 125 | ||
| 125 | 126 | self.style.theme_use(curr_theme) | |
| 126 | 127 | ||
| 128 | + @requires_tk(9, 0) | ||
| 129 | + def test_theme_styles(self): | ||
| 130 | + # The 'default' theme is always available and defines the base styles. | ||
| 131 | + default_styles = self.style.theme_styles('default') | ||
| 132 | + self.assertIsInstance(default_styles, tuple) | ||
| 133 | + self.assertIn('.', default_styles) | ||
| 134 | + self.assertIn('TButton', default_styles) | ||
| 135 | + | ||
| 136 | + # Without an argument the current theme is used. | ||
| 137 | + styles = self.style.theme_styles() | ||
| 138 | + self.assertIsInstance(styles, tuple) | ||
| 139 | + self.assertIn('.', styles) | ||
| 140 | + | ||
| 141 | + for theme in self.style.theme_names(): | ||
| 142 | + self.assertIsInstance(self.style.theme_styles(theme), tuple) | ||
| 143 | + | ||
| 144 | + self.assertRaises(tkinter.TclError, | ||
| 145 | + self.style.theme_styles, 'nonexistingname') | ||
| 146 | + | ||
| 127 | 147 | def test_theme_settings(self): | |
| 128 | 148 | style = self.style | |
| 129 | 149 | theme = style.theme_use() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -492,6 +492,20 @@ def theme_names(self): | |||
| 492 | 492 | return self.tk.splitlist(self.tk.call(self._name, "theme", "names")) | |
| 493 | 493 | ||
| 494 | 494 | ||
| 495 | + def theme_styles(self, themename=None): | ||
| 496 | + """Returns a list of all styles in themename. | ||
| 497 | + | ||
| 498 | + If themename is omitted, the current theme is used. | ||
| 499 | + | ||
| 500 | + Availability: Tk 9.0. | ||
| 501 | + """ | ||
| 502 | + if themename is None: | ||
| 503 | + return self.tk.splitlist( | ||
| 504 | + self.tk.call(self._name, "theme", "styles")) | ||
| 505 | + return self.tk.splitlist( | ||
| 506 | + self.tk.call(self._name, "theme", "styles", themename)) | ||
| 507 | + | ||
| 508 | + | ||
| 495 | 509 | def theme_use(self, themename=None): | |
| 496 | 510 | """If themename is None, returns the theme in use, otherwise, set | |
| 497 | 511 | the current theme to themename, refreshes all widgets and emits | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + Add the :meth:`ttk.Style.theme_styles <tkinter.ttk.Style.theme_styles>` | ||
| 2 | + method, wrapping the Tk ``ttk::style theme styles`` subcommand, which | ||
| 3 | + returns the list of styles defined in a theme. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments