sorry for my bad English,
1. in tkinter I tried to hide Minimize,
maximize button, but I only found :
Top.resizable(0,0)
what command to disable them?
2. I tried to edit the close button with
Top.withdraw()
what command to do that?
3. how to check if a Toplevel() window exists?
window = Toplevel(None)
thank you for reading,
have a nice day
Please show code in context, as we cannot see how Top was defined.
Is 'Top' an instance of Tk() ?
ah sorry
from tkinter import *
root = Tk()
root.title("Main Window")
root.geometry("200x200")
def show():
Top.deiconify()
def hide():
Top.withdraw()
Top = Toplevel()
Top.title("Child Window")
Top.geometry("400x400")
Top.withdraw()
Button(root, text="Show", command=show).pack(pady=10)
Button(root, text="Hide", command=hide).pack(pady=10)
root.mainloop()
(Apr-26-2024, 10:11 AM)menator01 Wrote: [ -> ]This will remove the titlebar
import tkinter as tk
root = tk.Tk()
root.overrideredirect(True) # This removes the title bar.
root.mainloop()
More can be found here
https://blog.finxter.com/5-best-ways-to-...title-bar/
thank you for the reply and answer
i just know that thing called "title bar"
but i just want to hide or disable the minimize and maximize buttons, but keep the close button
anyway I just give you a reputation point
From the link I provided, I don't think you can directly edit the titlebar as it's managed by the systems window manager.
Probably best option is to use
root.resizable(False, False)
A way to detect an open window. Not elegant but works
import tkinter as tk
root = tk.Tk()
root.minsize(400,200)
def window():
top = tk.Toplevel(None)
top.geometry('+300+300')
if top.winfo_exists():
label.config(text='Window is open')
top.protocol('WM_DELETE_WINDOW', lambda: change(top))
def change(top):
label.config(text='Window is closed')
top.destroy()
label = tk.Label(root, text='Window is closed')
label.pack()
btn = tk.Button(root, text='Open Window', command=window)
btn.pack(pady=10)
root.mainloop()
(Apr-26-2024, 10:44 AM)menator01 Wrote: [ -> ]From the link I provided, I don't think you can directly edit the titlebar as it's managed by the systems window manager.
Probably best option is to use root.resizable(False, False)
A way to detect an open window. Not elegant but works
import tkinter as tk
root = tk.Tk()
root.minsize(400,200)
def window():
top = tk.Toplevel(None)
top.geometry('+300+300')
if top.winfo_exists():
label.config(text='Window is open')
top.protocol('WM_DELETE_WINDOW', lambda: change(top))
def change(top):
label.config(text='Window is closed')
top.destroy()
label = tk.Label(root, text='Window is closed')
label.pack()
btn = tk.Button(root, text='Open Window', command=window)
btn.pack(pady=10)
root.mainloop()
i tried to answer question number 3:
if top.winfo_exists():
top.destroy()
Error:
NameError: name 'top' is not defined
anyway, thank you for reply
Ok i found out all
1.
Top.attributes('-toolwindow', True)
2.
def wd():
Top.withdraw()
Top.protocol("WM_DELETE_WINDOW", wd)
3.
try:
top.winfo_exists()
except:
print("Top Do not exist")