Making Tkinter Multiple Windows Have One Icon in the Task Bar

亡梦爱人 提交于 2019-12-10 18:19:33

问题


I used Tkinter , with several Toplevels, They appear separate in the Ubuntu Taskbar, instead of being together as with the case of say opening multiple firefox windows (i mean they all group under firefox icon together , the required can be selected from it). All the tkinter windows appear separately in task bar and therefore occupy a lot of space in the bar.Is there a way to group them together, so that it is easy to see how many windows are opened currently and look clearly that they are part of a program


回答1:


The only mechanism tkinter provides is the wm_group method, which provides hints to the window manager that one or more windows belong to a single group. The window manager is free to use or ignore those hints. I don't know if this will have any effect on Ubuntu and whatever window manager you're using.

From the canonical tcl/tk documentation:

wm group window ?pathName?

If pathName is specified, it gives the path name for the leader of a group of related windows. The window manager may use this information, for example, to unmap all of the windows in a group when the group's leader is iconified. PathName may be specified as an empty string to remove window from any group association. If pathName is specified then the command returns an empty string; otherwise it returns the path name of window's current group leader, or an empty string if window is not part of any group.

Example:

root = tk.Tk()
w1 = tk.Toplevel(root)
w2 = tk.Toplevel(root)
w1.group(root)
w2.group(root)


来源:https://stackoverflow.com/questions/50760753/making-tkinter-multiple-windows-have-one-icon-in-the-task-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!