How to have a Gtk.Button with Icon and Label #1140
-
I am trying to create a button that has an icon in it. My understanding is that Gtk will display icons from https://specifications.freedesktop.org/icon-naming-spec/latest/ and that themes used on the system are supposed to implement the icons listed in the standard. I am using GirCore.Gtk-4.0 version 0.5.0 from nuget. I am trying to do the following:
When the button is displayed in the window, it only shows the label with the word I have tested the following:
This returns the following:
I know the icon is in the The documentation at https://docs.gtk.org/gtk4/ctor.Button.new_from_icon_name.html says that a broken image icon should show if the icon name is not known. I tried using an icon name of Any assistance pointing me in the right direction would be greatly appreciated. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Ok, with further experimentation I found that if you have the button with no label then the icon will display as expected. I guess that means that the default is to show either a label or an icon but, not both together. I am wondering if there is a standard recommended way to show both an icon and a label on a Gtk.Button widget? Thanks, |
Beta Was this translation helpful? Give feedback.
-
The Gtk.Button will display either a Label or an Icon but not both at the same time. If you want to have both a icon and a label on a button then you need to make a Gtk.Box a child of the Gtk.Button and add the Gtk.Image and Gtk.Label to the Gtk.Box. Example of a Quit Button with an Icon and a Label:
|
Beta Was this translation helpful? Give feedback.
The Gtk.Button will display either a Label or an Icon but not both at the same time. If you want to have both a icon and a label on a button then you need to make a Gtk.Box a child of the Gtk.Button and add the Gtk.Image and Gtk.Label to the Gtk.Box.
Example of a Quit Button with an Icon and a Label: