我使用了 Tkinter ,有几个 Toplevels,它们在 Ubuntu 任务栏中分开显示,而不是像打开多个 firefox 窗口那样在一起(我的意思是它们都在 firefox 图标下组合在一起,可以从中选择所需的它)。所有的 tkinter 窗口都单独出现在任务栏中,因此占用了栏中的大量空间。有没有办法将它们组合在一起,以便很容易看到当前打开了多少个窗口并清楚地看到它们是一个程序
最佳答案
tkinter 提供的唯一机制是 wm_group
方法,它向窗口管理器提供一个或多个窗口属于一个组的提示。窗口管理器可以自由使用或忽略这些提示。我不知道这是否会对 Ubuntu 和您正在使用的任何窗口管理器产生任何影响。
来自规范的 tcl/tk 文档:
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.
示例:
root = tk.Tk()
w1 = tk.Toplevel(root)
w2 = tk.Toplevel(root)
w1.group(root)
w2.group(root)
关于python - 使 Tkinter 多个窗口在任务栏中有一个图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50760753/