refined CTkRadioButton and complex_example.py, version 3.3

This commit is contained in:
Tom Schimansky
2022-03-05 13:05:39 +01:00
parent 6c976245aa
commit 0d32213325
10 changed files with 74 additions and 74 deletions

View File

@ -65,8 +65,7 @@ class TestApp(customtkinter.CTk):
self.frame_2 = customtkinter.CTkFrame(master=self.ctk_frame, width=200, height=60)
self.frame_2.place(relx=0.5, y=y + 80, anchor=tkinter.CENTER)
self.button_2 = customtkinter.CTkButton(master=self.ctk_frame, border_width=3, border_color=customtkinter.CTkThemeManager.MAIN_HOVER_COLOR,
)
self.button_2 = customtkinter.CTkButton(master=self.ctk_frame, border_width=3)
self.button_2.place(relx=0.5, y=y + 160, anchor=tkinter.CENTER)
self.entry_2 = customtkinter.CTkEntry(master=self.ctk_frame)

View File

@ -1,44 +1,23 @@
import tkinter
import customtkinter
import time
customtkinter.set_appearance_mode("light")
class ExampleApp(customtkinter.CTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.geometry("400x400")
self.title("main CTk window")
time.sleep(0.5)
self.resizable(False, False)
self.b1 = customtkinter.CTkButton(self, text="Add another window", command=self.newWindow)
self.b1.pack(side="top", padx=40, pady=40)
self.c1 = customtkinter.CTkCheckBox(self, text="dark mode", command=self.change_mode)
self.c1.pack()
self.count = 0
self.geometry("500x400")
def change_mode(self):
if self.c1.get() == 1:
customtkinter.set_appearance_mode("dark")
else:
customtkinter.set_appearance_mode("light")
def newWindow(self):
self.count += 1
self.button_1 = customtkinter.CTkButton(self, text="Create CTkToplevel", command=self.create_toplevel)
self.button_1.pack(side="top", padx=40, pady=40)
def create_toplevel(self):
window = customtkinter.CTkToplevel(self)
window.configure(bg=("lime", "darkgreen"))
window.title("CTkToplevel window")
window.geometry("400x200")
window.resizable(False, False)
label = customtkinter.CTkLabel(window, text=f"This is CTkToplevel window number {self.count}")
label = customtkinter.CTkLabel(window, text="CTkToplevel window")
label.pack(side="top", fill="both", expand=True, padx=40, pady=40)
if __name__ == "__main__":
root = ExampleApp()
time.sleep(0.5)
root.mainloop()
app = ExampleApp()
app.mainloop()