[pygtk] Close button demonstrating app, and questions

Khiraly khiraly123 at gmx.net
Sun Apr 30 17:25:12 WST 2006


2006. 04. 30, vasárnap keltezéssel 03.09-kor Dieter Verfaillie ezt írta:
> (line 55 in the code,
> > which is actualy not working)
> 
> now they do. see attachment
Thanks! It works really great. Simple and clear solution.


> > Other things to do:
> > Get the following keybindings working:
> > Ctrl-W close the focused tab
> > Ctrl-PageUP Next tab 
> > Ctrl-PageDown Previous tab
> > Ctrl-T New tab

I have trouble with the shortcuts. I cant assign global keybindigs like
Ctrl-Q, because all the example what I find on the net, the sourcecode
is like this:

self.back = gtk.ImageMenuItem(gtk.STOCK_GO_BACK)
self.back.connect("activate",self.back_clicked)
self.back.add_accelerator("activate", self.accel_group,
     gtk.gdk.keyval_from_name("Left"),
     gtk.gdk.MOD1_MASK, gtk.ACCEL_VISIBLE)

In the above example, there is an exactly definied click on menuitem,
which is easily replacable with an accelerator.

But the following case is difficult:

(global Ctrl-Q signal for closeing the toplevel window)

self.accel_group = gtk.AccelGroup()
window.add_accel_group(self.accel_group)
window.add_accelerator("delete_event",

self.accel_group,ord('q'),gtk.gdk.CONTROL_MASK,gtk.ACCEL_LOCKED)

the error message:
pygtk-verfaillie.py:85: GtkWarning: gtkwidget.c:3260: widget `GtkWindow'
has no
activatable signal "delete_event" without arguments
window.add_accelerator("delete_event",self.accel_group,ord('q'),gtk.gdk.CONTROL_MASK,gtk.ACCEL_LOCKED)

The Ctrl-w signal:
notebook.add_accelerator('clicked',self.accel_group,ord('w'),gtk.gdk.CONTROL_MASK,gtk.ACCEL_LOCKED)

the error message:
pygtk-verfaillie.py:100: GtkWarning: gtkwidget.c:3260: widget
`GtkNotebook' has no
 activatable signal "clicked" without arguments
notebook.add_accelerator('clicked',self.accel_group,ord('w'),gtk.gdk.CONTROL_MASK,gtk.ACCEL_LOCKED)

The goal is, if the Ctrl-W signal emmitted, the
self.remove_actual_page() function should be called.

Here is an update-ed source code:
http://pastebin.com/689970

Khiraly



More information about the pygtk mailing list