mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
25297c2598 | |||
4e155aedd6 | |||
3a5d34cef6 | |||
e42db49ca5 | |||
a7c0fc2a3c | |||
9be2a76b25 | |||
b1ac3b6d45 | |||
a6b563abb1 |
@ -1,4 +1,4 @@
|
||||
__version__ = "4.0.2"
|
||||
__version__ = "4.0.4"
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
@ -51,7 +51,7 @@ class FontManager:
|
||||
return cls.windows_load_font(font_path, private=True, enumerable=False)
|
||||
|
||||
# Linux
|
||||
elif sys.platform.startswith("win"):
|
||||
elif sys.platform.startswith("linux"):
|
||||
try:
|
||||
shutil.copy(font_path, os.path.expanduser("~/.fonts/"))
|
||||
return True
|
||||
|
@ -2,7 +2,12 @@ import tkinter
|
||||
import tkinter.ttk as ttk
|
||||
import copy
|
||||
import re
|
||||
from typing import Callable, Union, TypedDict
|
||||
from typing import Callable, Union
|
||||
|
||||
try:
|
||||
from typing import TypedDict
|
||||
except ImportError:
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from ..windows.ctk_tk import CTk
|
||||
from ..windows.ctk_toplevel import CTkToplevel
|
||||
@ -130,22 +135,30 @@ class CTkBaseClass(tkinter.Frame):
|
||||
|
||||
self.draw(no_color_updates=True) # faster drawing without color changes
|
||||
|
||||
def detect_color_of_master(self):
|
||||
def detect_color_of_master(self, master_widget=None):
|
||||
""" detect color of self.master widget to set correct bg_color """
|
||||
|
||||
if isinstance(self.master, CTkBaseClass) and hasattr(self.master, "fg_color"): # master is CTkFrame
|
||||
return self.master.fg_color
|
||||
if master_widget is None:
|
||||
master_widget = self.master
|
||||
|
||||
elif isinstance(self.master, (ttk.Frame, ttk.LabelFrame, ttk.Notebook)): # master is ttk widget
|
||||
if isinstance(master_widget, CTkBaseClass) and hasattr(master_widget, "fg_color"): # master is CTkFrame
|
||||
if master_widget.fg_color is not None:
|
||||
return master_widget.fg_color
|
||||
|
||||
# if fg_color of master is None, try to retrieve fg_color from master of master
|
||||
elif hasattr(master_widget.master, "master"):
|
||||
return self.detect_color_of_master(self.master.master)
|
||||
|
||||
elif isinstance(master_widget, (ttk.Frame, ttk.LabelFrame, ttk.Notebook)): # master is ttk widget
|
||||
try:
|
||||
ttk_style = ttk.Style()
|
||||
return ttk_style.lookup(self.master.winfo_class(), 'background')
|
||||
return ttk_style.lookup(master_widget.winfo_class(), 'background')
|
||||
except Exception:
|
||||
return "#FFFFFF", "#000000"
|
||||
|
||||
else: # master is normal tkinter widget
|
||||
try:
|
||||
return self.master.cget("bg") # try to get bg color by .cget() method
|
||||
return master_widget.cget("bg") # try to get bg color by .cget() method
|
||||
except Exception:
|
||||
return "#FFFFFF", "#000000"
|
||||
|
||||
|
@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
||||
github_url = "https://github.com/TomSchimansky/CustomTkinter"
|
||||
|
||||
[tool.tbump.version]
|
||||
current = "4.0.2"
|
||||
current = "4.0.4"
|
||||
|
||||
# Example of a semver regexp.
|
||||
# Make sure this matches current_version before
|
||||
|
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = customtkinter
|
||||
version = 4.0.2
|
||||
version = 4.0.4
|
||||
description = Create modern looking GUIs with Python
|
||||
long_description = file: README.md
|
||||
long_description_content_type = text/markdown
|
||||
@ -14,10 +14,12 @@ classifiers =
|
||||
Programming Language :: Python :: 3 :: Only
|
||||
|
||||
[options]
|
||||
python_requires = >=3.7
|
||||
packages =
|
||||
customtkinter
|
||||
customtkinter.widgets
|
||||
customtkinter.windows
|
||||
install_requires =
|
||||
darkdetect
|
||||
typing_extensions; python_version<="3.7"
|
||||
include_package_data = True
|
||||
|
Reference in New Issue
Block a user