From 16c949b1aae6a00f6312a9ab5fe3037c7f8f023c Mon Sep 17 00:00:00 2001 From: RedFantom Date: Tue, 15 Dec 2020 18:03:05 +0100 Subject: [PATCH 1/3] Fix setup.py for upload to PyPI and exclude MSVCRT140.dll from wheels --- setup.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6fbe019..65eb4b2 100644 --- a/setup.py +++ b/setup.py @@ -72,6 +72,8 @@ class DependencyWalker(object): - The DLL_SEARCH_PATHS environment variable """ + EXCLUDE = ["MSVCRT140.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 From ce72bf9c90457bf365875ecdda3928eac6317e56 Mon Sep 17 00:00:00 2001 From: RedFantom Date: Tue, 15 Dec 2020 18:16:08 +0100 Subject: [PATCH 2/3] Exclude VCRUNTIME140.dll and add PyPI badge --- README.md | 2 ++ setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ef25281..da4d7d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # GTK Theme for Python's tkinter/ttk ![Build Status](https://api.travis-ci.com/TkinterEP/python-gttk.svg?branch=master) [![Build status](https://ci.appveyor.com/api/projects/status/80y25364onq2anmw/branch/master?svg=true)](https://ci.appveyor.com/project/RedFantom/python-gttk/branch/master) +[![PyPI version](https://badge.fury.io/py/gttk.svg)](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) diff --git a/setup.py b/setup.py index 65eb4b2..81bca7b 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,7 @@ class DependencyWalker(object): - The DLL_SEARCH_PATHS environment variable """ - EXCLUDE = ["MSVCRT140.dll"] + 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): From 11a2f315a46cbea09935c4b7c86bbcfe8d156a31 Mon Sep 17 00:00:00 2001 From: RedFantom Date: Wed, 16 Dec 2020 20:49:28 +0100 Subject: [PATCH 3/3] Extend theme loading description and create LIB option --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ gttk/__init__.py | 7 ++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da4d7d4..1521f30 100644 --- a/README.md +++ b/README.md @@ -96,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: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy