问题
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