Merge branch 'TomSchimansky:master' into update_entry_box

This commit is contained in:
Trask Crane 2023-06-22 15:46:52 -04:00 committed by GitHub
commit 613587db68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 17 deletions

View File

@ -56,7 +56,6 @@ The **official** documentation can be found here:
## Example Program
To test customtkinter you can try this simple example with only a single button:
```python
import tkinter
import customtkinter
customtkinter.set_appearance_mode("System") # Modes: system (default), light, dark
@ -70,7 +69,7 @@ def button_function():
# Use CTkButton instead of tkinter Button
button = customtkinter.CTkButton(master=app, text="CTkButton", command=button_function)
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
button.place(relx=0.5, rely=0.5, anchor=customtkinter.CENTER)
app.mainloop()
```

View File

@ -1,4 +1,4 @@
__version__ = "5.1.3"
__version__ = "5.2.0"
import os
import sys

View File

@ -5,6 +5,7 @@ from .widgets import CTkEntry
from .widgets import CTkButton
from .widgets.theme import ThemeManager
from .ctk_toplevel import CTkToplevel
from .widgets.font import CTkFont
class CTkInputDialog(CTkToplevel):
@ -24,6 +25,7 @@ class CTkInputDialog(CTkToplevel):
entry_text_color: Optional[Union[str, Tuple[str, str]]] = None,
title: str = "CTkDialog",
font: Optional[Union[tuple, CTkFont]] = None,
text: str = "CTkDialog"):
super().__init__(fg_color=fg_color)
@ -39,9 +41,11 @@ class CTkInputDialog(CTkToplevel):
self._user_input: Union[str, None] = None
self._running: bool = False
self._title = title
self._text = text
self._font = font
self.title(title)
self.title(self._title)
self.lift() # lift window on top
self.attributes("-topmost", True) # stay on top
self.protocol("WM_DELETE_WINDOW", self._on_closing)
@ -50,7 +54,6 @@ class CTkInputDialog(CTkToplevel):
self.grab_set() # make other windows not clickable
def _create_widgets(self):
self.grid_columnconfigure((0, 1), weight=1)
self.rowconfigure(0, weight=1)
@ -59,14 +62,16 @@ class CTkInputDialog(CTkToplevel):
wraplength=300,
fg_color="transparent",
text_color=self._text_color,
text=self._text,)
text=self._text,
font=self._font)
self._label.grid(row=0, column=0, columnspan=2, padx=20, pady=20, sticky="ew")
self._entry = CTkEntry(master=self,
width=230,
fg_color=self._entry_fg_color,
border_color=self._entry_border_color,
text_color=self._entry_text_color)
text_color=self._entry_text_color,
font=self._font)
self._entry.grid(row=1, column=0, columnspan=2, padx=20, pady=(0, 20), sticky="ew")
self._ok_button = CTkButton(master=self,
@ -76,6 +81,7 @@ class CTkInputDialog(CTkToplevel):
hover_color=self._button_hover_color,
text_color=self._button_text_color,
text='Ok',
font=self._font,
command=self._ok_event)
self._ok_button.grid(row=2, column=0, columnspan=1, padx=(20, 10), pady=(0, 20), sticky="ew")
@ -86,7 +92,8 @@ class CTkInputDialog(CTkToplevel):
hover_color=self._button_hover_color,
text_color=self._button_text_color,
text='Cancel',
command=self._ok_event)
font=self._font,
command=self._cancel_event)
self._cancel_button.grid(row=2, column=1, columnspan=1, padx=(10, 20), pady=(0, 20), sticky="ew")
self.after(150, lambda: self._entry.focus()) # set focus to entry with slight delay, otherwise it won't work

View File

@ -436,6 +436,7 @@ class CTkButton(CTkBaseClass):
if "anchor" in kwargs:
self._anchor = kwargs.pop("anchor")
self._create_grid()
require_redraw = True
super().configure(require_redraw=require_redraw, **kwargs)

View File

@ -186,7 +186,7 @@ class CTkSegmentedButton(CTkFrame):
for index, value in enumerate(self._value_list):
self.grid_columnconfigure(index, weight=1, minsize=self._current_height)
self._buttons_dict[value].grid(row=0, column=index, sticky="ew")
self._buttons_dict[value].grid(row=0, column=index, sticky="nsew")
def _create_buttons_from_values(self):
assert len(self._buttons_dict) == 0

View File

@ -171,8 +171,9 @@ class CTkTabview(CTkBaseClass):
padx=self._apply_widget_scaling(max(self._corner_radius, self._border_width)),
pady=self._apply_widget_scaling(max(self._corner_radius, self._border_width)))
def _grid_forget_all_tabs(self):
for frame in self._tab_dict.values():
def _grid_forget_all_tabs(self, exclude_name=None):
for name, frame in self._tab_dict.items():
if name != exclude_name:
frame.grid_forget()
def _create_tab(self) -> CTkFrame:
@ -360,8 +361,8 @@ class CTkTabview(CTkBaseClass):
if name in self._tab_dict:
self._current_name = name
self._segmented_button.set(name)
self._grid_forget_all_tabs()
self._set_grid_tab_by_name(name)
self.after(100, lambda: self._grid_forget_all_tabs(exclude_name=name))
else:
raise ValueError(f"CTkTabview has no tab named '{name}'")

View File

@ -52,7 +52,10 @@ class CTkFont(Font):
def remove_size_configure_callback(self, callback: Callable):
""" remove function, that gets called when font got configured """
try:
self._size_configure_callback_list.remove(callback)
except ValueError:
pass
def create_scaled_tuple(self, font_scaling: float) -> Tuple[str, int, str]:
""" return scaled tuple representation of font in the form (family: str, size: int, style: str)"""

View File

@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
github_url = "https://github.com/TomSchimansky/CustomTkinter"
[tool.tbump.version]
current = "5.1.3"
current = "5.2.0"
# Example of a semver regexp.
# Make sure this matches current_version before

View File

@ -1,6 +1,6 @@
[metadata]
name = customtkinter
version = 5.1.3
version = 5.2.0
description = Create modern looking GUIs with Python
long_description = A modern and customizable python UI-library based on Tkinter: https://customtkinter.tomschimansky.com
long_description_content_type = text/markdown
@ -9,7 +9,7 @@ author = Tom Schimansky
license = Creative Commons Zero v1.0 Universal
license_file = LICENSE
classifiers =
License :: MIT License
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3 :: Only