What is the reason for such black bars in GUI?

Im designing an application for my project but the window has some black colour space appearing as shown in pic. The hierarchy for widgets are as folllows:

         1. grid -
                  1.1. combo box
                  1.2. grid -
                           1.2.1. label, entry
                           1.2.2. label, entry
                           1.2.3. label, entry
                           1.2.4. expander -
                                    1.2.4.1. grid -
                                             1.2.4.1.1. label, entry
                                             1.2.4.1.2. label, entry
                  1.3. label

Is it due to the complex nature of way elements are packed?

A minimial working example is

from gi.repository import Gtk

dialog = Gtk.Window(name="dialog")
main_grid = Gtk.Grid(name="dialog-main_grid",
                     hexpand=True,
                     halign=Gtk.Align.FILL)
connectors_combobox = Gtk.ComboBoxText(name="connectors_combobox",
                                                    active_id=0)
entry_grid = Gtk.Grid(name="entry_grid",
                      hexpand=True,
                      halign=Gtk.Align.FILL)
error_label = Gtk.Label(name="error_label",
                        label="Error",
                        use_markup=True)

entry_grid.attach(Gtk.Label(label="Label 1"), 0, 0, 1, 1)
entry_grid.attach(Gtk.Entry(text="Entry 1"), 0, 1, 1, 1)
entry_grid.attach(Gtk.Label(label="Label 2"), 0, 2, 1, 1)
entry_grid.attach(Gtk.Entry(text="Entry 2"), 0, 3, 1, 1)
entry_grid.attach(Gtk.Label(label="Label 3"), 0, 4, 1, 1)
entry_grid.attach(Gtk.Entry(text="Entry 3"), 0, 5, 1, 1)

#connect_button = Gtk.Button(name="login-dialog-connect",
#                                         label="Connect")
#quit_button = Gtk.Button(name="login-dialog-quit",
#                                      label="Quit")
#connect_button.connect("clicked", response, 1)
#quit_button.connect("clicked", response, 0)

#connectors_combobox.connect("changed", show_prompts)
    
main_grid.attach(connectors_combobox, 0, 0, 1, 1)
main_grid.attach(entry_grid, 0, 1, 1, 1)
main_grid.attach(error_label, 0, 2, 1, 1)

#main_grid.attach(connect_button, 0, 3, 1, 1)
#main_grid.attach(quit_button, 1, 3, 1, 1)
dialog.add(main_grid)
dialog.show_all()
dialog.connect("destroy", Gtk.main_quit)
Gtk.main()

The black labels are from the theme that you are using. Test running the program with

GTK_THEME=Adwaita:dark python3 program.py

or

GTK_THEME=Adwaita:light python3 program.py

or change the CSS in your program to color the labels differently.

Eric

1 Like

Thanks. It seems weird, such black labels only appear when I pack containers inside containers and so and not in ordinary cases, anyway, I like your idea. Thanks again ^^

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.