Re: [pygtk] expander packing issue
On Sun, 2006-03-05 at 17:32 -0500, Tony Nelson wrote: At 10:12 AM -0800 3/4/06, Alex Roitman wrote: On Fri, 2006-03-03 at 21:23 -0800, John Finlay wrote: 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. ... I think that instead, the window should change size by the amount that the Expander widget changed size, so that a shrink then expand would restore to the size before shrinking. This behavior and enabling it should probably be a property of the Expander widget, which knows how much it is changing size. This would be good as well. Is this a GTK+ issue? Am I the only one who sees the current state as a problem? Alex -- Alexander Roitman http://www.gramps-project.org 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/
Re: [pygtk] expander packing issue
At 10:12 AM -0800 3/4/06, Alex Roitman wrote: Content-Type: multipart/signed; micalg=pgp-sha1; protocol=application/pgp-signature; boundary==-JirsYoptq0AXCyZXoyrU 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. ... I think that instead, the window should change size by the amount that the Expander widget changed size, so that a shrink then expand would restore to the size before shrinking. This behavior and enabling it should probably be a property of the Expander widget, which knows how much it is changing size. TonyN.:' mailto:[EMAIL PROTECTED] ' http://www.georgeanelson.com/ ___ 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/
Re: [pygtk] expander packing issue
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 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/
Re: [pygtk] expander packing issue
Alex Roitman wrote: 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. What's your thinking on how this would work? 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? John ___ 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/
Re: [pygtk] expander packing issue
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 pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] expander packing issue
On Tue, 2005-12-27 at 09:22 -0800, B C wrote: Adding d.set_resizable(False) will cause the window to shrink when the expander is collapsed. Thanks! That's exactly what we've been looking for! Alex -- Alexander Roitman http://www.gramps-project.org 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/
Re: [pygtk] expander packing issue
At 12:31 PM -0700 12/24/05, Don Allingham wrote: Hello, and happy holidays to everybody. I am observing strange packing behavior of the Expander widget. Consider the following piece of code: === 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\nand another line')) d.vbox.add(e) d.show_all() e.set_expanded(True) e.set_expanded(False) gtk.main() === When expander is expanded and then collapsed programmatically, the whole window is collapsed. But if I click to expand the expander and then click to collapse it, the window stays expanded. Do I have to do some more packing magic (how?) or is this bug in pygtk? I would think this is because you did this before the widgets received their allocations, which happens at event processing time (I think you can see this by connecting to the size_allocate gtk.Widget signal). You might want to set the expanded state in response to some signal or other (maybe size_allocate), or you might see what happens if you have an event eater before you do this. (I'm a bit uncomfortable with event eaters in general, and especially before calling gtk.main(), so it's at your own risk.) def gtkeat(): while gtk.events_pending(): gtk.main_iteration(False) TonyN.:' mailto:[EMAIL PROTECTED] ' http://www.georgeanelson.com/ ___ 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/
Re: [pygtk] expander packing issue
Tony, On Sat, 2005-12-24 at 15:27 -0500, Tony Nelson wrote: I would think this is because you did this before the widgets received their allocations, which happens at event processing time (I think you can see this by connecting to the size_allocate gtk.Widget signal). You might want to set the expanded state in response to some signal or other (maybe size_allocate), or you might see what happens if you have an event eater before you do this. (I'm a bit uncomfortable with event eaters in general, and especially before calling gtk.main(), so it's at your own risk.) def gtkeat(): while gtk.events_pending(): gtk.main_iteration(False) Why would I want to do any of that, unless there's a bug in pygtk? It seems that, if I click and then click again, I should get back to the same state as I was, and I never do. I thought initially that some packing options are incorrect, but no amount of tweaking packing in Dialog, its Vbox, or expander itself can seem to make a difference. I am not looking into making programmatic expansing/collapsing to behave same as the UI way. Rather, I want to get the expander to behave correctly on clicks. When the user collapses it, the dialog window should shrink, since the whole point is to hide the extra contents. I see no use for keeping an area of the screen taken by grey matter of a dialog with no contents. Am I missing something here? Alex -- Alexander Roitman http://www.gramps-project.org 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/
Re: [pygtk] expander packing issue
Alex Roitman wrote: Tony, On Sat, 2005-12-24 at 15:27 -0500, Tony Nelson wrote: I would think this is because you did this before the widgets received their allocations, which happens at event processing time (I think you can see this by connecting to the size_allocate gtk.Widget signal). You might want to set the expanded state in response to some signal or other (maybe size_allocate), or you might see what happens if you have an event eater before you do this. (I'm a bit uncomfortable with event eaters in general, and especially before calling gtk.main(), so it's at your own risk.) def gtkeat(): while gtk.events_pending(): gtk.main_iteration(False) Why would I want to do any of that, unless there's a bug in pygtk? I think Tony's point was that Don's example probably didn't correctly illustrate a difference in behavior between the programmatic and mouse click actions since the event loop wasn't running. It seems that, if I click and then click again, I should get back to the same state as I was, and I never do. I thought initially that some packing options are incorrect, but no amount of tweaking packing in Dialog, its Vbox, or expander itself can seem to make a difference. I am not looking into making programmatic expansing/collapsing to behave same as the UI way. Rather, I want to get the expander to behave correctly on clicks. When the user collapses it, the dialog window should shrink, since the whole point is to hide the extra contents. I see no use for keeping an area of the screen taken by grey matter of a dialog with no contents. I think that your expectation is not correct - the dialog should not shrink when the expander collapses. My observation is that windows expand to enclose their children but they do not shrink if the allocation requirements of the children are reduced. I expect a dialog to behave the same. If you want to shrink the dialog I think you probably have to catch the notify:expanded signal and then resize the dialog programmatically using the gtk.Window.resize() method. John ___ 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/