skip to Main Content

I have an app that has a play button to play audio from some local repeater: Although I want just a play/stop button, the button does not play on newer Ubuntu or a new Raspbian install. Is there something missing here, maybe related to the recent change where they set all the buttons to not show icons on buttons in GTK/Ubuntu?

button.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_MEDIA_PLAY, self.PLAYSIZE))

Is this how I should set the button to only have an icon? It works on my 16.04 setup, but button is blank on others. The code is here and app is here.

2

Answers


  1. Chosen as BEST ANSWER

    button.set_label('') made the button's image hide. It seems that Ubuntu and other systems do not display the icon whenever any text label is on it?


  2. Stock icons are deprecated, and should not be used in newly-written code.

    The appropriate way to show an icon in a button is to use named icons from an icon theme.

    For instance, if you want to show a “play” icon, you should use media-playback-start:

    b = Gtk.Button()
    b.set_image(Gtk.Image(icon_name='media-playback-start',
                          icon_size=Gtk.IconSize.BUTTON))
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search