7

I'm new to GTK3 (I prefer wxWidgets), and I can't load a stock icon to a gtk.button...

This is my attempt:

image = Gtk.Image()
pb = Pixbuf.new_from_stock(Gtk.STOCK_OPEN)

self.browse_button = Gtk.Button(label="")
self.browse_button.set_from_pixbuf(pb)

This is how it is done on wxWidgets (much more simpler):

self.browse_button = wx.BitmapButton( self, wx.ID_ANY, wx.ArtProvider.GetBitmap( wx.ART_FILE_OPEN, wx.ART_MENU ), wx.DefaultPosition, wx.DefaultSize, wx.BU_AUTODRAW )

any help?

2 Answers 2

6

Try:

image = Gtk.Image(stock=Gtk.STOCK_OPEN)
self.browse_button = Gtk.Button(label="Some Label", image=image)

See the documentation.

Sign up to request clarification or add additional context in comments.

1 Comment

OK, you didn't say you wanted your own label with a stock icon... see edit.
4

Like Ptomato did, but with no label and using one line :

self.btnOpen = Gtk.Button(None,image=Gtk.Image(stock=Gtk.STOCK_OPEN))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.