fixed some configure bugs #585 #584 #583 #580 #579 #578, added check_image method

This commit is contained in:
Tom Schimansky
2022-11-06 14:40:15 +01:00
parent 62b330ddba
commit cea48c3501
16 changed files with 144 additions and 102 deletions

View File

@@ -1,13 +1,9 @@
import tkinter
import tkinter.messagebox
import customtkinter
from PIL import Image, ImageTk
from PIL import Image
import os
customtkinter.set_appearance_mode("Dark") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
PATH = os.path.dirname(os.path.realpath(__file__))
customtkinter.set_appearance_mode("dark")
class App(customtkinter.CTk):
@@ -28,10 +24,11 @@ class App(customtkinter.CTk):
self.protocol("WM_DELETE_WINDOW", self.on_closing)
# 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)
current_path = os.path.dirname(os.path.realpath(__file__))
self.bg_image = customtkinter.CTkImage(Image.open(current_path + "/test_images/bg_gradient.jpg"),
size=(self.WIDTH, self.HEIGHT))
self.image_label = tkinter.Label(master=self, image=self.bg_image)
self.image_label = customtkinter.CTkLabel(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,7 +37,7 @@ class App(customtkinter.CTk):
corner_radius=0)
self.frame.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
self.label_1 = customtkinter.CTkLabel(master=self.frame, width=200, height=60,
self.label_1 = customtkinter.CTkLabel(master=self.frame, width=200, height=60, corner_radius=6,
fg_color=("gray70", "gray25"), text="CustomTkinter\ninterface example")
self.label_1.place(relx=0.5, rely=0.3, anchor=tkinter.CENTER)