mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
fixed rendering bug in CTkSlider and modified complex examples
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import tkinter
|
||||
import tkinter.messagebox
|
||||
import customtkinter
|
||||
import sys
|
||||
|
||||
customtkinter.set_appearance_mode("System") # Other: "Light", "Dark"
|
||||
|
||||
@ -16,14 +17,21 @@ class App(tkinter.Tk):
|
||||
|
||||
tkinter.Tk.__init__(self, *args, **kwargs)
|
||||
|
||||
# color the background of the Tk window if mode is not System
|
||||
if customtkinter.get_appearance_mode() == "Dark":
|
||||
self.configure(bg="#323232") # set window background to dark color
|
||||
elif customtkinter.get_appearance_mode() == "Light":
|
||||
self.configure(bg="#ECECEC") # set window background to dark color
|
||||
|
||||
self.title(App.APP_NAME)
|
||||
self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
|
||||
self.minsize(App.WIDTH, App.HEIGHT)
|
||||
|
||||
self.protocol("WM_DELETE_WINDOW", self.on_closing)
|
||||
self.bind("<Command-q>", self.on_closing)
|
||||
self.bind("<Command-w>", self.on_closing)
|
||||
self.createcommand('tk::mac::Quit', self.on_closing)
|
||||
if sys.platform == "darwin":
|
||||
self.bind("<Command-q>", self.on_closing)
|
||||
self.bind("<Command-w>", self.on_closing)
|
||||
self.createcommand('tk::mac::Quit', self.on_closing)
|
||||
|
||||
# ============ create two CTkFrames ============
|
||||
|
||||
|
@ -22,18 +22,21 @@ class App(tkinter.Tk):
|
||||
|
||||
tkinter.Tk.__init__(self, *args, **kwargs)
|
||||
|
||||
if "win" in sys.platform:
|
||||
if customtkinter.get_appearance_mode() == "Dark":
|
||||
self.configure(bg="gray20") # set window background to dark color
|
||||
# color the background of the Tk window if mode is not System
|
||||
if customtkinter.get_appearance_mode() == "Dark":
|
||||
self.configure(bg="#323232") # set window background to dark color
|
||||
elif customtkinter.get_appearance_mode() == "Light":
|
||||
self.configure(bg="#ECECEC") # set window background to dark color
|
||||
|
||||
self.title(App.APP_NAME)
|
||||
self.geometry(str(App.WIDTH) + "x" + str(App.HEIGHT))
|
||||
self.minsize(App.WIDTH, App.HEIGHT)
|
||||
|
||||
self.protocol("WM_DELETE_WINDOW", self.on_closing)
|
||||
self.bind("<Command-q>", self.on_closing)
|
||||
self.bind("<Command-w>", self.on_closing)
|
||||
self.createcommand('tk::mac::Quit', self.on_closing)
|
||||
if sys.platform == "darwin":
|
||||
self.bind("<Command-q>", self.on_closing)
|
||||
self.bind("<Command-w>", self.on_closing)
|
||||
self.createcommand('tk::mac::Quit', self.on_closing)
|
||||
|
||||
# ============ create two CTkFrames ============
|
||||
|
||||
|
@ -2,12 +2,13 @@ import tkinter
|
||||
import customtkinter # <- import the CustomTkinter module
|
||||
|
||||
customtkinter.enable_macos_darkmode()
|
||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||
|
||||
root_tk = tkinter.Tk() # create the Tk window like you normally do
|
||||
root_tk.geometry("400x300")
|
||||
root_tk.title("CustomTkinter Test")
|
||||
|
||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
||||
|
||||
|
||||
def button_function():
|
||||
print("Button click")
|
||||
@ -34,53 +35,15 @@ button_1 = customtkinter.CTkButton(master=frame_1, corner_radius=10, command=but
|
||||
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)
|
||||
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)
|
||||
|
||||
color = {'main': '#FFFFFF',
|
||||
'accent': '#F0F0F0',
|
||||
'text': '#141414',
|
||||
|
||||
'red': '#FF3232',
|
||||
'red_': '#DC1414',
|
||||
'yellow': '#FFDC32',
|
||||
'yellow_': '#F0C800',
|
||||
|
||||
'green': '#50C850',
|
||||
'green_': '#32B432',
|
||||
'teal': '#50C8C8',
|
||||
'teal_': '#329696',
|
||||
|
||||
'blue': '#3296FF',
|
||||
'blue_': '#1478FF',
|
||||
'purple': '#9696FF',
|
||||
'purple_': '#1478FF',
|
||||
|
||||
'white': '#FFFFFF',
|
||||
'white_': '#F0F0F0',
|
||||
'black': '#141414',
|
||||
'black_': '#323232',
|
||||
}
|
||||
|
||||
red_slider = customtkinter.CTkSlider(
|
||||
from_=0, to=100,
|
||||
command=lambda event: event,
|
||||
progress_color=color['red'],
|
||||
fg_color=color['accent'],
|
||||
button_color=color['white_'],
|
||||
button_hover_color=color['white_'],
|
||||
master=frame_1,
|
||||
height=20,
|
||||
width=100)
|
||||
red_slider.place(relx=0.5, rely=0.9)
|
||||
red_slider.configure(fg_color=color['accent'], bg_color=None)
|
||||
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()
|
||||
customtkinter.disable_macos_darkmode()
|
||||
|
Reference in New Issue
Block a user