3
votes

I am prototyping an application interface in Glade (GTK# 3.20 + C#) and use my CSS styles via CssProvider. I have this:

enter image description here

The problem is that I am using GTKLayout as my main container and I think it's the wrong way to create the UI. I am using this type of container because it give me the ability to resize and drag widgets as I want within the Glade during the prototyping. The bad thing is that widgets stuck at left top corner of the application window when I am resizing it. I made a min size for the window, but I want the UI to be adaptive when the window size is increasing. You can see the problem below:

enter image description here

I tried to create this UI with Box container, Grid container and so on. But I always had the same problem: the size of all the widgets was fixed (in Glade during the prototyping) and it looked like it was impossible to create the complex UI with it.

So, I want some experienced people to explain me a few things:

  1. If I am using GTKLayout in a wrong way how should I organize my widgets (in which containers) to have the ability to resize them like I want (In Glade) and to have the same look like at my screenshot.
  2. If it's not a bad practice to use GTKLayout, how should I solve the alignment problem to make an adaptive UI?
  3. If it's a bad practice to use GTKLayout, how should I make an adaptive UI and with which containers?

Here is the structure of the window (yes, I am using Label widget to create color panels):

enter image description here

3

3 Answers

4
votes

Give a look to the different containers available, run gtk-demo to see how are constructed the examples, use gtk-inspector on existing applications to know how they are laid out.

You may read also this layout "guide":

https://python-gtk-3-tutorial.readthedocs.io/en/latest/layout.html

TLDR: Use a GtkGrid.

0
votes

GtkLayout is not designed to stretch, shrink and so forth. You probably want to set your GtkBox to GTK_EXPAND(True) and / or GTK_FILL(True) . In Glade select your label, button or child widget and look under the Packing tab.

0
votes

I think in this case the best option would be GtkFixed.