mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
This commit is contained in:
parent
8c9183006c
commit
2db46afaf0
@ -52,7 +52,9 @@ class CTk(tkinter.Tk):
|
||||
super().title("CTk")
|
||||
self.geometry(f"{self.current_width}x{self.current_height}")
|
||||
|
||||
self.window_exists = False # indicates if the window is already shown through .update or .mainloop
|
||||
self.window_exists = False # indicates if the window is already shown through update() or mainloop()
|
||||
self.withdraw_called_before_window_exists = False # indicates if withdraw() was called before window is first shown through update() or mainloop()
|
||||
self.iconify_called_before_window_exists = False # indicates if iconify() was called before window is first shown through update() or mainloop()
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
if self.appearance_mode == 1:
|
||||
@ -104,16 +106,30 @@ class CTk(tkinter.Tk):
|
||||
self.disable_macos_dark_title_bar()
|
||||
super().destroy()
|
||||
|
||||
def withdraw(self):
|
||||
if self.window_exists is False:
|
||||
self.withdraw_called_before_window_exists = True
|
||||
super().withdraw()
|
||||
|
||||
def iconify(self):
|
||||
if self.window_exists is False:
|
||||
self.iconify_called_before_window_exists = True
|
||||
super().iconify()
|
||||
|
||||
def update(self):
|
||||
if self.window_exists is False:
|
||||
self.deiconify()
|
||||
self.window_exists = True
|
||||
|
||||
if not self.withdraw_called_before_window_exists and not self.iconify_called_before_window_exists:
|
||||
self.deiconify()
|
||||
super().update()
|
||||
|
||||
def mainloop(self, *args, **kwargs):
|
||||
if not self.window_exists:
|
||||
self.deiconify()
|
||||
self.window_exists = True
|
||||
|
||||
if not self.withdraw_called_before_window_exists and not self.iconify_called_before_window_exists:
|
||||
self.deiconify()
|
||||
super().mainloop(*args, **kwargs)
|
||||
|
||||
def resizable(self, *args, **kwargs):
|
||||
|
@ -47,7 +47,6 @@ class CTkToplevel(tkinter.Toplevel):
|
||||
AppearanceModeTracker.add(self.set_appearance_mode, self)
|
||||
super().configure(bg=ThemeManager.single_color(self.fg_color, self.appearance_mode))
|
||||
super().title("CTkToplevel")
|
||||
# self.geometry(f"{self._current_width}x{self._current_height}")
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
if self.appearance_mode == 1:
|
||||
|
@ -12,7 +12,7 @@ class App(customtkinter.CTk):
|
||||
super().__init__()
|
||||
|
||||
self.title("CustomTkinter complex_example.py")
|
||||
self.geometry(f"{920}x{500}-100-100")
|
||||
self.geometry(f"{920}x{500}")
|
||||
self.protocol("WM_DELETE_WINDOW", self.on_closing) # call .on_closing() when app gets closed
|
||||
|
||||
# configure grid layout (4x4)
|
||||
@ -73,6 +73,7 @@ class App(customtkinter.CTk):
|
||||
dynamic_resizing=False,
|
||||
values=["Value 1", "Value 2", "Value Long Long Long"])
|
||||
self.optionmenu_1.grid(row=0, column=0, padx=20, pady=(20, 10), sticky="ew")
|
||||
self.optionmenu_1.configure(dropdown_text_font=("Times New Roman", 20))
|
||||
self.combobox_1 = customtkinter.CTkComboBox(self.optionemnu_combobox_frame,
|
||||
values=["Value 1", "Value 2", "Value Long....."])
|
||||
self.combobox_1.grid(row=1, column=0, padx=20, pady=(10, 10), sticky="ew")
|
||||
|
@ -3,16 +3,20 @@ import customtkinter
|
||||
app = customtkinter.CTk()
|
||||
app.geometry("400x240")
|
||||
|
||||
app.withdraw()
|
||||
app.after(1000, app.deiconify)
|
||||
|
||||
|
||||
def button_function():
|
||||
|
||||
top = customtkinter.CTkToplevel(app)
|
||||
top.withdraw()
|
||||
|
||||
app.after(1000, top.iconify) # hide toplevel
|
||||
app.after(1500, top.deiconify) # show toplevel
|
||||
app.after(2500, app.iconify) # hide app
|
||||
app.after(3000, app.deiconify) # show app
|
||||
app.after(4000, app.destroy) # destroy everything
|
||||
app.after(1000, top.deiconify) # show toplevel
|
||||
app.after(2000, top.iconify) # hide toplevel
|
||||
app.after(2500, top.deiconify) # show toplevel
|
||||
app.after(3500, app.iconify) # hide app
|
||||
app.after(4000, app.deiconify) # show app
|
||||
app.after(5000, app.destroy) # destroy everything
|
||||
|
||||
|
||||
button = customtkinter.CTkButton(app, command=button_function)
|
||||
|
Loading…
Reference in New Issue
Block a user