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

@ -0,0 +1,51 @@
import tkinter.ttk as ttk
import tkinter
app = tkinter.Tk()
app.geometry("400x350")
app.title("simple_example_standard_tkinter.py")
def button_function():
print("button pressed")
def slider_function(value):
progressbar_1["value"] = value
s = ttk.Style()
s.configure("TRadiobutton", fg="red")
y_padding = 6
frame_1 = tkinter.Frame(master=app, width=300, height=260, bg="lightgray")
frame_1.pack(padx=60, pady=20, fill="both", expand=True)
label_1 = tkinter.Label(master=frame_1, text="Label", bg="lightgray")
label_1.pack(pady=y_padding, padx=10)
progressbar_1 = ttk.Progressbar(master=frame_1, style='black.Horizontal.TProgressbar', length=150)
progressbar_1.pack(pady=y_padding, padx=10)
progressbar_1["value"] = 50
button_1 = tkinter.Button(master=frame_1, command=button_function, text="Button", highlightbackground="lightgray")
button_1.pack(pady=y_padding, padx=10)
slider_1 = tkinter.Scale(master=frame_1, command=slider_function, orient="horizontal", bg="lightgray", length=150)
slider_1.pack(pady=y_padding, padx=10)
entry_1 = tkinter.Entry(master=frame_1, highlightbackground="lightgray", width=10)
entry_1.pack(pady=y_padding, padx=10)
checkbox_1 = tkinter.Checkbutton(master=frame_1, bg=frame_1.cget("bg"), text="CheckButton")
checkbox_1.pack(pady=y_padding, padx=10)
radiobutton_var = tkinter.IntVar()
radiobutton_1 = ttk.Radiobutton(master=frame_1, variable=radiobutton_var, value=1, text="Radiobutton")
radiobutton_1.pack(pady=y_padding, padx=10)
radiobutton_2 = ttk.Radiobutton(master=frame_1, variable=radiobutton_var, value=2, text="Radiobutton")
radiobutton_2.pack(pady=y_padding, padx=10)
app.mainloop()

View File

@ -0,0 +1,43 @@
import customtkinter
from PIL import Image, ImageTk
import os
# load images
file_path = os.path.dirname(os.path.realpath(__file__))
image_1 = customtkinter.CTkImage(light_image=Image.open(file_path + "/test_images/add_folder_dark.png"),
dark_image=Image.open(file_path + "/test_images/add_folder_light.png"),
size=(30, 30))
image_1.configure(dark_image=Image.open(file_path + "/test_images/add_folder_light.png"))
image_2 = customtkinter.CTkImage(light_image=Image.open(file_path + "/test_images/bg_gradient.jpg"),
size=(30, 50))
app = customtkinter.CTk()
app.geometry("500x900")
mode_switch = customtkinter.CTkSwitch(app, text="darkmode",
command=lambda: customtkinter.set_appearance_mode("dark" if mode_switch.get() == 1 else "light"))
mode_switch.pack(padx=20, pady=20)
scaling_button = customtkinter.CTkSegmentedButton(app, values=[0.8, 0.9, 1.0, 1.1, 1.2, 1.5, 2.0],
command=lambda v: customtkinter.set_widget_scaling(v))
scaling_button.pack(padx=20, pady=20)
button_1 = customtkinter.CTkButton(app, image=image_1)
button_1.pack(padx=20, pady=20)
button_1 = customtkinter.CTkButton(app, image=image_1, anchor="nw", compound="right", height=50, corner_radius=4)
button_1.pack(padx=20, pady=20)
label_1 = customtkinter.CTkLabel(app, text="", image=image_2, compound="right", fg_color="green", width=0)
label_1.pack(padx=20, pady=20)
label_1.configure(image=image_1)
label_2 = customtkinter.CTkLabel(app, text="text", image=image_2, compound="right", fg_color="red", width=0, corner_radius=10)
label_2.pack(padx=20, pady=20)
label_3 = customtkinter.CTkLabel(app, image=ImageTk.PhotoImage(Image.open(file_path + "/test_images/bg_gradient.jpg").resize((300, 100))),
text="", compound="right", fg_color="green", width=0)
label_3.pack(padx=20, pady=20)
app.mainloop()

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB