From e02dff6ca47e6272fe11b140f0eb97b32446e2bd Mon Sep 17 00:00:00 2001 From: Maruo <43961566+maru0123-2004@users.noreply.github.com> Date: Fri, 11 Mar 2022 23:52:40 +0900 Subject: [PATCH 1/2] Add themes listup function --- gttk/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gttk/__init__.py b/gttk/__init__.py index 20ec9f9..409f555 100644 --- a/gttk/__init__.py +++ b/gttk/__init__.py @@ -81,6 +81,14 @@ def __init__(self, window: tk.Tk, theme: Optional[str] = None, theme_dir_prefix: def get_themes_directory(self) -> str: """Return the directory in which GTK looks for installed themes""" return self.tk.call("ttk::theme::gttk::gtkDirectory", "theme") + + def get_themes_available(self) -> Tuple[str]: + """Return installed themes""" + themes=self.tk.call("ttk::theme::gttk::availableStyles") + if themes == '': + return () + else: + return themes def get_default_files(self) -> Tuple[str]: """Return the files that GTK parses by default at start-up""" From e55cf343174fc1e26c8033f6be052fbd8f8a3fd8 Mon Sep 17 00:00:00 2001 From: Maruo <43961566+maru0123-2004@users.noreply.github.com> Date: Sat, 12 Mar 2022 12:44:21 +0900 Subject: [PATCH 2/2] Add description for listing theme and fix typo --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1521f30..39094df 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ sub-folder. Then, set the theme using the GTTK class ```python gttk = GTTK(window, theme="THEME_NAME_HERE") # OR -gttk.set_theme("THEME_NAME_HERE") +gttk.set_gtk_theme("THEME_NAME_HERE") ``` or you can create a `~/.gtkrc` file (the specific paths of the files that are parsed are found with `GTTK().get_default_files()`) and having @@ -142,6 +142,14 @@ gtk-theme-name = "THEME_NAME_HERE" This will then be applied to all GTK applications that read the resource file. +### Listing available theme +To list up available theme, run this function: +```python +gttk=GTTK(window) +gttk.get_themes_available() #this +``` +It return tuple of theme names. + ## Screenshots `gttk` should work with any GTK theme you can throw at it, but below are the themes Yaru and Adwaita as examples.