resize wxTreeCtrl to window size

Hi All,
My question is:
How can I resize wxTreeCtrl to window size, when window with wxTreeCtrl is resizing.

Thanks in advance for help ...

Leonid

Use a sizer or see the TreeCtrl demo.

Ricardo

···

On Mon, 2005-08-29 at 18:31 +0300, Leonid Shulov wrote:

Hi All,
My question is:
How can I resize wxTreeCtrl to window size, when window with wxTreeCtrl
is resizing.

My question is not so trivial.

Into wxFrame I put sizer and after that I divide it into two parts
with wxSplitterWindow.

class MyFrame(wx.wxFrame):

    def __init__(self):

        self.papa = self

        wx.wxFrame.__init__(self, wx.NULL, -1, 'Formating SubSet

FS’,

                wx.wxDefaultPosition, wx.wxSize(600,500))

        self.CreateStatusBar()

        self.SetStatusText("", 0)

        self.sizer = wx.wxBoxSizer(wx.wxVERTICAL)

        self.SetSizer(self.sizer)

        self.split = wx.wxSplitterWindow(self, -1)

        self.sizer.Add(self.split,1,wx.wxEXPAND,1)

        self.p1 = wx.wxWindow(self.split, -1)

        self.p2 = wx.wxWindow(self.split, -1)

        self.split.SplitVertically(self.p1, self.p2, 300)

Now I do rezing OK.

After that I put into each splittered Window wxTreeCtrl:

                . . . . . . . .

                self.treeSFS = pyTree1(self.p1, self.papa, -1,

Obj(self.dirSFS))

                self.treeFS   = pyTree2(self.p2, self.papa, -1,

Obj(self.dirFS))

                w1,h1 = self.p1.GetClientSizeTuple()

                self.treeSFS.SetDimensions(0, 0, w1, h1)

                w2,h2 = self.p2.GetClientSizeTuple()

                self.treeFS.SetDimensions(0, 0, w2, h2)

                . . . . . . . .

And now if I do rezing frame two my trees is not resized.

I tried with SetSizer, wx.EVT_SIZE but without any success.

I attached all files from my project


Thanks for your help!
Leonid

Ricardo Pedroso wrote:

AppTree.py (17.7 KB)

FileFrame.py (977 Bytes)

MarkedFiles.py (954 Bytes)

pyTree1.py (10.6 KB)

pyTree2.py (3.88 KB)

···
On Mon, 2005-08-29 at 18:31 +0300, Leonid Shulov wrote:
Hi All,
My question is:
How can I resize wxTreeCtrl to window size, when window with wxTreeCtrl is resizing.

Use a sizer or see the TreeCtrl demo.
Ricardo

Attached is a modified AppTree.py. I call it AppTree2.py so you can save
to your workspace without overwriting the original.

Basically what I did was to change the two wxWindows to wxPanels and
make two more sizers, one for each panel, then when the trees are
created I put them in the sizers.

See if works for you.

Ricardo

AppTree2.py (18.7 KB)

···

On Tue, 2005-08-30 at 17:49 +0300, Leonid Shulov wrote:

My question is not so trivial.
Into wxFrame I put sizer and after that I divide it into two parts
with wxSplitterWindow.

    class MyFrame(wx.wxFrame):
        def __init__(self):
            self.papa = self
            wx.wxFrame.__init__(self, wx.NULL, -1, 'Formating SubSet
FS',
                    wx.wxDefaultPosition, wx.wxSize(600,500))

            self.CreateStatusBar()
            self.SetStatusText("", 0)

            self.sizer = wx.wxBoxSizer(wx.wxVERTICAL)
            self.SetSizer(self.sizer)

            self.split = wx.wxSplitterWindow(self, -1)
            self.sizer.Add(self.split,1,wx.wxEXPAND,1)

            self.p1 = wx.wxWindow(self.split, -1)
            self.p2 = wx.wxWindow(self.split, -1)
            self.split.SplitVertically(self.p1, self.p2, 300)
  
Now I do rezing OK.

