|
Re: stock item: msg#00075gnome.gtk+.python
Le mardi 14 décembre 2004 à 12:12 +0100, Marcus Habermehl a écrit : > Am Donnerstag, den 09.12.2004, 10:05 -0800 schrieb John Finlay: > > Marcus Habermehl wrote: > > > > >Hello. > > > > > >Short question: How can I register a new stock item? > > > > > >I found a description how I can register a new item in the > > >pygtk2reference. > > > > > ><from reference> > > >gtk.stock_add > > > def gtk.stock_add(items) > > >items : > > >a list or tuple containing 5-tuples > > >of stock items > > > > > >The gtk.stock_add() function registers each of the stock items in the > > >list or tuple specified by items. The stock items are specified by a 5- > > >tuple containing: > > > > > > * stock_id - a string identifier > > > * label - a string to use for a label > > > * modifier - a modifier mask (see the get_state() method for more > > > detail on modifiers) > > > * keyval - an integer key value (see gtk.gdk.Keymap) Together with > > > the modifiers specifies an accelerator. > > > * translation_domain - a string identifier of a translation domain > > > > > >If an item already exists with the same stock ID as one of the items, > > >the old item gets replaced. > > ></from reference> > > > > > >And this is my test. > > > > > >event1 = gtk.gdk.Event(gtk.gdk.KEY_PRESS) > > >gtk.stock_add(('gtk-current', '_Current', gtk.gdk.Event.get_state(event1), > > >99, 'gtk20')) > > > > > >or > > > > > >gtk.stock_add(('gtk-current', '_Current', gtk.gdk.Event.get_state > > >(gtk.gdk.CONTROL_MASK), 99, 'gtk20')) > > > > > >But nothing of this is working. > > > > > >I'am sure that the gtk.stock_add() function is correct. But I think that > > >I don't understand gtk.gdk.Event.get_state(). > > > > > >As you surely can see my English is bad. This is possibly the reason > > >wherefore I doesn't understanding gtk.gdk.Event.get_state(). > > > > > > > > > > > Your confusion is a result of confusing documentation. The third item in > > the 5-tuple should be composed from the Modifier Constants: > > http://www.pygtk.org/pygtk2reference/gdk-constants.html#gdk-modifier-constants > > to indicate which additional key(s) (if any) should be pressed in > > addtion to the keyval key e.g. 'Control' > > I doesn't understand it. Do you mean I must use anything like this? > > gtk.stock_add(('gtk-about', '_Credits', gtk.gdk.MOD1_MASK, 113, > 'gtk20')) > I had trouble to make it work, but now i use something like that : # quite empty class class _StockItem: def __init__(self, stock_id, label, modifier, keyval, translation_domain): self.stock_id = stock_id self.label = label self.modifier = modifier self.keyval = keyval self.translation_domain = translation_domain # instances PYMSERV_PLAY = "pymserv-play" play = _StockItem(PYMSERV_PLAY, _("_Play"), gtk.gdk.MOD1_MASK, gtk.gdk.keyval_from_name('P'), "pymserv") stock_items = [ play ] # add all stockitems to stock: for item in stock_items: gtk.stock_add( ((item.stock_id, item.label, item.modifier, item.keyval, item.translation_domain),) ) it's not that pretty, but it works > If yes, it doesn't work. > > regards > > 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/ > -- Nicolas ROMAN Ingénieur Intégration/Développement Aliacom http://www.aliacom.fr nicolas.roman@xxxxxxxxxx _______________________________________________ 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: stock item: 00075, Marcus Habermehl |
|---|---|
| Next by Date: | how do I do reassignable keybindings for menu items?: 00075, Thomas Mills Hinkle |
| Previous by Thread: | Re: stock itemi: 00075, Marcus Habermehl |
| Next by Thread: | Re: stock item: 00075, Marcus Habermehl |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |