How can I extend the Gtk Label to fill the entire horizontal space?

I am trying to insert a text label in a dialog box, but when I set aligment (X = 0, Y = 0.5) and wrap the string in True, the text does not fill the entire horizontal space.

There is an image here

This is an example code in python:

import gtk if __name__ == "__main__": lbl = gtk.Label('Presione el botón "Adelante" para iniciar la instalación del sistema. Después de este paso no podrá detener la instalación, así que asegúrese de que sus datos son correctos.') lbl.set_line_wrap(True) lbl.set_alignment(0, 0.5) lbl.set_justify(gtk.JUSTIFY_FILL) lbl.show() diag = gtk.Dialog() diag.set_size_request(640, 480) diag.vbox.pack_start(lbl) diag.run() 
+4
source share
1 answer

Try setting the "expand" and "fill" properties when you pack the label into a dialog:

 diag.vbox.pack_start(lbl, True, True, 0) 

Edit

You're right. I'm sorry. In the GTK Reference Guide:

Please note that setting line feed to TRUE does not make the wrapper of the label in its parent container wide, since GTK + concepts cannot conceptually make their application dependent on the size of the parent container. For a label that wraps at a specific position, set the label width using gtk_widget_set_size_request ().

Therefore, set the size request in GtkLabel instead of GtkDialog , and then in the dialog box and give the size of the dialog yourself.

 # -*- coding: utf-8 -*- import gtk if __name__ == "__main__": lbl = gtk.Label('Presione el botón "Adelante" para iniciar la instalación del sistema. Después de este paso no podrá detener la instalación, así que asegúrese de que sus datos son correctos.') lbl.set_line_wrap(True) lbl.set_alignment(0, 0.5) lbl.set_justify(gtk.JUSTIFY_FILL) lbl.set_size_request(640, 480) lbl.show() diag = gtk.Dialog() diag.set_resizable(True) diag.vbox.pack_start(lbl, True, True, 0) diag.run() 
+3
source

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


All Articles