After that I put into each splittered Window wxTreeCtrl:
                    . . . . . . . .
                    self.treeSFS = pyTree1(self.p1, self.papa, -1,
Obj(self.dirSFS))
                    self.treeFS = pyTree2(self.p2, self.papa, -1,
Obj(self.dirFS))

                    w1,h1 = self.p1.GetClientSizeTuple()
                    self.treeSFS.SetDimensions(0, 0, w1, h1)
                    w2,h2 = self.p2.GetClientSizeTuple()
                    self.treeFS.SetDimensions(0, 0, w2, h2)
                    . . . . . . . .
And now if I do rezing frame two my trees is not resized.

I tried with SetSizer, wx.EVT_SIZE but without any success.

I attached all files from my project

Thanks for your help!

Leonid

Ricardo,

You are effectively doing what a sizer would do for you.

In your panel subclass, define a sizer, like so:

class TreePanel(wx.Panel):
   def __init__(self....):
      wx.Panel.__init__(self, .... )
      self.sizer = wx.BoxSizer(wx.VERTICAL)
      self.SetSizer(self.sizer)
      self.SetAutoLayout(1)
      self.sizer.SetSizeHints(self)

   def Add(self, *parms):
      self.sizer.Add(*parms)

In your main app, create your two panels, after instantiating the splitter.
      LeftPanel = TreePanel(self.split)
      LeftTree = PyTree1(LeftPanel, ..)
      LeftPanel.Add(LeftTree, 1, wx.EXPAND|wx.ALL, 0)
      RightPanel = TreePanel(self.split)
      RightTree = PyTree2(LeftPanel, ..)
      RightPanel.Add(RightTree, 1, wx.EXPAND|wx.ALL, 0)

# Not split vertically..

Hope this helps.

Thanks,
-Kartic

···

On 8/30/05, Ricardo Pedroso <ricardo.pedroso@netvisao.pt> wrote:

On Tue, 2005-08-30 at 17:49 +0300, Leonid Shulov wrote:
> My question is not so trivial.
> Into wxFrame I put sizer and after that I divide it into two parts
> with wxSplitterWindow.
>
> class MyFrame(wx.wxFrame):
> def __init__(self):
> self.papa = self
> wx.wxFrame.__init__(self, wx.NULL, -1, 'Formating SubSet
> FS',
> wx.wxDefaultPosition, wx.wxSize(600,500))
>
> self.CreateStatusBar()
> self.SetStatusText("", 0)
>
> self.sizer = wx.wxBoxSizer(wx.wxVERTICAL)
> self.SetSizer(self.sizer)
>
> self.split = wx.wxSplitterWindow(self, -1)
> self.sizer.Add(self.split,1,wx.wxEXPAND,1)
>
> self.p1 = wx.wxWindow(self.split, -1)
> self.p2 = wx.wxWindow(self.split, -1)
> self.split.SplitVertically(self.p1, self.p2, 300)
>
> Now I do rezing OK.
>
> After that I put into each splittered Window wxTreeCtrl:
> . . . . . . . .
> self.treeSFS = pyTree1(self.p1, self.papa, -1,
> Obj(self.dirSFS))
> self.treeFS = pyTree2(self.p2, self.papa, -1,
> Obj(self.dirFS))
>
> w1,h1 = self.p1.GetClientSizeTuple()
> self.treeSFS.SetDimensions(0, 0, w1, h1)
> w2,h2 = self.p2.GetClientSizeTuple()
> self.treeFS.SetDimensions(0, 0, w2, h2)
> . . . . . . . .
> And now if I do rezing frame two my trees is not resized.
>
> I tried with SetSizer, wx.EVT_SIZE but without any success.
>
> I attached all files from my project
>
>
> Thanks for your help!
>
> Leonid

Attached is a modified AppTree.py. I call it AppTree2.py so you can save
to your workspace without overwriting the original.

Basically what I did was to change the two wxWindows to wxPanels and
make two more sizers, one for each panel, then when the trees are
created I put them in the sizers.

See if works for you.

Ricardo

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

Hi Ricardo!

