Hi Pietro. On Tue, Feb 16, 2010 at 07:01, Pietro Battiston wrote: > Il giorno lun, 15/02/2010 alle 21.38 +0100, Matthias Geier ha scritto: >> Dear list! >> >> My question may sound silly (and maybe it is), but let me explain. >> You could say that a ScrolledWindow that is exactly as big as its >> content doesn't make a lot of sense, but I think in my case it does: > > http://www.daa.com.au/pipermail/pygtk/2009-August/017372.html > and following. Also see the linked gtk-devel thread.
Thanks for the link, this indeed seems to be the same (or at least very similar) problem as I have. One of the suggested solutions was to use set_default_size() of the main window. However, in my case I want to run it in full-screen mode with all widgets placed in a centered gtk.Alignment. And, as mentioned in the linked thread, setting a size for the ScrolledWindow (set_size_request()) would make it impossible for the user to make the area smaller if needed. Especially on very low resolutions this would be necessary in my case. In your last response on the thread you wrote: """ If you _overide_ size_request() (presumably by defining the do_size_request() method), then the user _can_ resize. """ Does that mean I should sub-class the ScrolledWindow and define my own do_size_request() there? Do you have any hints how the function should look like? > But in your case (a kiosk), isn't > http://www.pygtk.org/docs/pygtk/class-gtkwindow.html#method-gtkwindow--maximize > enough?! Or even fullscreen?! Yes, I want to run it in fullscreen mode (as shown in my example), but I don't want to expand all the widgets to fill the whole screen. I would like to have the widgets in their "natural" size in a compact block in the center of the screen and an empty area along the border of the screen. For large screen resolutions this empty area will be also large, for medium resolutions there may be a small empty area and for small resolutions the widgets may be too large, therefore the ScrolledWindow should be used in this case. I'm starting to think this is impossible, especially after reading your message in the gtk-devel-list (http://mail.gnome.org/archives/gtk-devel-list/2009-January/msg00057.html): """ (Notice that - still as far as I know - getting a window, or a contained widget, to take the available space without overflowing the screen is _very_ tricky.) """ If I use my widgets inside of an Alignment inside of a ScrolledWindow inside of the main window instead of the ScrolledWindow inside of an Alignment inside of the main window, it looks a little better. However, I would prefer not scrolling the whole content but having some widgets inside and some outside of the ScrolledWindow. cheers, Matthias > > Pietro > > >> >> I made a GUI using Glade and want to show it in a kind of "kiosk >> mode", i.e. I want to run it in fullscreen mode with all the widgets >> centered on the screen. >> To achieve this, I placed a gtk.Alignment into the main gtk.Window and >> inside of this I put all my other widgets. >> This worked well until I placed a gtk.ScrolledWindow somewhere inside. >> >> The reason for this is that I wanted to run the GUI on different >> screen resolutions. On large screens, the Scrolledwindow should show >> all contents and on small screens there should be scrollbars. >> >> Therefore, I couldn't set a size request to the ScrolledWindow, >> because this would be either too large for small screens or the other >> way round. >> >> What do I have to do that the ScrolledWindow shows all its contents on >> large screens but still is scrollable if the toplevel window is very >> small? >> >> I think this should be logically possible, but I don't know how to >> achieve it with pygtk. >> >> To illustrate my problem, I created a little test script (see below). >> The buttons are of course only place-holders for my actual widgets. >> In a comment there is one line with a size request. If I un-comment >> that, it looks more or less like I want it to look. The thing is even >> if I did know the exact size of the contents, it would still not be >> scrollable if the window is made very small. >> >> I hope you understand my problem and maybe you know a solution or have >> some hints for me. >> >> Thanks in advance, >> Matthias >> >> ######################################### >> #!/usr/bin/env python >> >> import pygtk >> pygtk.require('2.0') >> import gtk >> >> class ScrolledWindowTest: >> def destroy(self, widget): >> gtk.main_quit() >> >> def __init__(self): >> window = gtk.Window() >> window.fullscreen() >> window.connect("destroy", self.destroy) >> window.set_title("ScrolledWindow Test") >> scrolled_window = gtk.ScrolledWindow() >> # I would like it to look like with this line: >> #scrolled_window.set_size_request(105,205) >> scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, >> gtk.POLICY_AUTOMATIC) >> alignment = gtk.Alignment(0.5, 0.5, 0, 0) >> alignment.add(scrolled_window) >> window.add(alignment) >> vbox = gtk.VBox() >> scrolled_window.add_with_viewport(vbox) >> for i in range(5): >> button = gtk.ToggleButton("button") >> button.set_size_request(80, 40) >> vbox.pack_start(button, expand=False) >> window.show_all() >> >> if __name__ == "__main__": >> ScrolledWindowTest() >> gtk.main() >> >> ######################################### >> _______________________________________________ >> pygtk mailing list [email protected] >> http://www.daa.com.au/mailman/listinfo/pygtk >> Read the PyGTK FAQ: http://faq.pygtk.org/ > > > _______________________________________________ > pygtk mailing list [email protected] > http://www.daa.com.au/mailman/listinfo/pygtk > Read the PyGTK FAQ: http://faq.pygtk.org/ > _______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
