在Gtk中,我如何制作一个带有股票图标的按钮? [英] In Gtk, how do I make a Button with just a stock icon?

查看:276
本文介绍了在Gtk中,我如何制作一个带有股票图标的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个带有删除图标的按钮,但没有删除文本。如果我使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