Gtk 按钮内边框
我向 HBox 添加了一个按钮,且 Expand 等于 False,但我希望按钮的标签和边框之间有更大的间距。我认为它是“内边框”属性,但它是只读的。我怎样才能将它设置为例如4px?
I add a button to HBox, with expand equal to False, but I want the button to have more spacing between its label and border. I assume it is "inner-border" property, but it is read-only. How can I set it to e.g. 4px?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
gtk.Label 是 gtk.Misc 的子类,它具有 set_padding 方法。如果你从 gtk.Button 中获取标签,那么你可以在它上面调用 set_padding 。
你可以这样做:
gtk.Label is a subclass of gtk.Misc which has the method set_padding. If you get the label out of the gtk.Button then you can just call set_padding on it.
You could do something like:
错误答案:
您正在寻找的内容称为“填充”。当您将按钮添加到容器时,例如通过调用 gtk.Box.pack_start,只需将
padding
参数设置为正整数即可。更新:
似乎我误读了这个问题。在这种情况下,我的猜测是你应该使用 gtk_widget_modify_style,因为
inner-border
是一个样式属性。您首先需要通过调用 gtk_widget_get_modifier_style。然后,您将能够使用 资源样式匹配规则。Wrong answer:
What you're looking for is called "padding". When you add your button to the container, for example by calling gtk.Box.pack_start, just set the
padding
parameter to a positive integer.Update:
Seems I misread the question. In that case, my guess is that you're supposed to use gtk_widget_modify_style, as
inner-border
is a style property. You'll first get the style modifier you need by calling gtk_widget_get_modifier_style. You'll then be able to modify the style only for that button using the ressource styles matching rules.您可以使用 gtk 按钮的“inner-border”样式属性。
这里
小代码片段[编辑]
是 gtkrc 文件中的
:希望会有帮助。
you can use "inner-border" style property of gtk button.
here, small code snippets
[Edit]
In gtkrc file:
hope, it would be helpful.
我有时只是在标签中添加空格!
以获得一些间距。
希望这可以帮助你。
I sometimes just add spaces in the label !
to get some spacing.
Hope this could help you.