CustomTkinter/examples/example_button_images.py

23 lines
766 B
Python
Raw Normal View History

import customtkinter
from PIL import Image, ImageTk
2022-01-22 22:28:59 +03:00
import os
PATH = os.path.dirname(os.path.realpath(__file__))
2022-03-13 03:26:18 +03:00
2022-11-01 02:37:30 +03:00
app = customtkinter.CTk()
2022-01-22 22:28:59 +03:00
2022-11-01 02:37:30 +03:00
switch_1 = customtkinter.CTkSwitch(app, text="darkmode", command=lambda: customtkinter.set_appearance_mode("dark" if switch_1.get() == 1 else "light"))
switch_1.pack(padx=20, pady=20)
2022-11-01 02:37:30 +03:00
image_1 = customtkinter.CTkImage(light_image=Image.open(PATH + "/test_images/add_folder_dark.png"),
dark_image=Image.open(PATH + "/test_images/add_folder_light.png"),
size=(30, 50))
image_1.configure(dark_image=Image.open(PATH + "/test_images/add_folder_light.png"))
2022-01-22 22:28:59 +03:00
2022-11-01 02:37:30 +03:00
button_1 = customtkinter.CTkButton(app, image=image_1)
button_1.pack(padx=20, pady=20)
2022-01-22 22:28:59 +03:00
2022-11-01 02:37:30 +03:00
app.mainloop()
2022-01-22 22:28:59 +03:00