On Fri, 2006-03-03 at 21:23 -0800, John Finlay wrote:
> >>> ==============
> >>> 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.
> >   
> What's your thinking on how this would work?

My thinking is that the following should be either normal behavior
or should be doable using signal handlers:

   When the user collapses the expander widget and the space that
   was taken up by the expander widget is no longer occupied by
   the expander, the window shrinks to the smaller size, as small
   as possible given the new size constraints, now that the expander
   takes just the size of its label.

In other words, I want same intuitive behavior that happens if the
dialog were non-resizable, only I don't want it to be non-resizable.

> > 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.
> >   
> If you add the expander using d.vbox.pack_start(e, False) the expander 
> will shrink automatically. If a textview shares the vbox it will expand 
> when the expander shrinks. Is that what you're looking for?

Expander shrinks alright, but I want the window to shrink as well.
What I am looking for is for the dialog to behave exactly the way
the non-resizable dialog would behave on expander click.

Is this asking too much?
Alex

-- 
Alexander Roitman   http://www.gramps-project.org

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to