self.button = gtk.Button(stock=gtk.STOCK_DELETE)
Only Shows: Delete
Join Stack Overflow to learn, share knowledge, and build your career.
|
|
This is a recent change in GTK - the developers wanted icons not to appear on buttons. On Linux, this can be changed by editing the
On windows, I think (I haven't actually tried this) that you need to set a value in your gtkrc file (for me it's in You can also add EDIT in answer to your comment: Just like this answer, but in Python: In Gtk, how do I make a Button with just a stock icon? For python, it's just
|
|||||||||||||
|
|
in Gtk3
In the case it doesn't help since it points to the custom label solution ( Example new button with a "stock" icon:
Example new button with a "stock" label:
NOTE: on serious code creating a constant variable instead of using the string straight is a better option :) References: |
|||
|
|
|
If you work with pygobject, the new syntax is:
|
|||||
|
|
You can show explicitly the button image, justly, Gtk+ developers do not recommend doing this because it's overrides the Gtk+ user configuration. So...
|
|||
|
|
|
The Python equivalent for setting the property without having to change any system config files is:
This should follow a call to window.show() and, obviously, precede the gtk.main() loop. |
|||||
|
|
I had the same issue in GTKmm on Windows. The "MS-Windows" theme disables images on stock buttons and the theme has priority over settings in gtkrc (so putting gtk-button-images = true in gtkrc didn't help). What I did is to modify the GTK settings runtime, and the images appeared as expected. :) Here's the code in C++:
It should be placed after the first window is constructed. |
|||
|
|
|
I had to do this to get it to work from Python without changing my config file. When I called set_image(), no image was being displayed.
|
|||
|
|