wx.lib.customtreectrl wnd=panel

Hi,

To my best guess there is something wrong using panels with
CustomTreeCtrl. I played a bit with it, the gauge is not displayed
inside the panel correctly, but the gauge can be made a child of the
CustomTreeCtrl without problems..

I think Andrea will have to take it from here, I see nothing wrong
fundamentally with your code..

- Jorgen

···

On 5/4/07, Zac Burns <zac256@gmail.com> wrote:

Greetings, I can't seem to get a control to show up as a child of a panel in
a CustomTreeCtrl. You can follow a small conversation about it here
http://wxforum.shadonet.com/viewtopic.php?p=62328#62328 .
To sum it up they believed that it may be a parenting problem.

Below is a sample app demonstrating the problem. The important code is in
customTreeCtrlTest.AddItems(). There you can see that I'm trying to add 2
gauges to a panel and have both gauges be visible next to each other in the
tree.

I am using WindowsXP:SP2, Python2.5, and wx-2.8-msw-unicode.

If any of you can point me to the problem below that would be much
appreciated.

--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Technical Artist(Digital Overlord, melGuru)
Kush Games

// BEGIN SAMPLE CODE
import wx
import wx.lib.customtreectrl as CustomTreeCtrl

class customTreeCtrlTest(CustomTreeCtrl.CustomTreeCtrl):
    def __init__(self, parent, id= wx.ID_ANY, pos=wx.DefaultPosition,
             size=wx.DefaultSize,
             style=wx.SUNKEN_BORDER,
             ctstyle=CustomTreeCtrl.TR_HAS_BUTTONS
             >CustomTreeCtrl.TR_HAS_VARIABLE_ROW_HEIGHT,
             log=None):

        CustomTreeCtrl.CustomTreeCtrl.__init__(self,
parent, id, pos, size, style, ctstyle)

    def AddItems(self):
        self.root = self.AddRoot("The Root Item")
         self.root.Expand()

        panel = wx.Panel(self, -1)

        element = wx.Gauge(panel, -1, 100,
style=wx.GA_HORIZONTAL|wx.GA_SMOOTH)
        element2 = wx.Gauge(panel, -1, 100,
style=wx.GA_HORIZONTAL|wx.GA_SMOOTH )

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(element, -1, wx.EXPAND)
        sizer.Add(element2, -1, wx.EXPAND)
        panel.SetSizer(sizer)
        sizer.Layout()

        self.AppendItem (self.root, "test", wnd=panel)

def test():
    class customTreeCtrlTestFrame(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, -1, "Demo", size = (950, 720),
                style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)

            panel = wx.Panel(self, -1)

            sizer = wx.BoxSizer(wx.VERTICAL)
            self.tree = customTreeCtrlTest(panel, -1)
            self.tree.AddItems()

            sizer.Add(self.tree, 1, wx.EXPAND)
            panel.SetSizer(sizer)
            sizer.Layout()

    app = wx.PySimpleApp()
    frame = customTreeCtrlTestFrame()
    frame.Show()
    app.MainLoop()

test()

// END SAMPLE CODE

Thanks, this is the fastest response I have ever gotten from any mailing list.

SetSizer and fit did the trick. To respond to Andrea’s question about what the -1 was for, I have no idea. I’ve only been using wx for a few days. It’s nothing.

···

On 5/4/07, Andrea Gavana andrea.gavana@gmail.com wrote:

Hi All,

On 5/4/07, Jorgen Bodde wrote:

To my best guess there is something wrong using panels with
CustomTreeCtrl. I played a bit with it, the gauge is not displayed
inside the panel correctly, but the gauge can be made a child of the

CustomTreeCtrl without problems…

I think Andrea will have to take it from here, I see nothing wrong
fundamentally with your code…

Robin’s answer is what the OP needs: just call SetSizerAndFit on the

panel and you’ll see the 2 gauges correctly displayed. This works for
me on 2.8.4 pre-release. I noticed however something strange in the
sizer code:

    sizer = wx.BoxSizer(wx.HORIZONTAL)

sizer.Add(element, -1, wx.EXPAND)
sizer.Add(element2, -1, wx.EXPAND)

What is “-1” supposed to do on the expand flag? I have no idea, I
always used either 0 or 1 for that flag. But it doesn’t matter, as

long as you compose your widget correctly, you can really add
whatever you want inside CustomTreeCtrl next to an item (except TLWs
of course).

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”

http://xoomer.virgilio.it/infinity77/


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


Zachary Burns
(407)590-4814
Aim - Zac256FL
Technical Artist(Digital Overlord, melGuru)
Kush Games

Hi Zac,

···

On 5/4/07, Zac Burns wrote:

Thanks, this is the fastest response I have ever gotten from any mailing
list.

You'd better get used to receive fast answers on this mailing list :smiley: :smiley:

Andrea.

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