On Wed, 2006-03-01 at 20:09 -0800, John Finlay wrote: > Alex Roitman wrote: > > Hello, > > > > I have asked this question before: > > http://www.daa.com.au/pipermail/pygtk/2005-December/011572.html > > and was pointed by John Finlay to the proper solution: > > http://www.daa.com.au/pipermail/pygtk/2005-December/011562.html > > > > Unfortunately, following the given advice still did not do the trick. > > Running the code below still leaves the window not shrunken in > > either direction. It seems to be limited by the size that would > > be a minimum size of the _expanded_ expander, not collapsed expander. > > > > ============== > > import gtk > > > > d = gtk.Dialog('Dialog') > > d.connect('delete-event',lambda obj,event: gtk.main_quit()) > > > > e = gtk.Expander('Expander') > > e.add(gtk.Label('Label\nAnother line that is very very very long\n' > > 'and another line')) > > > > def expander_toggled(expander,param): > > if expander.get_expanded(): > > print "expanding -> do nothing" > > else: > > print "collapsing -> shrink both X and Y size" > > d.resize(1,1) > > > > e.connect('notify::expanded',expander_toggled) > > > > d.vbox.add(e) > > d.show_all() > > > > gtk.main() > > ============== > > > > If after > > print "expanding -> do nothing" > > I add: > > d.resize(400,200) > > or if I resize the window manually to a larger size > > while expander is in the expanded state, I can see that > > the window does indeed shrink somewhat upon collapsing > > the expander, so I know that resize() is working. > > The problem is that it shrinks to the size constrained > > by _expanded_ state of the expander, not its _collapsed_ > > state. > > > > After collapsing, I can manually resize the window > > to the smaller size, picking up "the slack" produced > > by collapsing the expander. > > > > Am I missing something obvious? How can I make the window > > shrink after expander is collapsed so that there's > > no "slack"? > > > I thought the message following mine actually indicated a better > solution than the one I suggested: > > http://www.daa.com.au/pipermail/pygtk/2005-December/011564.html > > i.e. use d.set_resizable(False)
This does shrink the dialog window, but then it becomes, er, not resizable :-) For a complex window with a lot of widgets and a text editable area, this is not very nice. We do want small size, but the user will ultimately decide what's the convenient size. Smallest is the nice default behavior on expander collapse. My wild guess as to what's happening would be that the size request of the expander widget is not set to the new state while the handlers are being run. It is properly set afterwards, so I can manually do what I want. But this behavior seems to leave me no way to do the obviously logical thing: free the space when expander is collapsed. Is this a bug? Is there a workaround? Many thanks in advance. Alex -- Alexander Roitman http://www.gramps-project.org
signature.asc
Description: This is a digitally signed message part
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
