我正在尝试开发一个python应用程序,它允许在gnome工作区之间移动窗口。我正在使用wnck与windows交互,但我想知道如何将窗口从一个工作区移动到另一个工作区。有人能给我一个建议吗?在
我试着用下面的代码
screen = wnck.screen_get_default()
window_list = screen.get_windows()
titlePattern = re.compile('.*Downloads.*')
if len(window_list) == 0:
print "No Windows Found"
for win in window_list:
if(titlePattern.match(win.get_name())):
win.move_to_workspace(screen.get_workspace(2))
但是screen.get_工作区(2) 返回'None',虽然它工作(但不移动窗口!)如果我使用screen.get_工作区(0)作为“移动到”工作区参数。在
我能解决我的问题吗?在
提前感谢大家。在
当您调用
screen.get_workspace(2)
时,窗口管理器根本没有工作区2。在您的代码应该适用于实际存在的所有工作区。在gnome3中,这意味着所有已经有windows的工作区加上一个空的工作区。这意味着
screen.get_workspace(screen.get_workspace_count() - 1)
应该给你一个“空”的工作区,如果你正在寻找的话。请注意,没有规范说明最后一个工作区是empy,这正是gnomeshell当前所做的。在您也可以要求窗口管理器增加屏幕上的工作区数量,但它没有义务这样做:gnome3窗口管理器不会这样做。在
哦,关于Wnck还有一件事要记住:
我不认为这是你的问题(因为你已经有一个窗口列表),但我只是再次检查,因为这是一个严重的陷阱。在
相关问题 更多 >
编程相关推荐