Gtk justification doesn't work - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Gtk justification doesn't work (/thread-776.html) |
Gtk justification doesn't work - rebelxt - Nov-05-2016 Using python3 and Gtk3 in Linux Mint 18. Part of my script is: label=Gtk.label("text") label.set_justify(Gtk.Justification.RIGHT)The text remains in the center of the widget. Should I be doing sometning different? RE: Gtk justification doesn't work - rebelxt - Nov-05-2016 Here is a very small demo: #!/usr/bin/env python3 import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk dialog = Gtk.Dialog(title="Dialog", buttons=(Gtk.STOCK_OK, Gtk.ResponseType.OK)) dialog.set_default_size(400, -1) box = dialog.get_content_area() label = Gtk.Label("Label 1") label.set_justify(Gtk.Justification.RIGHT) box.pack_start(label, True, True, 0) label = Gtk.Label("Label 2") label.set_justify(Gtk.Justification.LEFT) box.pack_start(label, True, False, 0) label = Gtk.Label("Label 3") label.set_justify(Gtk.Justification.RIGHT) box.pack_start(label, False, True, 0) label = Gtk.Label("Label 4") label.set_justify(Gtk.Justification.LEFT) box.pack_start(label, False, False, 0) dialog.show_all() response = dialog.run() dialog.destroy() RE: Gtk justification doesn't work - rebelxt - Nov-05-2016 OK, I finally found the documentation that says set_justify does not work on single line labels, use set_alignment instead. So, for right justification: label.set_alignment(1, 0.5) For left justification: label.set_alignment(0, 0.5) |