问题标签 [wnck]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1225 浏览

python - 使用 KDE 检测 python 中的活动窗口

我正在编写一个小的 python 脚本来跟踪我如何在程序之间分配时间。它需要检测当前活动的窗口(理想情况下,控制该窗口的应用程序,但我可以只使用窗口标题)以及空闲时间。

目前,我正在使用KIdleTime来确定我有多久没有碰过我的电脑,这本身就可以正常工作。

我还尝试使用wnck来确定哪些窗口处于活动状态,而且这本身就可以正常工作。

当我尝试将两者结合到一个程序中时,我遇到了麻烦。由于 wnck 是一个 gnome 库,而 KIdleTime 是一个 KDE 库,它们需要在自己的线程上运行才能触发窗口更改和空闲超时信号。

我很难在 python 中找到一种方法 - 如果我使用线程模块尝试在单独的线程上运行其中一个,KDE 库会抱怨它不在主线程上,或者 Gnome 库有一个令人印象深刻的崩溃并吃掉了它可以获得的所有内存(顺便说一下,ulimit 在这种情况下非常有用,我可以推荐它)。

所以,我有四个选择:

  1. 找到一个可以检测窗口何时更改的 KDE 库——我原以为 dbus 会在 kwin 中公开它,但似乎没有。
  2. 找到一种同时运行 kde 和 gnome 库的方法。
  3. 查找在 Gnome 事件线程上运行的等效 KIdleTime。
  4. 使用计时器从 Gnome 线程中轮询 KIdleTime(这是我现在正在做的,但远非理想,它会导致确定空闲时间时不精确)。

谁能给我一个解决方案?

0 投票
2 回答
778 浏览

python - python wnck 在 pdb.set_trace() 之后才返回任何数据

在 Ubuntu Linux / Gnome 上,我正在尝试使用 python 的 wnck 绑定来获取所有打开的窗口的列表。

我的代码如下所示:

输出是这样的:

第一次get_windows()调用返回[]一个空列表。第二个get_windows()调用返回打开的窗口列表。在 中pdb,我只按c继续,什么也不做(在 pdb 中)。

如果我注释掉pdb,这两个get_windows()调用都会返回[]。如果我get_windows()在 pdb 之前多次重复调用,则什么都没有。如果我get_windows()在 pdb 之后多次重复调用,我会不断得到一个完整的列表。

为什么这个调用只在一个空的 pdb 之后才起作用?如何在没有 pdb 的情况下使其工作?

0 投票
2 回答
3220 浏览

python - 如何使用 PyGI 获取带有 Wnck 的窗口列表?

我刚开始使用 PyGI(在 Ubuntu Natty 上),虽然我以前从未使用过 pygtk。不过,我在 wxPython 程序中使用了 wnck,并且很容易获得当前打开的窗口的列表。在 PyGI 中,窗口列表始终为空。相关代码位:

有了这个,wins == []。谢谢!

0 投票
1 回答
287 浏览

window - Why wxframe isn't raised from a function called with global gtk binder?

Ok, why this simple app dosn't work. I've spent one day investigating this and got nothing.

I don't know why, but sometimes (especially when I raise apps by clicking on them on panel) raising dosen't work and I got flash icon instead of raised window.

UPDATE

Ok, i return to the topic and notice these..

  1. above example works for me.. strange
  2. i isolated strange behaviour which below code shows.. it's something related with wnck lib. So if my app window is deactivated by open new window (left click on window - test1) then raise works perfect, but if other window (replace 'opera' with any of Yours) is activated with wnck(by right click - test2) then actvation fails

    import logging import subprocess import time import wnck import wx

    logging.basicConfig(level=logging.DEBUG)

    class MyFrame(wx.Frame):

    if name == 'main': app = wx.PySimpleApp(redirect=False) frame = MyFrame(None) frame.Show() app.MainLoop()

Does anybody understand this behaviour instead of very helpful wtf like i feel? :)

0 投票
1 回答
420 浏览

python - 如何在 Xorg 中获取窗口的图标名称?

我正在尝试使用 python 获取窗口的图标名称,以便在基于 pyclutter 的任务栏中使用。我已经通过 wnck 获得了 XID,但 wnck 似乎只能给我一个 gtk.gdk.Pixbuf,这对混乱没有用处。我确信有一些方法可以使用 python-xlib 或 python-xcb 来做到这一点,我只是找不到它:-)

有任何想法吗?

0 投票
1 回答
882 浏览

python - 带有忽略所有 X(鼠标)事件(通过它们)的框的 pygtk 窗口

我想做以下事情:创建一个全屏,始终位于顶部的 pygtk 窗口,其中带有显示一些 html 的 webkit 小部件,但带有一个完全透明的框,以便下面的窗口可见。(这似乎是可能的:Is it possible to render web content over a clear background using WebKit?

我想要(有时)将透明框中发生的所有鼠标事件传递到我的应用程序窗口下方的窗口,以便我可以正常与它们交互。所以不仅视觉上透明,而且对鼠标事件也是透明的。

从理论上讲,我想我可以使用 pygtk Eventbox 捕获我感兴趣的所有事件,使用 wnck 找到我的正下方的窗口,然后使用 python-xlib 将此事件传递给它。

这似乎不是最优雅的解决方案。有没有更好的办法?

0 投票
1 回答
800 浏览

python - 在使用 python-wnck 生成和移动之后,窗口位置有点偏离

我制作了这个 Python 脚本:

它的作用是让 roxterm 表现得像 Guake。我遇到的唯一问题是当我打开一个新的 roxterm 实例并将窗口移动到 (0,0) 之后,窗口的最终 y 位置向下几个可见像素。我使用 wnck 库中的 set_geometry 函数来执行此操作。关于如何解决它的任何想法?谢谢。

0 投票
1 回答
422 浏览

python - python wnck.window_get() 从 conlose 工作,但不能从模块工作

如果我在刚刚打开的 python 控制台中键入下面的代码,但如果我从文件中运行它则不行(此文件中没有其他代码)

0 投票
2 回答
4288 浏览

python - python-wnck set focus to window

I'm trying to set focus to a window using python-wnck.
The only docs I could find related to this library are from https://developer.gnome.org/libwnck/stable/WnckWindow.html

Using some code I found on another question here at SO, I was able to search for windows using the window title, but I'm not sure how to get a window to focus.
From the above docs I found the function:


So in python I tried using this function like "window.activate(0)", but this appears to fail, the icon on my taskbar flashed but it doesn't get focus.
In the terminal I get the message:

So I think I may actually need to put in a valid timestamp but not sure how to get this.

This is the code Im using sofar:

0 投票
1 回答
230 浏览

python - python-wnck如何获取监控属性

python-wnck具有 Screen 对象,该对象组合了多个监视器的区域并将其提供给get_screen_size(). 如何获得单个显示器的大小。我正在尝试将窗口从一台显示器移动到另一台显示器