Reputation: 79
i am making tkinter window and another one as top level but i want when the top level window is displayed only one icon in the task bar which is main window icon not the top level one
I already used overrideredirect(1), it works but it also hid top level border including title bar
w = tk.Tk()
w.title('main')
w.geometry('300x300')
def c():
t = tk.Toplevel()
t.title('toplevel')
t.geometry('100x100')
# t.overrideredirect(1)
t.mainloop()
b = tk.Button(w,text='click',command=c)
b.pack()
w.mainloop()
Upvotes: 2
Views: 1383
Reputation: 16169
The method .transient()
does exactly what you want, it will remove the toplevel icon from the taskbar:
import tkinter as tk
w = tk.Tk()
w.title('main')
w.geometry('300x300')
def c():
t = tk.Toplevel()
t.title('toplevel')
t.geometry('100x100')
t.transient(w)
b = tk.Button(w, text='click', command=c)
b.pack()
w.mainloop()
By the way, you only need to call mainloop()
once, calling it again in the function c
is useless.
Upvotes: 1