问题
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();
}
回答1:
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.
来源:https://stackoverflow.com/questions/54937787/how-can-i-change-the-thickness-of-a-gtkwidget