如何使Gtk.Box填充所有可用空间?

问题描述

布局如下图所示:两个框封装在具有指定宽度的垂直框中。一个大盒子位于右侧。大框应填充所有可用空间,但是尽管设置了Gtk.Align.FILL属性,却没有发生。

The Layout

请忽略“利用率”框。

        cpu_utilization_chart = new Chart (cpu.core_list.size);
        cpu_frequency_chart = new Chart (1);
        cpu_temperature_chart = new Chart (1);

        var smol_charts_container = new Gtk.Box (Gtk.Orientation.VERTICAL,0);
        smol_charts_container.add (cpu_frequency_chart);
        smol_charts_container.add (cpu_temperature_chart);

        var big_Box = new Gtk.Box (Gtk.Orientation.HORIZONTAL,0);
        big_Box.add (smol_charts_container);
        big_Box.add (cpu_utilization_chart);

        attach (title_grid,1,1);
        attach (grid_usage_labels(),1);
        attach (big_Box,1);

解决方法

要解决此问题,我放弃了Gtk.Grid,而将其替换为Gtk.Box

        pack_end (cpu_utilization_chart,true,0);
        pack_end(smol_charts_container,false,0);

smol_charts_container.hexpand = false;

enter image description here