简体   繁体   English

如何在GTK + 3中添加spacer?

[英]How to add spacer in GTK+3?

I am using C GTK+3, using Glade for the GUI design. 我正在使用C GTK + 3,使用Glade进行GUI设计。 I have a GtkGrid with 1 row and 3 columns. 我有一个包含1行和3列的GtkGrid。 I have a button on column 2 and I want to add a spacer in column 1 and 3 so the button stays in the middle of the window. 我在第2列有一个按钮,我想在第1列和第3列添加一个垫片,这样按钮就会停留在窗口的中间。 Which GTK3 widget should I use to act as a simple 'spacer'? 我应该使用哪个GTK3小部件作为一个简单的“间隔”?

From your description I'm assuming your interface looks like so: 根据您的描述,我假设您的界面如下所示:

当前

I think your trying to achieve an interface like so: 我认为你试图实现这样的界面:

活着

Which can be achieved by changing the alignment from fill to centre in the 'Common' tab: 这可以通过在“公共”选项卡中将对齐从填充更改为中心来实现:

怎么样

However if you wanted the button to be centred regardless of any content placed in Col 1 / 3 you would be better off with a GtkBox with a center widget: 但是,如果你想让按钮居中而不管Col 1/3中放置的任何内容,那么使用带有中心小部件的GtkBox会更好:

可能

Which is achieved like so: 这是如此实现:

Add a horizontally orientated GtkBox and enable center child 添加一个水平方向的GtkBox并启用中心子

中央

Add your button to the extra placeholder displayed 将按钮添加到显示的额外占位符

Set any content you want to the right of the button as pack end 将所需的任何内容设置为按钮右侧的包装结束

包装结束

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM