如何更改gtkwidget的厚度? [英] How can I change the thickness of a gtkwidget?
问题描述
此图片显示了我当前应用中的场景.看起来很蠢空的gtk列表仅占用屏幕的一半.如何使它占据屏幕的五分之四,完成"按钮占屏幕的五分之一?我一如既往地使用C编程语言和刚刚升级到的gtk3.如果有一种方法可以调整小部件的厚度,那么我在繁琐的文本输入方面也会遇到麻烦.使其均质使它们相同,但是我如何使其不均质但让我决定每个小部件获得多少屏幕?
This image shows a scene in my current app. It looks dumb. The empty gtk list is only taking half the screen. How can I make it take four fifths of the screen and the done button take up one fifth? I am using the C programming language as always and gtk3 which I just upgraded to. I am also having trouble with fat text entries, if there is a way to ajust the thickness of widgets. Making it homogeneous makes them all the same, but how can I make it NOT homogeneous but let me decide how much of the screen each widget gets?
#include "DisplayHelp.h"
#define NOTHING
void DisplayHelp(void) {
gtk_main_quit(NOTHING);
gtk_widget_destroy(Box);
Box = gtk_vbox_new(0, 0);
GtkWidget (*Button) = NULL;
GtkWidget (*List) = gtk_list_box_new();
gtk_container_add(GTK_CONTAINER(Box), List);
gtk_container_add(GTK_CONTAINER(Window),Box);
Button = gtk_button_new_with_label("Done");
gtk_box_pack_start(GTK_BOX (Box), Button, 1, 1, FALSE);
g_signal_connect(Button,"clicked",DisplayOptions,NULL);
//i need a function to ajust the size of the button here
printf("Entering the screen: Help\n");
gtk_widget_show_all(Window);
gtk_main();
}
推荐答案
您可以使用GtkGrid,将其垂直均匀性设置为TRUE,并根据所需比例为每个小部件设置高度:
You can use GtkGrid, set it's vertical homogenity to TRUE and set height for each widget with respect to desired proportions:
grid = gtk_grid_new ();
gtk_grid_set_row_homogeneous (grid, TRUE);
/*l t w h*/
gtk_grid_attach (grid, top_widget, 0, 0, 1, 4);
gtk_grid_attach (grid, bot_widget, 0, 0, 1, 1);
但是,这可能不是最佳的设计解决方案,因为您浪费了按钮空间.
However, it may be not the best design solution, as you are wasting space for button.
这篇关于如何更改gtkwidget的厚度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!