You are big!!!

Thank you

Leonid

Ricardo Pedroso wrote:

···

Attached is a modified AppTree.py. I call it AppTree2.py so you can save
to your workspace without overwriting the original.

Basically what I did was to change the two wxWindows to wxPanels and
make two more sizers, one for each panel, then when the trees are
created I put them in the sizers.

See if works for you.

Ricardo

Ooops... it should read RightTree = PyTree2(RightPanel, ..) and not
PyTree2(LeftPanel, ..)

And # now split vertically..

:slight_smile:

···

On 8/30/05, Kartic Krish <kartic0@gmail.com> wrote:

Ricardo,

You are effectively doing what a sizer would do for you.

In your panel subclass, define a sizer, like so:

class TreePanel(wx.Panel):
   def __init__(self....):
      wx.Panel.__init__(self, .... )
      self.sizer = wx.BoxSizer(wx.VERTICAL)
      self.SetSizer(self.sizer)
      self.SetAutoLayout(1)
      self.sizer.SetSizeHints(self)

   def Add(self, *parms):
      self.sizer.Add(*parms)

In your main app, create your two panels, after instantiating the splitter.
      LeftPanel = TreePanel(self.split)
      LeftTree = PyTree1(LeftPanel, ..)
      LeftPanel.Add(LeftTree, 1, wx.EXPAND|wx.ALL, 0)
      RightPanel = TreePanel(self.split)
      RightTree = PyTree2(LeftPanel, ..)
      RightPanel.Add(RightTree, 1, wx.EXPAND|wx.ALL, 0)

# Not split vertically..

Hope this helps.

Thanks,
-Kartic

On 8/30/05, Ricardo Pedroso <ricardo.pedroso@netvisao.pt> wrote:
> On Tue, 2005-08-30 at 17:49 +0300, Leonid Shulov wrote:
> > My question is not so trivial.
> > Into wxFrame I put sizer and after that I divide it into two parts
> > with wxSplitterWindow.
> >
> > class MyFrame(wx.wxFrame):
> > def __init__(self):
> > self.papa = self
> > wx.wxFrame.__init__(self, wx.NULL, -1, 'Formating SubSet
> > FS',
> > wx.wxDefaultPosition, wx.wxSize(600,500))
> >
> > self.CreateStatusBar()
> > self.SetStatusText("", 0)
> >
> > self.sizer = wx.wxBoxSizer(wx.wxVERTICAL)
> > self.SetSizer(self.sizer)
> >
> > self.split = wx.wxSplitterWindow(self, -1)
> > self.sizer.Add(self.split,1,wx.wxEXPAND,1)
> >
> > self.p1 = wx.wxWindow(self.split, -1)
> > self.p2 = wx.wxWindow(self.split, -1)
> > self.split.SplitVertically(self.p1, self.p2, 300)
> >
> > Now I do rezing OK.
> >
> > After that I put into each splittered Window wxTreeCtrl:
> > . . . . . . . .
> > self.treeSFS = pyTree1(self.p1, self.papa, -1,
> > Obj(self.dirSFS))
> > self.treeFS = pyTree2(self.p2, self.papa, -1,
> > Obj(self.dirFS))
> >
> > w1,h1 = self.p1.GetClientSizeTuple()
> > self.treeSFS.SetDimensions(0, 0, w1, h1)
> > w2,h2 = self.p2.GetClientSizeTuple()
> > self.treeFS.SetDimensions(0, 0, w2, h2)
> > . . . . . . . .
> > And now if I do rezing frame two my trees is not resized.
> >
> > I tried with SetSizer, wx.EVT_SIZE but without any success.
> >
> > I attached all files from my project
> >
> >
> > Thanks for your help!
> >
> > Leonid
>
> Attached is a modified AppTree.py. I call it AppTree2.py so you can save
> to your workspace without overwriting the original.
>
> Basically what I did was to change the two wxWindows to wxPanels and
> make two more sizers, one for each panel, then when the trees are
> created I put them in the sizers.
>
> See if works for you.
>
> Ricardo
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>
>
>