I've got a Gtk.Label
contained within a Gtk.Grid
something like as follows:
self.__grid = Gtk.Grid()
self.__grid.set_row_spacing(2)
self.__grid.set_column_spacing(5)
self.__grid.props.margin = 5
#...
self.clock_label = Gtk.Label("N/A")
self.clock_label.set_halign(Gtk.Align.START)
self.__grid.attach(self.clock_label, current_col, current_row, 1, 1)
Which works as expected. I encountered an unwanted behavior, though, which meant that as the seconds ticked by, the text of the label being set elsewhere would offset the column (as the clock label is the widest thing in this column) causing all elements to the right of it to shift back and forth as the string itself grew wider (with seconds like 8) or narrower (with seconds like 1).
To solve this, I added a line to the setup code for this label
self.clock_label.set_width_chars(8)
And voila, it worked. However, it insists on centering the text when I do that, irrespective of the presence or absence of the set_halign()
.
I would like very much to have a label whose text starts on the left-hand border of its cell, but whose width is also padded such that changes in string length are of no concern.
Any help is appreciated. =)