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

Simple but required additions (no mixed/conflicting changes) #2545

Open
wants to merge 4 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
3 changes: 3 additions & 0 deletions customtkinter/windows/widgets/ctk_radiobutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ def configure(self, require_redraw=False, **kwargs):
self._check_state = True if self._variable.get() == self._value else False
require_redraw = True

if "value" in kwargs:
self._value = kwargs.pop("value")

super().configure(require_redraw=require_redraw, **kwargs)

def cget(self, attribute_name: str) -> any:
Expand Down
10 changes: 10 additions & 0 deletions customtkinter/windows/widgets/ctk_tabview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Union, Tuple, Dict, List, Callable, Optional, Any

from .theme import ThemeManager
from .font import CTkFont
from .ctk_frame import CTkFrame
from .core_rendering import CTkCanvas
from .core_rendering import DrawEngine
Expand Down Expand Up @@ -39,6 +40,7 @@ def __init__(self,

text_color: Optional[Union[str, Tuple[str, str]]] = None,
text_color_disabled: Optional[Union[str, Tuple[str, str]]] = None,
font: Optional[Union[tuple, CTkFont]] = None,

command: Union[Callable, Any] = None,
anchor: str = "center",
Expand All @@ -48,6 +50,9 @@ def __init__(self,
# transfer some functionality to CTkFrame
super().__init__(master=master, bg_color=bg_color, width=width, height=height, **kwargs)

# font
segmented_button_font = CTkFont() if font is None else font

# color
self._border_color = ThemeManager.theme["CTkFrame"]["border_color"] if border_color is None else self._check_color_type(border_color)

Expand Down Expand Up @@ -85,6 +90,7 @@ def __init__(self,
unselected_hover_color=segmented_button_unselected_hover_color,
text_color=text_color,
text_color_disabled=text_color_disabled,
font=segmented_button_font,
corner_radius=corner_radius,
border_width=self._segmented_button_border_width,
command=self._segmented_button_callback,
Expand Down Expand Up @@ -277,6 +283,8 @@ def configure(self, require_redraw=False, **kwargs):
self._segmented_button.configure(text_color=kwargs.pop("text_color"))
if "text_color_disabled" in kwargs:
self._segmented_button.configure(text_color_disabled=kwargs.pop("text_color_disabled"))
if "font" in kwargs:
self._segmented_button.configure(font=kwargs.pop("font"))

if "command" in kwargs:
self._command = kwargs.pop("command")
Expand Down Expand Up @@ -313,6 +321,8 @@ def cget(self, attribute_name: str):
return self._segmented_button.cget(attribute_name)
elif attribute_name == "text_color_disabled":
return self._segmented_button.cget(attribute_name)
elif attribute_name == "font":
return self._segmented_button.cget(attribute_name)

elif attribute_name == "command":
return self._command
Expand Down
11 changes: 7 additions & 4 deletions customtkinter/windows/widgets/image/ctk_image.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Tuple, Dict, Callable, List
from typing import Tuple, Dict, Callable, List, Any
try:
from PIL import Image, ImageTk
except ImportError:
Expand All @@ -21,7 +21,8 @@ class CTkImage:
def __init__(self,
light_image: "Image.Image" = None,
dark_image: "Image.Image" = None,
size: Tuple[int, int] = (20, 20)):
size: Tuple[int, int] = (20, 20),
master: Any = None):

if not self._checked_PIL_import:
self._check_pil_import()
Expand All @@ -31,6 +32,8 @@ def __init__(self,
self._check_images()
self._size = size

self._master = master

self._configure_callback_list: List[Callable] = []
self._scaled_light_photo_images: Dict[Tuple[int, int], ImageTk.PhotoImage] = {}
self._scaled_dark_photo_images: Dict[Tuple[int, int], ImageTk.PhotoImage] = {}
Expand Down Expand Up @@ -96,14 +99,14 @@ def _get_scaled_light_photo_image(self, scaled_size: Tuple[int, int]) -> "ImageT
if scaled_size in self._scaled_light_photo_images:
return self._scaled_light_photo_images[scaled_size]
else:
self._scaled_light_photo_images[scaled_size] = ImageTk.PhotoImage(self._light_image.resize(scaled_size))
self._scaled_light_photo_images[scaled_size] = ImageTk.PhotoImage(self._light_image.resize(scaled_size), master=self._master)
return self._scaled_light_photo_images[scaled_size]

def _get_scaled_dark_photo_image(self, scaled_size: Tuple[int, int]) -> "ImageTk.PhotoImage":
if scaled_size in self._scaled_dark_photo_images:
return self._scaled_dark_photo_images[scaled_size]
else:
self._scaled_dark_photo_images[scaled_size] = ImageTk.PhotoImage(self._dark_image.resize(scaled_size))
self._scaled_dark_photo_images[scaled_size] = ImageTk.PhotoImage(self._dark_image.resize(scaled_size), master=self._master)
return self._scaled_dark_photo_images[scaled_size]

def create_scaled_photo_image(self, widget_scaling: float, appearance_mode: str) -> "ImageTk.PhotoImage":
Expand Down