[pygtk] WNCK question

Magnus Therning magnus at therning.org
Tue May 23 01:04:29 WST 2006


On Thu, Apr 20, 2006 at 11:01:55AM +0100, Gustavo J. A. M. Carneiro wrote:
>On Qua, 2006-04-19 at 20:56 +0200, Danny Milosavljevic wrote:
>> Hi,
>> 
>> Am Dienstag, den 18.04.2006, 23:13 +0100 schrieb Magnus Therning:
>> > After discovering wmctrl and EWMH I decided to play around a little with
>> > wnck. Of course I'd like to do it in Python. However I'm having some
>> > problems to get started. I entered the following in ipython running in
>> > a gnome-terminal:
>> > 
>> >  In [1]: import wnck
>> > 
>> >  In [2]: scr = wnck.screen_get_default()
>> > 
>> >  In [3]: scr
>> >  Out[3]: <wnck.Screen object (WnckScreen) at 0xa7b08e3c>
>> > 
>> >  In [4]: scr.get_windows()
>> >  Out[4]: []
>> > 
>> >  In [5]: scr.get_active_window()
>> > 
>> >  In [6]: scr.get_windows_stacked()
>> >  Out[6]: []
>> > 
>> >  In [7]: scr.get_workspace_count()
>> >  Out[7]: 0
>> > 
>> > The results are a little surprising to me. I was expecting to find some
>> > windows on the current screen, and I have 8 workspaces. Am I missing
>> > something here?
>> > 
>> > I have only managed to find the reference docs for libwnck. The only
>> > program I know uses it is devilspie, but it's not exactly ideal for
>> > jumpstarting my plying with wnck...
>> > 
>> > /M
>> 
>> We, the Xfce Project, have an old fork of wnck (called netk now), and
>> there it didn't update the window list until some idle callback of it
>> had been called by the main loop (i.e. the main loop was already
>> running!)
>> 
>> I patched that by now, but I guess the original wnck still has the
>> problem :)

Hmm, that's a bit irritating. I was hoping to be able to call
gtk.main_iteration(0) to trigger that update to be done, but it doesn't
seem to work:

 >>> import wnck
 >>> scr = wnck.screen_get_default()
 >>> scr.get_windows()
 []
 >>> import gtk
 >>> for x in range(100): gtk.main_iteration(0)
 ...
 >>> scr.get_windows()
 []
 >>> gtk.main()
 Traceback (most recent call last):
   File "<stdin>", line 1, in ?
 KeyboardInterrupt
 >>> scr.get_windows()
 [<wnck.Window object (WnckWindow) at 0xa6e1ed4c>,
  <wnck.Window object (WnckWindow) at 0xa6e34144>,
  <wnck.Window object (WnckWindow) at 0xa6e3420c>,
  <wnck.Window object (WnckWindow) at 0xa6e342d4>,
  <wnck.Window object (WnckWindow) at 0xa6e34234>,
  <wnck.Window object (WnckWindow) at 0xa6e340a4>,
  <wnck.Window object (WnckWindow) at 0xa6e342fc>,
  <wnck.Window object (WnckWindow) at 0xa6e34324>,
  <wnck.Window object (WnckWindow) at 0xa6e34284>,
  <wnck.Window object (WnckWindow) at 0xa6e3434c>,
  <wnck.Window object (WnckWindow) at 0xa6e34374>,
  <wnck.Window object (WnckWindow) at 0xa6e3439c>,
  <wnck.Window object (WnckWindow) at 0xa6e343c4>,
  <wnck.Window object (WnckWindow) at 0xa6e343ec>,
  <wnck.Window object (WnckWindow) at 0xa6e34414>,
  <wnck.Window object (WnckWindow) at 0xa6e3443c>,
  <wnck.Window object (WnckWindow) at 0xa6e34464>]

I'm looking to writing a command line tool that does some window
manipulation, based on command line arguments, and then exits. Is there
a way around having to call gtk.main()?

/M

-- 
Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
magnus at therning.org             Jabber: magnus.therning at gmail.com
http://therning.org/magnus

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

Here's the social reason that DRM fails: keeping an honest user honest
is like keeping a tall user tall.
     -- Cory Doctorow, Microsoft Research DRM talk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20060522/b1655853/attachment.pgp


More information about the pygtk mailing list