|
Re: Re: gtk.Window() and accelerator: msg#00094gnome.gtk+.python
Am Donnerstag, den 16.12.2004, 21:02 +0300 schrieb Eugene Morozov: > Marcus Habermehl wrote: > > Am Donnerstag, den 16.12.2004, 08:26 +0300 schrieb Eugene Morozov: > > > >>Marcus Habermehl wrote: > >> > >>>Hi. > >>> > >>>I want to add an accelerator to my gtk.Window(). > >>> > >>>After I read the pygtk reference several hours I meant this is the right > >>>way. > >>> > >> > >>I use the following code: > >> > >> accelgroup = gtk.AccelGroup() > >> key, modifier = gtk.accelerator_parse('<Alt>%d' % i) > >> accelgroup.connect_group(key, modifier, gtk.ACCEL_VISIBLE, > >> lambda a,b,c,d,i=i: self.assess_quality(i)) > >> recall_card_window.add_accel_group(accelgroup) > >> > >>Don't know whether it's right or wrong, but it works. > > > > > > Thanks! I've modified your example a little bit. > > > > def Quit(*args): > > gtk.main_quit() > > > > accelgroup = gtk.AccelGroup() > > key, modifier = gtk.accelerator_parse('<Control>q') > > accesgroup.connect_group(key, modifier, gtk.ACCEL_VISIBLE, Quit) > > window1.add_accel_group(accelgroup) > > Please, remember that callbacks assigned in connect_group must return > True. Otherwise GTK+ will segfault sooner or later. It is probably > irrelevant to this example as it only calls gtk.main_quit(), but if you > want to do other things in callback it must return some value. Is the "i" the returning value in your example? Because there are some things in your example that I not understand. key, modifier = gtk.accelerator_parse('<Alt>%d' % i) Why %d instead d and what is % i? accelgroup.connect_group(key, modifier, gtk.ACCEL_VISIBLE, lambda a,b,c,d,i=i: self.assess_quality(i)) Are a,b,c,d,i widgets in your script? And why =i? I supposing self.assess_quality(i) is a function from you that returns the needed value for GTK+. I'm right? Marcus _______________________________________________ pygtk mailing list pygtk@xxxxxxxxxx http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: gtk.Window() and accelerator: 00094, Eugene Morozov |
|---|---|
| Next by Date: | TreeView backgound image: 00094, vector |
| Previous by Thread: | Re: gtk.Window() and acceleratori: 00094, Eugene Morozov |
| Next by Thread: | Re: gtk.Window() and accelerator: 00094, Eugene Morozov |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |