Treebook questions

Hi there, I was just trying to use the Treebook shown in the demo and
I've got a couple of questions... First, is it possible to have more
than two levels in your tree? If so, how?

Second, is it possible to change the width of the tree portion of the
tree book so that there's enough space if you have long names? And
along the same lines, is it possible to make it an adjustable pane or
automatically expand if you expand some of the list and it gets wider?

Thanks a lot,
Alex

Hi there, I was just trying to use the Treebook shown in the demo and
I've got a couple of questions... First, is it possible to have more
than two levels in your tree? If so, how?

No.

Second, is it possible to change the width of the tree portion of the
tree book so that there's enough space if you have long names? And
along the same lines, is it possible to make it an adjustable pane or
automatically expand if you expand some of the list and it gets wider?

It's not user adjustable, and I haven't been happy with how it chooses the initial size either. I would suggest using a wx.SpliterWindow with a tree on one side, and manage changing the "page" window yourself as items are selected in the tree.

···

On 2/19/10 2:44 PM, Alex S wrote:

--
Robin Dunn
Software Craftsman

Ok, thanks a lot I'll give that a try.

···

On Feb 20, 8:06 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 2/19/10 2:44 PM, Alex S wrote:

> Hi there, I was just trying to use the Treebook shown in the demo and
> I've got a couple of questions... First, is it possible to have more
> than two levels in your tree? If so, how?

No.

> Second, is it possible to change the width of the tree portion of the
> tree book so that there's enough space if you have long names? And
> along the same lines, is it possible to make it an adjustable pane or
> automatically expand if you expand some of the list and it gets wider?

It's not user adjustable, and I haven't been happy with how it chooses
the initial size either. I would suggest using a wx.SpliterWindow with
a tree on one side, and manage changing the "page" window yourself as
items are selected in the tree.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

Ok well I tried to make an equivalent, using sashwindows instead of a
splitter because I thought I might like to add more than two windows
at some point in the future. It kind of works, but when I get it to
change screens I get weird refresh errors. I've tried deleting the old
instances before calling it and refreshing stuff, but I still get
weird artifacts and it's like buttons on both of the frames exist when
I switch between them. Heres how I'm trying to do it:

    def ChangeScreen(self, selfText):
        if selfText == 'Property 1':
            print 'setting to property panel'
            del self.remainingSpace
            self.remainingSpace = PropertyPanel(self)
            wx.LayoutAlgorithm().LayoutWindow(self,
self.remainingSpace)
            self.remainingSpace.Refresh()
            self.leftwin.Refresh()

        if selfText == 'Company Name':
            print 'setting to Company panel'
            del self.remainingSpace
            self.remainingSpace = CompanyPanel(self)
            wx.LayoutAlgorithm().LayoutWindow(self,
self.remainingSpace)
            self.remainingSpace.Refresh()
            self.leftwin.Refresh()

This is still a test case, I have the tree control (in the left sash
frame) send the text of the item selected to this function which is
supposed to change the panel shown in the other sash frame (on the
right, called "remainingSpace").
It's pretty obvious this is not the right way to switch sash frames,
but I can't find the correct way...
Thanks a lot!

Alex

Sorry I guess you wouldn't know it from the code above, but ideally I
wouldn't be deleting and generating new panels each time I switched
the frame shown. I'd generate (but not show) a bunch of panels and
then show or hide them as required.

···

On Feb 22, 3:41 pm, Alex S <schmitt.happ...@gmail.com> wrote:

Ok well I tried to make an equivalent, using sashwindows instead of a
splitter because I thought I might like to add more than two windows
at some point in the future. It kind of works, but when I get it to
change screens I get weird refresh errors. I've tried deleting the old
instances before calling it and refreshing stuff, but I still get
weird artifacts and it's like buttons on both of the frames exist when
I switch between them. Heres how I'm trying to do it:

def ChangeScreen\(self, selfText\):
    if selfText == &#39;Property 1&#39;:
        print &#39;setting to property panel&#39;
        del self\.remainingSpace
        self\.remainingSpace = PropertyPanel\(self\)
        wx\.LayoutAlgorithm\(\)\.LayoutWindow\(self,

self.remainingSpace)
self.remainingSpace.Refresh()
self.leftwin.Refresh()

    if selfText == &#39;Company Name&#39;:
        print &#39;setting to Company panel&#39;
        del self\.remainingSpace
        self\.remainingSpace = CompanyPanel\(self\)
        wx\.LayoutAlgorithm\(\)\.LayoutWindow\(self,

self.remainingSpace)
self.remainingSpace.Refresh()
self.leftwin.Refresh()

This is still a test case, I have the tree control (in the left sash
frame) send the text of the item selected to this function which is
supposed to change the panel shown in the other sash frame (on the
right, called "remainingSpace").
It's pretty obvious this is not the right way to switch sash frames,
but I can't find the correct way...
Thanks a lot!

Alex

Python's del statement doesn't reduce the refcount all the way to zero so it won't actually destroy the widget. You need to explicitly call the Destroy() method.

···

On 2/22/10 2:41 PM, Alex S wrote:

Ok well I tried to make an equivalent, using sashwindows instead of a
splitter because I thought I might like to add more than two windows
at some point in the future. It kind of works, but when I get it to
change screens I get weird refresh errors. I've tried deleting the old
instances before calling it and refreshing stuff, but I still get
weird artifacts and it's like buttons on both of the frames exist when
I switch between them. Heres how I'm trying to do it:

     def ChangeScreen(self, selfText):
         if selfText == 'Property 1':
             print 'setting to property panel'
             del self.remainingSpace

--
Robin Dunn
Software Craftsman

Yes, this is much better. Try putting a single panel in the sash window, and make all your "page" windows be children of that panel. Add all of them to a sizer belonging to the panel, and Hide() all but one of them. When you want to switch Hide the one that is shown, SHow() the new one, and then call the panel's Layout method.

···

On 2/22/10 2:59 PM, Alex S wrote:

Sorry I guess you wouldn't know it from the code above, but ideally I
wouldn't be deleting and generating new panels each time I switched
the frame shown. I'd generate (but not show) a bunch of panels and
then show or hide them as required.

--
Robin Dunn
Software Craftsman

Great, it took a while but that worked! Thanks a lot.
Alex

···

On Feb 22, 7:25 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 2/22/10 2:59 PM, Alex S wrote:

> Sorry I guess you wouldn't know it from the code above, but ideally I
> wouldn't be deleting and generating new panels each time I switched
> the frame shown. I'd generate (but not show) a bunch of panels and
> then show or hide them as required.

Yes, this is much better. Try putting a single panel in the sash
window, and make all your "page" windows be children of that panel. Add
all of them to a sizer belonging to the panel, and Hide() all but one of
them. When you want to switch Hide the one that is shown, SHow() the
new one, and then call the panel's Layout method.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org