[pygtk] How to do_size_allocate properly in a gtk.Viewport subclass?

Joel Hedlund yohell at ifm.liu.se
Thu Oct 23 17:45:29 WST 2008


Thanks for your suggestion! It works quite well, however I do have some 
gripes with this solution, mostly because of stuff I left out of my 
original mail for the sake of brevity. So here goes:

John Finlay wrote:
> I'm not sure what behavior you are looking for so I'll assume that you 
> have one widget (e.g. Image) that you want to put inside a Viewport  

Yup, only it's a custom widget, a subclass of gtk.DrawingArea.

> in a ScrolledWindow. 

Not necessarily, but I probably could if that works better?

> I'll also assume that you want the widget to 
> float in the center of the Window when the widget is smaller than the 
> Window. 

Mostly correct. I'd rather have top left. Or somewhere else, see below.

> Finally I assume that you want the widget to be partially 
> displayed but scrollable within the window when the widget is larger 
> than the Window. 

Correct.

So, the purpose of all this is to make a viewer for multiple sequence 
alignments (MSA). You can think of an MSA as a very large matrix with 
one amino acid (aa = a letter) per element. Both the aas and their 
backgrounds will be colored individually based on properties of the aa 
and its context in the MSA. My widget will let you interact with the MSA 
(draw, make selections, context menus, ...). Also there will be multiple 
additional widgets around this one, displaying graphs and plots for row- 
and column statistics in the MSA. My widget will also be used for these. 
When looking at this kind of stuff you need to zoom around a lot to be 
able to look at both the big picture and the gory details, hence the 
need to support both tiny and huge widgets. All these views need to be 
coupled so that the graphs line up with the MSA *exactly*, and for all 
this I want a total of 2 scrollbars.

I want to use the mouse scrolls to do most of the zooming, and when that 
happens I want to have the MSA "stay put" under the pointer so that the 
aa that was under the pointer before the zoom also is under the pointer 
after the zoom (not implemented in the attached example). This is easy 
when the widget is larger than the viewport, but I don't really know how 
to do that when it's smaller. If that turns out to be too hard I think 
the next best thing is to place small widgets topleft (how?). Or if 
that's also a problem I could make do with centered I suppose...

Now, my real gripe is that zooming looks "twitchy" for small widgets 
with the widget-in-table-in-viewport solution, and that will be painful 
for users to look at. I'm hoping I've done some stupid oversight 
somewhere (help?). Maybe that will go away if you glue the widget 
topleft somehow?

I attached a small example I've worked with so you can see what I mean.

Thanks for your time!
/Joel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: custom_viewport.py
Type: text/x-python
Size: 5300 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20081023/776299fd/attachment.py 


More information about the pygtk mailing list