Re-hello,
The wnck library seems to have many useful functions.
I made this based on your example.
import gtk, gobject, wnck
class SwitchDesktop(object):
def __init__(self):
self.screen = wnck.screen_get_default()
def switch(self, desktop_num):
self.screen = wnck.screen_get_default()
print "desktop_num=", desktop_num
print "get_workspace_count=", self.screen.get_workspace_count()
if desktop_num + 1 > self.screen.get_workspace_count():
desktop_num = 0
workspace = self.screen.get_workspace(desktop_num)
workspace.activate(gtk.get_current_event_time())
gtk.main_quit()
c = SwitchDesktop()
# switch to desktop number 1 (0 based)
gobject.idle_add(c.switch, 1)
gtk.main()
# --------------------
It works well.
Thank you.
Pietro Battiston wrote:
> I posted the following on another mailing list some time ago, it cycles
> though desktops. It's in Italian, but I think the mechanisms are clear
> enough:
>
> import gtk, gobject, wnck
>
> class Cambiatore(object):
> def __init__(self):
> self.schermo= wnck.screen_get_default()
>
> def cambia(self):
> try:
> self.attuale
> except:
> self.massimo = self.schermo.get_workspace_count()
> self.attuale =
> self.schermo.get_workspace_index(self.schermo.get_active_workspace())
>
> self.attuale = (self.attuale + 1) % self.massimo
> prossimo = self.schermo.get_workspaces()[self.attuale]
> prossimo.activate(0)
> return True
>
> c = Cambiatore()
> gobject.timeout_add_seconds(5, c.cambia)
> gtk.main()
>
> # bye
> # Pietro
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/