Scrollbar help with DynamicSashWindow

I'm using a DSW to present multiple views of a tree. The DSW has it's own scrollbars.
Currently as the length of the tree increases, the TreeCtrl puts up it's own scrollbars, So I have
two scrollbars on the rhs.

I know DSW's have scrollbar events as in the demo. What I don't understand is how
to hook up the DSW scrollbars to the TreeCtrl.

For the demo, the operative lines are:
self.SetVScrollBar(v_bar)
self.SetHScrollBar(h_bar)

But there are no Set[V|H]ScrollBar methods for a TreeCtrl. For a TreeCtrl there is
a SetScrollbar method, but that just changes the position, not the window.

So, I'm stuck. What am I supposed to do?

Thanks,
Danny

Danny Shevitz wrote:

I'm using a DSW to present multiple views of a tree. The DSW has it's own scrollbars.
Currently as the length of the tree increases, the TreeCtrl puts up it's own scrollbars, So I have
two scrollbars on the rhs.

I know DSW's have scrollbar events as in the demo. What I don't understand is how
to hook up the DSW scrollbars to the TreeCtrl.

For the demo, the operative lines are:
self.SetVScrollBar(v_bar)
self.SetHScrollBar(h_bar)

But there are no Set[V|H]ScrollBar methods for a TreeCtrl. For a TreeCtrl there is
a SetScrollbar method, but that just changes the position, not the window.

So, I'm stuck. What am I supposed to do?

You could try making the TreeCtrls large enough that they don't need to display their scrollbars, and then respond to the scroll events from the DSW by moving the tree widgets such that the portion that is visible (not clipped by their parent) corresponds to the scrollbar positions. I think I would approach it by using a custom panel to hold the treectrl and manage sizing it and positioning it. You can then give it Set[V|H]ScrollBar methods like STC so it can hook itself up to the DSW's scrollbars.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

let me see if I understand your response.

Instead of putting the TreeCtrl inside each window created by the DSW,
I should put a panel in each window. If the panel is large enough to hold the tree, then the panel gets clipped but the
TreeCtrl newer needs to draw it's own scroll bars. At that point I use the DSW scrollbars to move the panel around.
Is this right?

D

···

At 12:40 PM 3/2/2007 -0800, you wrote:

Danny Shevitz wrote:

I'm using a DSW to present multiple views of a tree. The DSW has it's own scrollbars.
Currently as the length of the tree increases, the TreeCtrl puts up it's own scrollbars, So I have
two scrollbars on the rhs.
I know DSW's have scrollbar events as in the demo. What I don't understand is how
to hook up the DSW scrollbars to the TreeCtrl.
For the demo, the operative lines are:
self.SetVScrollBar(v_bar)
self.SetHScrollBar(h_bar)
But there are no Set[V|H]ScrollBar methods for a TreeCtrl. For a TreeCtrl there is
a SetScrollbar method, but that just changes the position, not the window.
So, I'm stuck. What am I supposed to do?

You could try making the TreeCtrls large enough that they don't need to display their scrollbars, and then respond to the scroll events from the DSW by moving the tree widgets such that the portion that is visible (not clipped by their parent) corresponds to the scrollbar positions. I think I would approach it by using a custom panel to hold the treectrl and manage sizing it and positioning it. You can then give it Set[V|H]ScrollBar methods like STC so it can hook itself up to the DSW's scrollbars.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi Danny,

Time for the next question. I have now put the TreeCtrl in a Panel. The
size of the TreeCtrl is fixed, and the panel
is sized to fit. The problem is that the trees can grow arbitrarily large.
Is there a way to dynamically resize the
tree/panel so that the tree fits itself without it's own scrollbar. I tried
looking at
GetVirtualSize, GetBestSize,GetBestVirtualSize,GetEffectiveMinSize, etc.for
the tree to find what
virtual size it should be, but none of these methods seem to work.

In summary, is there a dynamic way to find the virtual size of the tree, so
that I can update the physical size
to always be the same size? Would I need to re-Fit the Panel after this
operation?

If I understand your question correctly, you could try the attached
file. Every time you expand/collapse a node, if the size of the
longest item does not fit (or it has too much space), the treectrl is
resized accordingly to avoid the horizontal scrollbars. The attached
file uses a splitterwindow to place the treectrl but it should be
trivial to use a panel + sizer + treectrl.
And, yes, try to call sizer.Layout() or panel.Layout() or
yourframe.SendSizeEvent() (as a last resource) to layout your
panel/tree configuration.

Hope this helps.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

prova74.py (4.14 KB)

···

On 3/22/07, Danny Shevitz wrote:

Hi Danny,

Now what do I do with the panel. In the above code, I tried p.Fit(), but
either the
panel isn't actually resizing, or else the scrollbars on the DSW don't
reflect the size change.

If your treectrl is inside a sizer, have you tried something like:

theSizer.Layout()

Or even:

MainFrame.SendSizeEvent()

?

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

···

On 3/23/07, Danny Shevitz wrote: