<interface>
<object class='GtkWindow' id='window'>
<child>
<object class='GtkBox' id='box'>
<property name='orientation'>horizontal</property>
<child>
<object class='GtkAspectFrame' id='aspect_frame'>
<property name='xalign'>0.0</property>
<property name='yalign'>0.0</property>
<child>
<object class='GtkDrawingArea' id='drawing_area_A'>
<property name='expand'>TRUE</property>
</object>
</child>
</object>
</child>
<child>
<!-- widget B goes here -->
</child>
</object>
</child>
</object>
</interface>
上面的GtkBuilder UI 定义创建了一个方形 DrawingArea A。我希望它在其窗口内尽可能大,因此我将Aexpand
的属性设置为. 但是,当窗口本身的宽度大于高度时,我想要一个小部件B来填充绘图区域未使用的剩余宽度。基本上,我想要这个:TRUE
+--------------------+
|+-----------++-----+|
|| || ||
|| A || B ||
|| || ||
|| || ||
|+-----------++-----+|
+--------------------+
但我得到了这个(如果B已expand
设置为FALSE
):
+--------------------+
|+-----------+ +-+|
|| | | ||
|| A | |B||
|| | | ||
|| | | ||
|+-----------+ +-+|
+--------------------+
或者这个(如果B已expand
设置为TRUE
):
+--------------------+
|+-------++---------+|
|| || ||
|| A || B ||
|| || ||
|+-------+| ||
| +---------+|
+--------------------+
如何让 GTK 合作?