7 Commits

Author SHA1 Message Date
db4f5ec919 Bump to 4.5.5 2022-07-12 21:57:50 +02:00
78f4e1e2ee Merge remote-tracking branch 'origin/master' into develop 2022-07-12 21:54:29 +02:00
acaeceb96d added methods to CTkTextbox 2022-07-12 21:52:52 +02:00
be126c70ae Merge pull request #247 from Ripeey/Theme-Scrollbar-Patch
Add scrollbar default values in .json theme files
2022-07-10 15:10:43 -04:00
d45904b1e4 Update missing scrollbar configs in green and sweetkind themes. 2022-07-11 04:57:39 +05:30
4fbcce75a0 Update dark-blue.json 2022-07-10 23:19:14 +05:30
92de2c4183 fixed CTkButton fg_color type hint 2022-07-07 18:23:50 +02:00
11 changed files with 58 additions and 32 deletions

View File

@ -1,4 +1,4 @@
__version__ = "4.5.4"
__version__ = "4.5.5"
import os
import sys

View File

@ -72,6 +72,8 @@
"switch_border_width": 3,
"switch_corner_radius": 1000,
"switch_button_corner_radius": 1000,
"switch_button_length": 0
"switch_button_length": 0,
"scrollbar_corner_radius": 1000,
"scrollbar_border_spacing": 4
}
}

View File

@ -72,6 +72,8 @@
"switch_border_width": 3,
"switch_corner_radius": 1000,
"switch_button_corner_radius": 1000,
"switch_button_length": 0
"switch_button_length": 0,
"scrollbar_corner_radius": 1000,
"scrollbar_border_spacing": 4
}
}

View File

@ -72,6 +72,8 @@
"switch_border_width": 3,
"switch_corner_radius": 1000,
"switch_button_corner_radius": 1000,
"switch_button_length": 2
"switch_button_length": 2,
"scrollbar_corner_radius": 1000,
"scrollbar_border_spacing": 4
}
}

View File

@ -1,6 +1,6 @@
import tkinter
import sys
from typing import Union, Tuple, Callable, Literal
from typing import Union, Tuple, Callable
from .ctk_canvas import CTkCanvas
from ..theme_manager import ThemeManager
@ -13,8 +13,8 @@ class CTkButton(CTkBaseClass):
""" button with border, rounded corners, hover effect, image support """
def __init__(self, *args,
bg_color: Union[str, Tuple[str, str]] = None,
fg_color: Union[str, Tuple[str, str]] = "default_theme",
bg_color: Union[str, Tuple[str, str], None] = None,
fg_color: Union[str, Tuple[str, str], None] = "default_theme",
hover_color: Union[str, Tuple[str, str]] = "default_theme",
border_color: Union[str, Tuple[str, str]] = "default_theme",
text_color: Union[str, Tuple[str, str]] = "default_theme",
@ -250,7 +250,7 @@ class CTkButton(CTkBaseClass):
if "image" in kwargs:
self.image = kwargs.pop("image")
self.set_image(self.image)
require_redraw = True
if "compound" in kwargs:
self.compound = kwargs.pop("compound")

View File

@ -1,3 +1,4 @@
import sys
import tkinter
from .ctk_canvas import CTkCanvas
@ -106,6 +107,10 @@ class CTkLabel(CTkBaseClass):
self.canvas.configure(bg=ThemeManager.single_color(self.bg_color, self._appearance_mode))
def config(self, **kwargs):
sys.stderr.write("Warning: Use .configure() instead of .config()")
self.configure(**kwargs)
def configure(self, require_redraw=False, **kwargs):
if "anchor" in kwargs:
self.anchor = kwargs.pop("anchor")

View File

@ -28,12 +28,13 @@ class CTkTextbox(CTkBaseClass):
# color
self.fg_color = ThemeManager.theme["color"]["entry"] if fg_color == "default_theme" else fg_color
self.border_color = ThemeManager.theme["color"]["frame_border"] if border_color == "default_theme" else border_color
self.text_color = ThemeManager.theme["color"]["text"] if text_color == "default_theme" else text_color
# shape
self.corner_radius = ThemeManager.theme["shape"]["frame_corner_radius"] if corner_radius == "default_theme" else corner_radius
self.border_width = ThemeManager.theme["shape"]["frame_border_width"] if border_width == "default_theme" else border_width
self.text_color = ThemeManager.theme["color"]["text"] if text_color == "default_theme" else text_color
# text
self.text_font = (ThemeManager.theme["text"]["font"], ThemeManager.theme["text"]["size"]) if text_font == "default_theme" else text_font
# configure 1x1 grid
@ -56,28 +57,18 @@ class CTkTextbox(CTkBaseClass):
height=0,
font=self.text_font,
highlightthickness=0,
insertbackground=ThemeManager.single_color(("black", "white"), self._appearance_mode),
bg=ThemeManager.single_color(self.fg_color, self._appearance_mode),
**kwargs)
self.textbox.grid(row=0, column=0, padx=self.corner_radius, pady=self.corner_radius, rowspan=1, columnspan=1, sticky="nsew")
self.bind('<Configure>', self.update_dimensions_event)
self.draw()
def winfo_children(self):
""" winfo_children of CTkFrame without self.canvas widget,
because it's not a child but part of the CTkFrame itself """
child_widgets = super().winfo_children()
try:
child_widgets.remove(self.canvas)
return child_widgets
except ValueError:
return child_widgets
def set_scaling(self, *args, **kwargs):
super().set_scaling(*args, **kwargs)
self.textbox.configure(font=self.apply_font_scaling(self.text_font))
self.canvas.configure(width=self.apply_widget_scaling(self._desired_width), height=self.apply_widget_scaling(self._desired_height))
self.draw()
@ -110,17 +101,36 @@ class CTkTextbox(CTkBaseClass):
outline=ThemeManager.single_color(self.border_color, self._appearance_mode))
self.canvas.configure(bg=ThemeManager.single_color(self.bg_color, self._appearance_mode))
self.textbox.configure(fg=ThemeManager.single_color(self.text_color, self._appearance_mode),
bg=ThemeManager.single_color(self.fg_color, self._appearance_mode),
insertbackground=ThemeManager.single_color(("black", "white"), self._appearance_mode))
self.canvas.tag_lower("inner_parts")
self.canvas.tag_lower("border_parts")
def yview(self, args, kwargs):
self.textbox.yview(args, kwargs)
def yview(self, *args):
return self.textbox.yview(*args)
def xview(self, args, kwargs):
self.textbox.xview(args, kwargs)
def xview(self, *args):
return self.textbox.xview(*args)
def insert(self, args, kwargs):
self.textbox.insert(args, kwargs)
def insert(self, *args, **kwargs):
return self.textbox.insert(*args, **kwargs)
def focus(self):
return self.textbox.focus()
def tag_add(self, *args, **kwargs):
return self.textbox.tag_add(*args, **kwargs)
def tag_config(self, *args, **kwargs):
return self.textbox.tag_config(*args, **kwargs)
def tag_configure(self, *args, **kwargs):
return self.textbox.tag_configure(*args, **kwargs)
def tag_remove(self, *args, **kwargs):
return self.textbox.tag_remove(*args, **kwargs)
def configure(self, require_redraw=False, **kwargs):
if "fg_color" in kwargs:

