mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
fixed numerous bg_color bugs, added complete_test.py for color testing, changed AppearanceModeTracker to non-threaded approach with tk.after()
This commit is contained in:
@ -90,8 +90,7 @@ class App(customtkinter.CTk):
|
||||
|
||||
self.progressbar = customtkinter.CTkProgressBar(master=self.frame_info,
|
||||
width=250,
|
||||
height=15,
|
||||
border_width=3)
|
||||
height=12)
|
||||
self.progressbar.place(relx=0.5, rely=0.85, anchor=tkinter.S)
|
||||
|
||||
# from tkintermapview import TkinterMapView
|
||||
|
@ -18,7 +18,7 @@ class App(customtkinter.CTk):
|
||||
MAIN_HOVER = "#458577"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.title(App.APP_NAME)
|
||||
self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
|
||||
@ -102,8 +102,7 @@ class App(customtkinter.CTk):
|
||||
self.progressbar = customtkinter.CTkProgressBar(master=self.frame_info,
|
||||
progress_color=App.MAIN_COLOR,
|
||||
width=250,
|
||||
height=15,
|
||||
border_width=3)
|
||||
height=12)
|
||||
self.progressbar.place(relx=0.5, rely=0.85, anchor=tkinter.S)
|
||||
self.progressbar.set(0.65)
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
import tkinter
|
||||
import customtkinter # <- import the CustomTkinter module
|
||||
|
||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||
|
||||
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("400x240")
|
||||
root_tk.title("CustomTkinter Test")
|
||||
|
||||
|
||||
def change_button_2_state():
|
||||
if button_2.state == tkinter.NORMAL:
|
||||
button_2.configure(state=tkinter.DISABLED)
|
||||
elif button_2.state == tkinter.DISABLED:
|
||||
button_2.configure(state=tkinter.NORMAL)
|
||||
|
||||
|
||||
def button_2_click():
|
||||
print("button_2 clicked")
|
||||
|
||||
|
||||
frame_1 = customtkinter.CTkFrame(master=root_tk, width=300, height=200, corner_radius=15)
|
||||
frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||
|
||||
button_1 = customtkinter.CTkButton(master=frame_1, text="Disable/Enable Button_2",
|
||||
corner_radius=10, command=change_button_2_state, width=200)
|
||||
button_1.place(relx=0.5, rely=0.3, anchor=tkinter.CENTER)
|
||||
|
||||
button_2 = customtkinter.CTkButton(master=frame_1, text="Button_2",
|
||||
corner_radius=10, command=button_2_click)
|
||||
button_2.place(relx=0.5, rely=0.7, anchor=tkinter.CENTER)
|
||||
|
||||
root_tk.mainloop()
|
@ -11,15 +11,15 @@ PATH = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
class App(customtkinter.CTk):
|
||||
|
||||
APP_NAME = "CustomTkinter background gardient"
|
||||
APP_NAME = "CustomTkinter background gradient image"
|
||||
WIDTH = 900
|
||||
HEIGHT = 600
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(self, *args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.title(App.APP_NAME)
|
||||
self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
|
||||
self.geometry(f"{App.WIDTH}x{App.HEIGHT}")
|
||||
self.minsize(App.WIDTH, App.HEIGHT)
|
||||
self.maxsize(App.WIDTH, App.HEIGHT)
|
||||
|
||||
@ -28,10 +28,11 @@ class App(customtkinter.CTk):
|
||||
self.bind("<Command-w>", self.on_closing)
|
||||
self.createcommand('tk::mac::Quit', self.on_closing)
|
||||
|
||||
self.image = Image.open(PATH + "/test_images/bg_gradient.jpg").resize((self.WIDTH, self.HEIGHT))
|
||||
self.photo = ImageTk.PhotoImage(self.image)
|
||||
# load image with PIL and convert to PhotoImage
|
||||
image = Image.open(PATH + "/test_images/bg_gradient.jpg").resize((self.WIDTH, self.HEIGHT))
|
||||
self.bg_image = ImageTk.PhotoImage(image)
|
||||
|
||||
self.image_label = tkinter.Label(master=self, image=self.photo)
|
||||
self.image_label = tkinter.Label(master=self, image=self.bg_image)
|
||||
self.image_label.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||
|
||||
self.frame = customtkinter.CTkFrame(master=self,
|
||||
@ -40,16 +41,24 @@ class App(customtkinter.CTk):
|
||||
corner_radius=0)
|
||||
self.frame.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||
|
||||
self.button_1 = customtkinter.CTkButton(master=self.frame, text="button 1",
|
||||
corner_radius=10, command=self.button_event, width=200)
|
||||
self.button_1.place(relx=0.5, rely=0.6, anchor=tkinter.CENTER)
|
||||
self.label_1 = customtkinter.CTkLabel(master=self.frame, corner_radius=10, width=200, height=60,
|
||||
fg_color=("gray70", "gray20"), text="CustomTkinter\ninterface example")
|
||||
self.label_1.place(relx=0.5, rely=0.3, anchor=tkinter.CENTER)
|
||||
|
||||
self.button_2 = customtkinter.CTkButton(master=self.frame, text="button 2",
|
||||
self.entry_1 = customtkinter.CTkEntry(master=self.frame, corner_radius=10, width=200)
|
||||
self.entry_1.place(relx=0.5, rely=0.52, anchor=tkinter.CENTER)
|
||||
self.entry_1.insert(0, "username")
|
||||
|
||||
self.entry_2 = customtkinter.CTkEntry(master=self.frame, corner_radius=10, width=200, show="*")
|
||||
self.entry_2.place(relx=0.5, rely=0.6, anchor=tkinter.CENTER)
|
||||
self.entry_2.insert(0, "password")
|
||||
|
||||
self.button_2 = customtkinter.CTkButton(master=self.frame, text="Login",
|
||||
corner_radius=10, command=self.button_event, width=200)
|
||||
self.button_2.place(relx=0.5, rely=0.7, anchor=tkinter.CENTER)
|
||||
|
||||
def button_event(self):
|
||||
print("Button pressed")
|
||||
print("Login pressed - username:", self.entry_1.get(), "password:", self.entry_2.get())
|
||||
|
||||
def on_closing(self, event=0):
|
||||
self.destroy()
|
||||
|
@ -1,8 +1,47 @@
|
||||
import tkinter as tk
|
||||
import customtkinter as ctk
|
||||
import time
|
||||
import tkinter
|
||||
import customtkinter # <- import the CustomTkinter module
|
||||
|
||||
root = tk.Tk()
|
||||
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")
|
||||
|
||||
btn = ctk.CTkButton(master=root, text="EXIT", command=root.destroy).pack()
|
||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||
|
||||
root.mainloop()
|
||||
|
||||
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()
|
||||
|
Reference in New Issue
Block a user