[pygtk] Pixmap, DrawingArea, Viewport, Scrolledwindow

A.T.Hofkamp a.t.hofkamp at tue.nl
Mon Aug 17 16:05:23 WST 2009


Nick Peters wrote:
> A.T.Hofkamp wrote:
>> Nick Peters wrote:
>>
>>>         if response == gtk.RESPONSE_OK:
>>>             print open_dialog.get_filename(), 'selected'
>>>             #load the Image the user selected.
>>>             rpg_map =
>>> gtk.gdk.pixbuf_new_from_file(open_dialog.get_filename())
>> I am missing the resize of the DrawingArea (self.area in my case):
>>
>> self.area.set_size_request(rpg_map.get_width(),
>>                        rpg_map.get_height())
>>
>> this notifies that the area has grown, and updates the scrollbars.
>>
>>
>> Albert
>>
> Thanks very much! I remember reading about that method, however i
> mistakenly thought it was for resizing the drawingarea! Thanks for the
> clarification!

The method is intended for resizing the drawing area, actually.

You don't show the drawing area, you show the ScrolledWindow. That means the 
size of the window at the screen is the size of the scrolled window, not of 
the drawing area.

The scrolled window however needs to know the size of the widget it displays 
(ie the drawing area) for managing the bars. It does that by simply asking its 
child widget (the drawing area) about its size.[1]

Albert

[1] Actually, it does not 'ask', it gets an update with every change.


More information about the pygtk mailing list