python - 使 Tkinter 多个窗口在任务栏中有一个图标

标签 python tkinter taskbar tkinter-layout

我使用了 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/

相关文章:

python - tkinter:打开一个带有按钮提示的新窗口

安卓 : Floating Clickable Icon over Screen?

python - 实现python RTMP服务器,发送媒体数据后flash播放器重置连接,如何排除故障

python - tkinter 中的 GIF 故障

python - 迭代 VM 列表时出现 Azure 异步 Python SDK 错误

python - 如何让文本框水平滚动插入的小部件?

c++ - 更改Windows 7/8跳转列表上MFC应用程序的应用程序标题

c# - 如何使用 C# 控制 Windows 中的任务栏

python - 检查字符串是否仅包含正则表达式中的字符

python - : "file.readlines()", "list(file)"和 "file.read().splitlines(True)"之间有区别吗?