0

I have a toplevel Gtk.Window which only child is a Gtk.Label.
If the width needed by the label to show its text is XXX pixels, I am not able to resize the top-level window with under XXX pixels. This happens if I set the size_request of the label to 5,5 too.
I'd like to be able to resize the window width under XXX pixels hiding part of the label text.

This is the code for testing: from gi.repository import Gtk

class Window(Gtk.Window):

    def __init__(self):
        super(Window,self).__init__()

        self.label = Gtk.Label("long text label bla bla bla bla bla bla")
        self.label.set_size_request(5,5)
        self.add(self.label)

        self.connect("delete-event",Gtk.main_quit)
        self.show_all()

if __name__ == "__main__":

    app = Window()
    Gtk.main()
Irr
  • 656
  • 1
  • 9
  • 19
  • It would possibly let you shrink if you wrap the window contents in a `Gtk.ScrolledWindow`. But it may not work with a size request. –  Jan 22 '13 at 05:05
  • Yes, but I don't want the scrollbars and if I set the policy to `NEVER` I lose the possibility to shrink – Irr Jan 22 '13 at 13:31

1 Answers1

1

Try to change the ellipsize status of your label with gtk_set_ellipsize_status. The minimal requested size will then be the one of the ellipsis "…". Choose the right Pango ellipsize mode. Sad I can't find any PyGObject online documentation, so I had to link to the C and pyGTK ones, but you can find the PyGObject equivalent from that.

liberforce
  • 11,189
  • 37
  • 48