Use gtk settings to make buttons show their icons again

You may have noticed gtk has stopped showing images for buttons by default. Many apps have not bothered to check the default settings and just assumed that defining an image for a button meant it would show. Too bad the gtk devs decided to change the default value.

b = gtk.Button(label='Home', stock=gtk.STOCK_HOME))

There is a way to make sure the image shows without modifying the system or user preferences outside of your application.

>>> import gtk
>>> settings = gtk.settings_get_default()
>>> print settings.__doc__

The last one on the list is gtk-button-images and it’s a gboolean. Now why would they go and change the behavior like that? Oh well – time to change it back!

>>> s = gtk.settings_get_default()
>>> s.set_property("gtk-button-images", True)

buttons2

Here’s the rest of the settings from printing settings.__doc__

Object GtkSettings

Properties from GtkSettings:
gtk-double-click-time -> gint: Double Click Time
Maximum time allowed between two clicks for them to be considered a double click (in milliseconds)
gtk-double-click-distance -> gint: Double Click Distance
Maximum distance allowed between two clicks for them to be considered a double click (in pixels)
gtk-cursor-blink -> gboolean: Cursor Blink
Whether the cursor should blink
gtk-cursor-blink-time -> gint: Cursor Blink Time
Length of the cursor blink cycle, in milliseconds
gtk-cursor-blink-timeout -> gint: Cursor Blink Timeout
Time after which the cursor stops blinking, in seconds
gtk-split-cursor -> gboolean: Split Cursor
Whether two cursors should be displayed for mixed left-to-right and right-to-left text
gtk-theme-name -> gchararray: Theme Name
Name of theme RC file to load
gtk-icon-theme-name -> gchararray: Icon Theme Name
Name of icon theme to use
gtk-fallback-icon-theme -> gchararray: Fallback Icon Theme Name
Name of a icon theme to fall back to
gtk-key-theme-name -> gchararray: Key Theme Name
Name of key theme RC file to load
gtk-menu-bar-accel -> gchararray: Menu bar accelerator
Keybinding to activate the menu bar
gtk-dnd-drag-threshold -> gint: Drag threshold
Number of pixels the cursor can move before dragging
gtk-font-name -> gchararray: Font Name
Name of default font to use
gtk-icon-sizes -> gchararray: Icon Sizes
List of icon sizes (gtk-menu=16,16:gtk-button=20,20…
gtk-modules -> gchararray: GTK Modules
List of currently active GTK modules
gtk-xft-antialias -> gint: Xft Antialias
Whether to antialias Xft fonts; 0=no, 1=yes, -1=default
gtk-xft-hinting -> gint: Xft Hinting
Whether to hint Xft fonts; 0=no, 1=yes, -1=default
gtk-xft-hintstyle -> gchararray: Xft Hint Style
What degree of hinting to use; hintnone, hintslight, hintmedium, or hintfull
gtk-xft-rgba -> gchararray: Xft RGBA
Type of subpixel antialiasing; none, rgb, bgr, vrgb, vbgr
gtk-xft-dpi -> gint: Xft DPI
Resolution for Xft, in 1024 * dots/inch. -1 to use default value
gtk-cursor-theme-name -> gchararray: Cursor theme name
Name of the cursor theme to use, or NULL to use the default theme
gtk-cursor-theme-size -> gint: Cursor theme size
Size to use for cursors, or 0 to use the default size
gtk-alternative-button-order -> gboolean: Alternative button order
Whether buttons in dialogs should use the alternative button order
gtk-alternative-sort-arrows -> gboolean: Alternative sort indicator direction
Whether the direction of the sort indicators in list and tree views is inverted compared to the default (where down means ascending)
gtk-show-input-method-menu -> gboolean: Show the ‘Input Methods’ menu
Whether the context menus of entries and text views should offer to change the input method
gtk-show-unicode-menu -> gboolean: Show the ‘Insert Unicode Control Character’ menu
Whether the context menus of entries and text views should offer to insert control characters
gtk-timeout-initial -> gint: Start timeout
Starting value for timeouts, when button is pressed
gtk-timeout-repeat -> gint: Repeat timeout
Repeat value for timeouts, when is pressed
gtk-timeout-expand -> gint: Expand timeout
Expand value for timeouts, when a widget is expanding a new region
gtk-color-scheme -> gchararray: Color scheme
A palette of named colors for use in themes
gtk-enable-animations -> gboolean: Enable Animations
Whether to enable toolkit-wide animations.
gtk-touchscreen-mode -> gboolean: Enable Touchscreen Mode
When TRUE, there are no motion notify events delivered on this screen
gtk-tooltip-timeout -> gint: Tooltip timeout
Timeout before tooltip is shown
gtk-tooltip-browse-timeout -> gint: Tooltip browse timeout
Timeout before tooltip is shown when browse mode is enabled
gtk-tooltip-browse-mode-timeout -> gint: Tooltip browse mode timeout
Timeout after which browse mode is disabled
gtk-keynav-cursor-only -> gboolean: Keynav Cursor Only
When TRUE, there are only cursor keys available to navigate widgets
gtk-keynav-wrap-around -> gboolean: Keynav Wrap Around
Whether to wrap around when keyboard-navigating widgets
gtk-error-bell -> gboolean: Error Bell
When TRUE, keyboard navigation and other errors will cause a beep
color-hash -> GHashTable: Color Hash
A hash table representation of the color scheme.
gtk-file-chooser-backend -> gchararray: Default file chooser backend
Name of the GtkFileChooser backend to use by default
gtk-print-backends -> gchararray: Default print backend
List of the GtkPrintBackend backends to use by default
gtk-print-preview-command -> gchararray: Default command to run when displaying a print preview
Command to run when displaying a print preview
gtk-enable-mnemonics -> gboolean: Enable Mnemonics
Whether labels should have mnemonics
gtk-enable-accels -> gboolean: Enable Accelerators
Whether menu items should have accelerators
gtk-recent-files-limit -> gint: Recent Files Limit
Number of recently used files
gtk-im-module -> gchararray: Default IM module
Which IM module should be used by default
gtk-recent-files-max-age -> gint: Recent Files Max Age
Maximum age of recently used files, in days
gtk-fontconfig-timestamp -> guint: Fontconfig configuration timestamp
Timestamp of current fontconfig configuration
gtk-sound-theme-name -> gchararray: Sound Theme Name
XDG sound theme name
gtk-enable-input-feedback-sounds -> gboolean: Audible Input Feedback
Whether to play event sounds as feedback to user input
gtk-enable-event-sounds -> gboolean: Enable Event Sounds
Whether to play any event sounds at all
gtk-enable-tooltips -> gboolean: Enable Tooltips
Whether tooltips should be shown on widgets
gtk-button-images -> gboolean: Show button images
Whether images should be shown on buttons

Signals from GObject:
notify (GParam)

Posted by admica   @   17 May 2011

Related Posts

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

*

Previous Post
«
Next Post
»
Powered by Wordpress   |   Lunated designed by ZenVerse

Valid XHTML 1.0 Transitional