2021-03-08 20:17:36 +03:00
|
|
|
import tkinter
|
|
|
|
import customtkinter # <- import the CustomTkinter module
|
2021-07-13 12:39:52 +03:00
|
|
|
from PIL import Image, ImageTk # <- import PIL for the images
|
2021-08-25 18:02:16 +03:00
|
|
|
import os
|
|
|
|
|
|
|
|
PATH = os.path.dirname(os.path.realpath(__file__))
|
2021-03-08 20:17:36 +03:00
|
|
|
|
2021-07-13 12:39:52 +03:00
|
|
|
customtkinter.enable_macos_darkmode()
|
|
|
|
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
2021-03-08 20:17:36 +03:00
|
|
|
|
|
|
|
root_tk = tkinter.Tk() # create the Tk window like you normally do
|
|
|
|
root_tk.geometry("400x240")
|
|
|
|
root_tk.title("CustomTkinter Test")
|
|
|
|
|
2021-03-14 17:45:02 +03:00
|
|
|
|
2021-03-08 20:17:36 +03:00
|
|
|
def button_function():
|
|
|
|
print("button pressed")
|
|
|
|
|
2021-03-14 17:45:02 +03:00
|
|
|
|
2021-03-08 20:17:36 +03:00
|
|
|
# load images as PhotoImage
|
2021-08-25 18:02:16 +03:00
|
|
|
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)))
|
2021-03-08 20:17:36 +03:00
|
|
|
|
|
|
|
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 with settings-image
|
|
|
|
button_1 = customtkinter.CTkButton(master=frame_1, image=settings_image, width=60, height=60,
|
|
|
|
corner_radius=10, command=button_function)
|
|
|
|
button_1.place(relx=0.33, rely=0.5, anchor=tkinter.CENTER)
|
|
|
|
|
|
|
|
# button with bell-image
|
|
|
|
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)
|
|
|
|
|
|
|
|
root_tk.mainloop()
|
|
|
|
customtkinter.disable_macos_darkmode()
|