mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
added compound to CTkButton, restructured some code in CTkButton for better readability
This commit is contained in:
@@ -117,20 +117,20 @@ class App(tkinter.Tk):
|
||||
self.slider_1 = customtkinter.CTkSlider(master=self.frame_right,
|
||||
button_color=App.MAIN_COLOR,
|
||||
button_hover_color=App.MAIN_HOVER,
|
||||
width=160,
|
||||
height=16,
|
||||
border_width=5.5,
|
||||
command=self.progressbar.set)
|
||||
width=160,
|
||||
height=16,
|
||||
border_width=5.5,
|
||||
command=self.progressbar.set)
|
||||
self.slider_1.place(x=20, rely=0.6, anchor=tkinter.W)
|
||||
self.slider_1.set(0.3)
|
||||
|
||||
self.slider_2 = customtkinter.CTkSlider(master=self.frame_right,
|
||||
button_color=App.MAIN_COLOR,
|
||||
button_hover_color=App.MAIN_HOVER,
|
||||
width=160,
|
||||
height=16,
|
||||
border_width=5.5,
|
||||
command=self.progressbar.set)
|
||||
width=160,
|
||||
height=16,
|
||||
border_width=5.5,
|
||||
command=self.progressbar.set)
|
||||
self.slider_2.place(x=20, rely=0.7, anchor=tkinter.W)
|
||||
self.slider_2.set(0.7)
|
||||
|
||||
|
@@ -9,7 +9,7 @@ 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("400x240")
|
||||
root_tk.geometry("400x400")
|
||||
root_tk.title("CustomTkinter Test")
|
||||
|
||||
|
||||
@@ -21,18 +21,28 @@ def button_function():
|
||||
settings_image = ImageTk.PhotoImage(Image.open(PATH + "/test_images/settings.png").resize((40, 40)))
|
||||
bell_image = ImageTk.PhotoImage(Image.open(PATH + "/test_images/bell.png").resize((40, 40)))
|
||||
|
||||
frame_1 = customtkinter.CTkFrame(master=root_tk, width=300, height=200, corner_radius=15)
|
||||
frame_1 = customtkinter.CTkFrame(master=root_tk, width=300, height=350, corner_radius=15)
|
||||
frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||
|
||||
# button with settings-image
|
||||
button_1 = customtkinter.CTkButton(master=frame_1, image=settings_image, width=60, height=60,
|
||||
# button with settings-image and no text
|
||||
button_1 = customtkinter.CTkButton(master=frame_1, image=settings_image, text="", width=60, height=60,
|
||||
corner_radius=10, command=button_function)
|
||||
button_1.place(relx=0.33, rely=0.5, anchor=tkinter.CENTER)
|
||||
button_1.place(relx=0.1, rely=0.2, anchor=tkinter.W)
|
||||
|
||||
# button with bell-image
|
||||
# button with bell-image and standard compound ("left")
|
||||
button_2 = customtkinter.CTkButton(master=frame_1, image=bell_image, width=60, height=60,
|
||||
corner_radius=10, command=button_function)
|
||||
button_2.place(relx=0.66, rely=0.5, anchor=tkinter.CENTER)
|
||||
button_2.place(relx=0.9, rely=0.2, anchor=tkinter.E)
|
||||
|
||||
# button with bell-image and compound="bottom"
|
||||
button_4 = customtkinter.CTkButton(master=frame_1, image=bell_image, text="bell_image", compound="bottom",
|
||||
command=button_function, height=100)
|
||||
button_4.place(relx=0.5, rely=0.55, relwidth=0.5, anchor=tkinter.CENTER)
|
||||
|
||||
# button with settings-image and compound="right"
|
||||
button_4 = customtkinter.CTkButton(master=frame_1, image=settings_image, text="bell_image", compound="right",
|
||||
command=button_function, height=60)
|
||||
button_4.place(relx=0.5, rely=0.85, relwidth=0.5, anchor=tkinter.CENTER)
|
||||
|
||||
root_tk.mainloop()
|
||||
customtkinter.disable_macos_darkmode()
|
||||
|
Reference in New Issue
Block a user