[pygtk] synchronizing HPaned widgets
stephen.langer at nist.gov
Fri Feb 6 05:34:48 WST 2009
On Feb 5, 2009, at 3:15 PM, John Finlay wrote:
> Stephen Langer wrote:
>> Hi --
>> I'm hoping that someone can tell me if this is a bug or if I'm
>> doing something wrong.
>> I have two HPaned widgets whose separators I'd like to keep
>> synchronized. Both Paneds are in the same VBox, so they have the
>> same width.
>> As described at http://faq.pygtk.org/index.py?req=show&file=faq19.013.htp
>> , I connect to the 'notify' signal for each pane to find out when
>> the separator has been moved. The callback function blocks the
>> signal for the other pane, changes its position to match the
>> first pane, and then unblocks the signal.
>> The problem is that the signal doesn't seem to be blocked
>> sometimes, so the program goes into an infinite loop. There are
>> easy workarounds for this, but they're ugly and unsatisfying. In
>> particular, the program loops when the panes are first shown if
>> the contents of two diagonally opposite subpanes are larger than
>> the contents of the other two.
>> I've appended short program that illustrates the problem. Just
>> starting the program will put it into an infinite loop. If you
>> replace paneMoved by paneMoved_workaround, the problem goes away.
>> Why doesn't blocking the signal work? Am I doing something wrong?
>> I've run this test on OS X with python 2.5, gtk 2.14.7, and pygtk
>> 2.12.1, and on Linux with python 2.4, gtk 2.8.20, and pygtk 2.8.6.
[ code deleted ]
> You have to allow the widgets to shrink - remove the "shrink=0" args
> from the pack1() and pack2() calls.
Thanks for the response, but what if I don't want the widgets to be
able to shrink? Is that possible? Why isn't calling handler_block
before calling set_position sufficient?
-- EMail: stephen.langer at nist.gov Phone: (301)
-- WWW: http://math.nist.gov/mcsd/Staff/SLanger/ Fax: (301)
-- Mail: NIST; 100 Bureau Drive -- Stop 8910; Gaithersburg, Md
-- "I don't think this will work. That's why it's
-- Naomi Langer (age 6), 17 Feb
More information about the pygtk