diff --git a/README.md b/README.md index ef25281..1521f30 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # GTK Theme for Python's tkinter/ttk  [](https://ci.appveyor.com/project/RedFantom/python-gttk/branch/master) +[](https://pypi.python.org/pypi/gttk) + Would you like to have a more native look for your Tkinter application? Are the themes provided in [ttkthemes](https://github.com/TkinterEP/ttkthemes) @@ -94,6 +96,52 @@ sys.path = sys.path[2:] import gttk ``` +## Setting the GTK Theme +So, now that you've installed `gttk` and loaded it into your application, +you want to specify what GTK should be loaded. Due to the nature of GTK, +this may seem a bit complicated, but it's not too hard. + +### Default theme directories +The default theme directory on **Linux** are specified by the XDG +standard and generally `/usr/share/themes` is used. This folder contains +Gnome themes, which can be applied to `gttk` if it includes a GTK+-2.0 +theme variant. + +On **Windows** the default directory is given by +`${dirname(GetModuleFileName())}\\share\\themes`, where `GetModuleFileName()` +is a `win32` function that returns the path to the current executable, +so usually `%PYTHONDIR%\\python.exe`. + +These folders are not really convenient, as users do not generally +have write permissions for them. + +### Setting a different theme directory +A different theme directory may be specified by passing the +`theme_dir_prefix` kwarg to `GTTK.__init__`, or by setting the +environment variable `GTK_DATA_PREFIX`. This value only serves as a +prefix, so then the theme directory becomes +`${GTK_DATA_PREFIX}/share/themes`. Check the absolute path with +`GTTK().get_themes_directory()`. + +### Loading a different theme +To load a theme from the theme directory, first make sure that you have +copied a proper GTK+-2.0 theme into the theme directory, in its own +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") +``` +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 +at least the line +```python +gtk-theme-name = "THEME_NAME_HERE" +``` + +This will then be applied to all GTK applications that read the resource +file. + ## Screenshots `gttk` should work with any GTK theme you can throw at it, but below are the themes Yaru and Adwaita as examples. diff --git a/gttk/__init__.py b/gttk/__init__.py index 9d4e4a9..20ec9f9 100644 --- a/gttk/__init__.py +++ b/gttk/__init__.py @@ -46,7 +46,12 @@ def __init__(self, window: tk.Tk, theme: Optional[str] = None, theme_dir_prefix: folder = os.path.dirname(os.path.abspath(__file__)) if theme_dir_prefix is not None: - os.environ["GTK_DATA_PREFIX"] = theme_dir_prefix + if theme_dir_prefix == "LIB": + os.environ["GTK_DATA_PREFIX"] = folder + elif os.path.exists(theme_dir_prefix): + os.environ["GTK_DATA_PREFIX"] = theme_dir_prefix + else: # Invalid directory specified, throw error here as GTK will fail silently + raise FileNotFoundError("Specified theme directory prefix does not exist: {}".format(theme_dir_prefix)) # Create loaders.cache on win32 platforms to find pixbuf loaders properly if "win" in sys.platform: diff --git a/setup.py b/setup.py index 6fbe019..81bca7b 100644 --- a/setup.py +++ b/setup.py @@ -72,6 +72,8 @@ class DependencyWalker(object): - The DLL_SEARCH_PATHS environment variable """ + EXCLUDE = ["MSVCRT140.dll", "VCRUNTIME140.dll"] + def __init__(self, dll_file: str, dependencies_exe="deps\\dependencies.exe", specials=dict()): if not os.path.exists(dependencies_exe): printf("dependencies.exe is required to find all dependency DLLs") @@ -146,7 +148,9 @@ def _find_dll_abs_path(self, dll_name: str) -> Optional[str]: def copy_to_target(self, target: str): for p in self.dependency_dll_files: - if os.path.basename(p) in self._specials: + if os.path.basename(p) in self.EXCLUDE: + continue + elif os.path.basename(p) in self._specials: t = os.path.join(target, *self._specials[os.path.basename(p)].split("/"), os.path.basename(p)) d = os.path.dirname(t) if not os.path.exists(d): @@ -192,6 +196,7 @@ def copy_to_target(self, target: str): url="https://github.com/RedFantom/python-gttk", download_url="https://github.com/RedFantom/python-gttk/releases", license="GNU GPLv3", + long_description_content_type="text/markdown", long_description=read("README.md"), zip_safe=False, **kwargs
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: