How can I align widgets in GTK 3

box1=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,3);
align=gtk_alignment_new(1,0,0,0);
my=gtk_button_new_with_label("HELLO");
gtk_container_add(GTK_CONTAINER(frame),my);
gtk_container_add(GTK_CONTAINER(box1),frame);
gtk_container_add(GTK_CONTAINER(window),box1);

I have to write all this code to align the button to the left of the window or easier. If someone can give me more information about GTK containers, because I understand the link well.

Before using Glade, I want to see how everything works. Sorry for my English.

+4
source share
2 answers

As the documentation for GtkAlignment notes in Gtk3, there is usually no need to use it, since the same effect can be achieved by setting the halign and margin , hexpand properties of the widget that you want to align.

halign valign GTK_ALIGN_START.

+8

: jku, GtkHBox, GtkVBox GtkTable , GtkGrid. GtkAlignment , , Phillip Wood.


, gtk_alignment_new(0,0,0,0) . , , . .

GTK :

  • GtkFixed, .

    +----------------------------+
    |                   Widget 3 |
    | Widget 2                   |
    |              Widget 1      |
    |                            |
    +----------------------------+
    
  • GtkHBox :

    +--------+-----+
    | Widget | ... |
    +--------+-----+
    
  • GtkVBox :

    +--------+
    | Widget |
    +--------+
    |  ...   |
    +--------+
    
  • GtkTable .

    +--------+-----+
    | Widget | ... |
    +--------+-----+
    |  ...   | ... |
    +--------+-----+
    

GtkAlignment, .

GTK + - , .

+2

Source: https://habr.com/ru/post/1530760/


All Articles