[pygtk] accelerator for an image button.
Gian Mario Tagliaretti
gianmt at gnome.org
Sat Nov 3 18:51:43 WST 2007
2007/11/3, Neil Dugan <pygtk a butterflystitches.com.au>:
Hi Neil,
> I am trying to make an python/gtk+ app. One problem I am having is
> attaching an accelerator to a image button.
>
> This is the code I am using to create the buttons.
>
> --- cut ---
> def index_control(self):
> hbox = gtk.HBox()
> for stock in
> [gtk.STOCK_GOTO_FIRST,gtk.STOCK_GO_BACK,gtk.STOCK_GO_FORWARD,gtk.STOCK_GOTO_LAST] :
> image = gtk.Image()
> image.set_from_stock(stock,gtk.ICON_SIZE_MENU)
> button = gtk.Button()
> button.set_image(image)
> hbox.pack_start(button,False,False)
> return hbox
> --- cut ---
> I can give the full source if needed.
I don't see any code with accelerators here, btw here we go with a
small example:
import gtk
w = gtk.Window()
w.connect("destroy", gtk.main_quit)
w.set_default_size(200, 300)
b = gtk.Button(None, gtk.STOCK_QUIT)
b.connect("clicked", gtk.main_quit)
ag = gtk.AccelGroup()
w.add_accel_group(ag)
b.add_accelerator("clicked", ag, ord('q'), gtk.gdk.SHIFT_MASK,
gtk.ACCEL_VISIBLE)
w.add(b)
w.show_all()
gtk.main()
cheers
--
Gian Mario Tagliaretti
More information about the pygtk
mailing list