From 53c0b00babe1ca507cd419ee410d3f11a925d93a Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sun, 2 Jan 2022 12:14:46 +0100 Subject: [PATCH] fixed bug when button click destroys button itself (version 1.8) --- customtkinter/__init__.py | 2 +- customtkinter/customtkinter_button.py | 2 +- examples/simple_example.py | 48 +++------------------------ setup.py | 2 +- 4 files changed, 8 insertions(+), 46 deletions(-) diff --git a/customtkinter/__init__.py b/customtkinter/__init__.py index d39b93d..8f2a794 100644 --- a/customtkinter/__init__.py +++ b/customtkinter/__init__.py @@ -1,4 +1,4 @@ -__version__ = "1.7" +__version__ = "1.8" from .customtkinter_button import CTkButton from .customtkinter_slider import CTkSlider diff --git a/customtkinter/customtkinter_button.py b/customtkinter/customtkinter_button.py index eaa47d0..83fe7b1 100644 --- a/customtkinter/customtkinter_button.py +++ b/customtkinter/customtkinter_button.py @@ -501,8 +501,8 @@ class CTkButton(tkinter.Frame): def clicked(self, event=0): if self.function is not None: if self.state is not tkinter.DISABLED: - self.function() self.on_leave() + self.function() def set_appearance_mode(self, mode_string): if mode_string.lower() == "dark": diff --git a/examples/simple_example.py b/examples/simple_example.py index a43c026..005cd77 100644 --- a/examples/simple_example.py +++ b/examples/simple_example.py @@ -1,46 +1,8 @@ -import tkinter -import customtkinter # <- import the CustomTkinter module +import tkinter as tk +import customtkinter as ctk -root_tk = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window) -root_tk.geometry("400x300") -root_tk.title("CustomTkinter Test") +root = tk.Tk() -customtkinter.set_appearance_mode("System") # Other: "Dark", "Light" +btn = ctk.CTkButton(master=root, text="EXIT", command=root.destroy).pack() - -def button_function(): - print("Button click") - - -def slider_function(value): - progressbar_1.set(value) - - -def check_box_function(): - print("checkbox_1:", checkbox_1.get()) - - -frame_1 = customtkinter.CTkFrame(master=root_tk, width=300, height=260, corner_radius=15) -frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER) - -label_1 = customtkinter.CTkLabel(master=frame_1) -label_1.place(relx=0.5, rely=0.1, anchor=tkinter.CENTER) - -progressbar_1 = customtkinter.CTkProgressBar(master=frame_1) -progressbar_1.place(relx=0.5, rely=0.25, anchor=tkinter.CENTER) - -button_1 = customtkinter.CTkButton(master=frame_1, corner_radius=10, command=button_function) -button_1.place(relx=0.5, rely=0.4, anchor=tkinter.CENTER) -# button_1.configure(state="disabled") - -slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_function, from_=0, to=1, progress_color="gray20") -slider_1.place(relx=0.5, rely=0.55, anchor=tkinter.CENTER) -slider_1.set(1.5) - -entry_1 = customtkinter.CTkEntry(master=frame_1) -entry_1.place(relx=0.5, rely=0.75, anchor=tkinter.CENTER) - -checkbox_1 = customtkinter.CTkCheckBox(master=frame_1, command=check_box_function) -checkbox_1.place(relx=0.5, rely=0.9, anchor=tkinter.CENTER) - -root_tk.mainloop() +root.mainloop() \ No newline at end of file diff --git a/setup.py b/setup.py index b3298da..e7f32ba 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ def read(filename): setup(name="customtkinter", - version="1.7", + version="1.8", author="Tom Schimansky", license="Creative Commons Zero v1.0 Universal", url="https://github.com/TomSchimansky/CustomTkinter",