remove old complex example

This commit is contained in:
Tom Schimansky 2022-10-22 15:14:23 +02:00
parent 7ea2edeef2
commit fc3a41d074
4 changed files with 12 additions and 204 deletions

View File

@ -64,8 +64,8 @@ from .widgets.ctk_optionmenu import CTkOptionMenu
from .widgets.ctk_combobox import CTkComboBox
from .widgets.ctk_scrollbar import CTkScrollbar
from .widgets.ctk_textbox import CTkTextbox
from .widgets.ctk_tabview import CTkTabview as _CTkTabview
from .widgets.ctk_segmented_button import CTkSegmentedButton as _CTkSegmentedButton
from .widgets.ctk_tabview import CTkTabview
from .widgets.ctk_segmented_button import CTkSegmentedButton
# import windows
from .windows.ctk_tk import CTk
@ -73,7 +73,7 @@ from .windows.ctk_toplevel import CTkToplevel
from .windows.ctk_input_dialog import CTkInputDialog
# util classes
from .utility.ctk_font import CTkFont as _CTkFont
from .utility.ctk_font import CTkFont
def set_appearance_mode(mode_string: str):

View File

@ -1,192 +0,0 @@
import tkinter
import tkinter.messagebox
import customtkinter
customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
class App(customtkinter.CTk):
WIDTH = 780
HEIGHT = 520
def __init__(self):
super().__init__()
self.title("CustomTkinter complex_example.py")
self.geometry(f"{App.WIDTH}x{App.HEIGHT}")
self.protocol("WM_DELETE_WINDOW", self.on_closing) # call .on_closing() when app gets closed
# ============ create two frames ============
# configure grid layout (2x1)
self.grid_columnconfigure(1, weight=1)
self.grid_rowconfigure(0, weight=1)
self.frame_left = customtkinter.CTkFrame(master=self,
width=180,
corner_radius=0)
self.frame_left.grid(row=0, column=0, sticky="nswe")
self.frame_right = customtkinter.CTkFrame(master=self)
self.frame_right.grid(row=0, column=1, sticky="nswe", padx=20, pady=20)
# ============ frame_left ============
# configure grid layout (1x11)
self.frame_left.grid_rowconfigure(0, minsize=10) # empty row with minsize as spacing
self.frame_left.grid_rowconfigure(5, weight=1) # empty row as spacing
self.frame_left.grid_rowconfigure(8, minsize=20) # empty row with minsize as spacing
self.frame_left.grid_rowconfigure(11, minsize=10) # empty row with minsize as spacing
self.label_1 = customtkinter.CTkLabel(master=self.frame_left,
text="CustomTkinter",
font=("Roboto Medium", -16)) # font name and size in px
self.label_1.grid(row=1, column=0, pady=10, padx=10)
self.button_1 = customtkinter.CTkButton(master=self.frame_left,
text="CTkButton",
command=self.button_event)
self.button_1.grid(row=2, column=0, pady=10, padx=20)
self.button_2 = customtkinter.CTkButton(master=self.frame_left,
text="CTkButton",
command=self.button_event)
self.button_2.grid(row=3, column=0, pady=10, padx=20)
self.button_3 = customtkinter.CTkButton(master=self.frame_left,
text="CTkButton",
command=self.button_event)
self.button_3.grid(row=4, column=0, pady=10, padx=20)
self.label_mode = customtkinter.CTkLabel(master=self.frame_left, text="Appearance Mode:")
self.label_mode.grid(row=9, column=0, pady=0, padx=20, sticky="w")
self.optionmenu_1 = customtkinter.CTkOptionMenu(master=self.frame_left,
values=["Light", "Dark", "System"],
command=self.change_appearance_mode)
self.optionmenu_1.grid(row=10, column=0, pady=10, padx=20, sticky="w")
# ============ frame_right ============
# configure grid layout (3x7)
self.frame_right.rowconfigure((0, 1, 2, 3), weight=1)
self.frame_right.rowconfigure(7, weight=10)
self.frame_right.columnconfigure((0, 1), weight=1)
self.frame_right.columnconfigure(2, weight=0)
self.frame_info = customtkinter.CTkFrame(master=self.frame_right)
self.frame_info.grid(row=0, column=0, columnspan=2, rowspan=4, pady=20, padx=20, sticky="nsew")
# ============ frame_info ============
# configure grid layout (1x1)
self.frame_info.rowconfigure(0, weight=1)
self.frame_info.columnconfigure(0, weight=1)
self.label_info_1 = customtkinter.CTkLabel(master=self.frame_info,
text="CTkLabel: Lorem ipsum dolor sit,\n" +
"amet consetetur sadipscing elitr,\n" +
"sed diam nonumy eirmod tempor" ,
height=100,
corner_radius=6, # <- custom corner radius
fg_color=("white", "gray38"), # <- custom tuple-color
justify=tkinter.LEFT)
self.label_info_1.grid(column=0, row=0, sticky="nwe", padx=15, pady=15)
self.progressbar = customtkinter.CTkProgressBar(master=self.frame_info)
self.progressbar.grid(row=1, column=0, sticky="ew", padx=15, pady=15)
# ============ frame_right ============
self.radio_var = tkinter.IntVar(value=0)
self.label_radio_group = customtkinter.CTkLabel(master=self.frame_right,
text="CTkRadioButton Group:")
self.label_radio_group.grid(row=0, column=2, columnspan=1, pady=20, padx=10, sticky="")
self.radio_button_1 = customtkinter.CTkRadioButton(master=self.frame_right,
variable=self.radio_var,
value=0)
self.radio_button_1.grid(row=1, column=2, pady=10, padx=20, sticky="n")
self.radio_button_2 = customtkinter.CTkRadioButton(master=self.frame_right,
variable=self.radio_var,
value=1)
self.radio_button_2.grid(row=2, column=2, pady=10, padx=20, sticky="n")
self.radio_button_3 = customtkinter.CTkRadioButton(master=self.frame_right,
variable=self.radio_var,
value=2)
self.radio_button_3.grid(row=3, column=2, pady=10, padx=20, sticky="n")
self.slider_1 = customtkinter.CTkSlider(master=self.frame_right,
from_=0,
to=1,
number_of_steps=3,
command=self.progressbar.set)
self.slider_1.grid(row=4, column=0, columnspan=2, pady=10, padx=20, sticky="we")
self.slider_2 = customtkinter.CTkSlider(master=self.frame_right,
command=self.progressbar.set)
self.slider_2.grid(row=5, column=0, columnspan=2, pady=10, padx=20, sticky="we")
self.switch_1 = customtkinter.CTkSwitch(master=self.frame_right,
text="CTkSwitch")
self.switch_1.grid(row=4, column=2, columnspan=1, pady=10, padx=20, sticky="we")
self.switch_2 = customtkinter.CTkSwitch(master=self.frame_right,
text="CTkSwitch")
self.switch_2.grid(row=5, column=2, columnspan=1, pady=10, padx=20, sticky="we")
self.combobox_1 = customtkinter.CTkComboBox(master=self.frame_right,
values=["Value 1", "Value 2"])
self.combobox_1.grid(row=6, column=2, columnspan=1, pady=10, padx=20, sticky="we")
self.check_box_1 = customtkinter.CTkCheckBox(master=self.frame_right,
text="CTkCheckBox")
self.check_box_1.grid(row=6, column=0, pady=10, padx=20, sticky="w")
self.check_box_2 = customtkinter.CTkCheckBox(master=self.frame_right,
text="CTkCheckBox")
self.check_box_2.grid(row=6, column=1, pady=10, padx=20, sticky="w")
self.entry = customtkinter.CTkEntry(master=self.frame_right,
width=120,
placeholder_text="CTkEntry")
self.entry.grid(row=8, column=0, columnspan=2, pady=20, padx=20, sticky="we")
self.button_5 = customtkinter.CTkButton(master=self.frame_right,
text="CTkButton",
border_width=2, # <- custom border_width
fg_color=None, # <- no fg_color
command=self.button_event)
self.button_5.grid(row=8, column=2, columnspan=1, pady=20, padx=20, sticky="we")
# set default values
self.optionmenu_1.set("Dark")
self.button_3.configure(state="disabled", text="Disabled CTkButton")
self.combobox_1.set("CTkCombobox")
self.radio_button_1.select()
self.slider_1.set(0.2)
self.slider_2.set(0.7)
self.progressbar.set(0.5)
self.switch_2.select()
self.radio_button_3.configure(state=tkinter.DISABLED)
self.check_box_1.configure(state=tkinter.DISABLED, text="CheckBox disabled")
self.check_box_2.select()
def button_event(self):
print("Button pressed")
def change_appearance_mode(self, new_appearance_mode):
customtkinter.set_appearance_mode(new_appearance_mode)
def on_closing(self, event=0):
self.destroy()
if __name__ == "__main__":
app = App()
app.mainloop()

