在Gtk中,我如何制作一个带有股票图标的按钮? [英] In Gtk, how do I make a Button with just a stock icon?
问题描述
我想创建一个带有删除图标的按钮,但没有删除文本。如果我使用 Button button = new Button(Stock.Remove);
,我会得到相反的结果:只是文本,没有图标。我会有很多这些按钮,文本使它看起来很混乱。如何获取图标?
I want to create a button with the stock "Remove" icon on it, but without the text "Remove". If I use Button button = new Button(Stock.Remove);
, I get the opposite: just the text, and no icon. I will have many of these buttons, and the text makes it look cluttered. How do I get just the icon?
注意:这些是常规按钮,而不是工具栏按钮。
Note: these are regular buttons, not toolbar buttons.
编辑:
这就是它目前的样子:
This is how it currently looks:
我想用小而不显眼的图标按钮来代替这些按钮。
I want to replace these buttons with small, unobtrusive, icon-only buttons.
推荐答案
首先创建一个股票 Gtk.Image
,然后创建您的 Gtk.Button
,将图片作为参数。
First create a stock Gtk.Image
, and then create your Gtk.Button
, passing the image as its argument.
Image image = new Image(Stock.Remove, IconSize.Button);
Button button = new Button(image);
这篇关于在Gtk中,我如何制作一个带有股票图标的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!