Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add theme list up function #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions gttk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down