View File

@ -87,7 +87,7 @@ class App(customtkinter.CTk):
self.slider_progressbar_frame.grid_columnconfigure(0, weight=1)
self.slider_progressbar_frame.grid_rowconfigure(4, weight=1)
self.seg_button_1 = customtkinter._CTkSegmentedButton(self.slider_progressbar_frame)
self.seg_button_1 = customtkinter.CTkSegmentedButton(self.slider_progressbar_frame)
self.seg_button_1.grid(row=0, column=0, padx=(20, 10), pady=(10, 10), sticky="ew")
self.progressbar_1 = customtkinter.CTkProgressBar(self.slider_progressbar_frame)
@ -102,7 +102,7 @@ class App(customtkinter.CTk):
self.progressbar_3.grid(row=0, column=2, rowspan=5, padx=(10, 20), pady=(10, 10), sticky="ns")
# create tabview
self.tabview = customtkinter._CTkTabview(self)
self.tabview = customtkinter.CTkTabview(self)
self.tabview.grid(row=1, column=3, columnspan=2, padx=(10, 20), pady=(10, 10), sticky="nsew")
self.tabview.add("CTkTabview")
self.tabview.add("Tab 2")

View File

@ -15,7 +15,7 @@ def set_scaling(scaling):
customtkinter.set_widget_scaling(scaling)
customtkinter.set_spacing_scaling(scaling)
scaling_button = customtkinter._CTkSegmentedButton(frame_1, values=[0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.5, 2.0], command=set_scaling)
scaling_button = customtkinter.CTkSegmentedButton(frame_1, values=[0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.5, 2.0], command=set_scaling)
scaling_button.pack(pady=(2, 10))
b = customtkinter.CTkButton(frame_1, text="single name", font=("Times", ))
@ -29,14 +29,14 @@ b.pack(pady=2)
b = customtkinter.CTkButton(frame_1, text="object default")
b.pack(pady=(10, 2))
b = customtkinter.CTkButton(frame_1, text="object single name", font=customtkinter._CTkFont("Times"))
b = customtkinter.CTkButton(frame_1, text="object single name", font=customtkinter.CTkFont("Times"))
b.pack(pady=2)
b = customtkinter.CTkButton(frame_1, text="object with name and size", font=customtkinter._CTkFont("Times", 18))
b = customtkinter.CTkButton(frame_1, text="object with name and size", font=customtkinter.CTkFont("Times", 18))
b.pack(pady=2)
b = customtkinter.CTkButton(frame_1, text="object with name and negative size", font=customtkinter._CTkFont("Times", -18))
b = customtkinter.CTkButton(frame_1, text="object with name and negative size", font=customtkinter.CTkFont("Times", -18))
b.pack(pady=2)
b = customtkinter.CTkButton(frame_1, text="object with extra keywords",
font=customtkinter._CTkFont("Times", -18, weight="bold", slant="italic", underline=True, overstrike=True))
font=customtkinter.CTkFont("Times", -18, weight="bold", slant="italic", underline=True, overstrike=True))
b.pack(pady=2)
b1 = customtkinter.CTkButton(frame_1, text="object default modified")
@ -46,9 +46,9 @@ print("test_font.py:", b1.cget("font").cget("size"), b1.cget("font").cget("famil
b2 = customtkinter.CTkButton(frame_1, text="object default overridden")
b2.pack(pady=10)
b2.configure(font=customtkinter._CTkFont(family="Times"))
b2.configure(font=customtkinter.CTkFont(family="Times"))
label_font = customtkinter._CTkFont(size=5)
label_font = customtkinter.CTkFont(size=5)
for i in range(30):
l = customtkinter.CTkLabel(frame_2, font=label_font, height=0)
l.grid(row=i, column=0, pady=1)