View File

@ -28,6 +28,7 @@ progressbar_1.pack(pady=12, padx=10)
button_1 = customtkinter.CTkButton(master=frame_1, command=button_callback)
button_1.pack(pady=12, padx=10)
button_1.configure(state='disabled')
slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_callback, from_=0, to=1)
slider_1.pack(pady=12, padx=10)

View File

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

View File

@ -1,6 +1,6 @@
[metadata]
name = customtkinter
version = 4.5.4
version = 4.5.5
description = Create modern looking GUIs with Python
long_description = CustomTkinter UI-Library\n\n[](https://github.com/TomSchimansky/CustomTkinter/blob/master/documentation_images/Windows_dark.png)\n\nMore Information: https://github.com/TomSchimansky/CustomTkinter
long_description_content_type = text/markdown

View File

@ -39,7 +39,7 @@ class App(customtkinter.CTk):
self.appearance_mode_optionemenu.grid(row=6, column=0, padx=20, pady=(10, 10))
self.scaling_label = customtkinter.CTkLabel(self.sidebar_frame, text="Widget Scaling:", anchor="w")
self.scaling_label.grid(row=7, column=0, padx=20, pady=(10, 0))
self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["75%", "100%", "150%"],
self.scaling_optionemenu = customtkinter.CTkOptionMenu(self.sidebar_frame, values=["90%", "100%", "110%"],
command=self.change_scaling)
self.scaling_optionemenu.grid(row=8, column=0, padx=20, pady=(10, 20))
@ -50,8 +50,8 @@ class App(customtkinter.CTk):
self.main_button_1 = customtkinter.CTkButton(self, fg_color=None, border_width=2)
self.main_button_1.grid(row=3, column=3, padx=(10, 20), pady=(10, 20), sticky="nsew")
self.text_frame = customtkinter.CTkFrame(self)
self.text_frame.grid(row=0, column=1, padx=(20, 10), pady=(20, 10), sticky="nsew")
self.textbox = customtkinter.CTkTextbox(self)
self.textbox.grid(row=0, column=1, padx=(20, 10), pady=(20, 10), sticky="nsew")
# create radiobutton frame
self.radiobutton_frame = customtkinter.CTkFrame(self)
@ -119,6 +119,10 @@ class App(customtkinter.CTk):
self.scaling_optionemenu.set("100%")
self.optionmenu_1.set("CTkOptionmenu")
self.combobox_1.set("CTkComboBox")
self.textbox.insert("1.0",
"CTkTextbox\n\nLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.", )
#self.textbox.tag_add("headline", "1.0", "1.end")
#self.textbox.tag_config("headline", foreground="red")
def open_input_dialog(self):
dialog = customtkinter.CTkInputDialog(master=None, text="Type in a number:", title="CTkInputDialog")