What can be displayed inside a wx.Panel ?

Hi,

I have two wxPython scripts.

One is displaying its data in a wx.SplitterWindows composed of three wx.Panels.

The other is displaying it’s data in a wx.Frame.

I want to merge the two scripts into one.

The problem is that the second script is using a subclass of wx.Frame for display (ListControl).
When I try to merge the two scripts (see below a demo, line 25 is of interest),
the frame won’t display inside the panel, but will be an autonomic window (with the OS desktop as its parent).

I have a specific and a general wxPython questions:

  1. What can I change in the demo below, to get ListControl (line 25) to display in self.window_2_pane_1 as its parent ?
  2. Where can I find which widgets may be created/displayed inside a wx.Panel (googled, but could not find the answer) ?
    Thanks,

Ron.

$ cat -n tmp.py
1 #!/usr/bin/env python
2
3 import wx
4 import wx.grid
5 import sys
6
7 class ListControl(wx.Frame):
8
9 def init(self, parent, id, title):
10 wx.Frame.init(self,parent,id,title)
11 wx.CallLater(100, self.Raise)
12 self.Show(True)
13
14 class MyFrame(wx.Frame):
15 def init(self, *args, **kwds):
16 wx.Frame.init(self, *args, **kwds)
17 self.window_1 = wx.SplitterWindow(self, -1)
18 self.window_1_pane_2 = wx.Panel(self.window_1, -1)
19 self.window_2 = wx.SplitterWindow(self.window_1_pane_2, -1)
20 self.window_2_pane_2 = wx.Panel(self.window_2, -1)
21 self.window_2_pane_1 = wx.Panel(self.window_2, -1)
22 self.window_1_pane_1 = wx.Panel(self.window_1, -1)
23 self.TreeView = wx.TreeCtrl(self.window_1_pane_1, -1)
24
25 self.TableView = ListControl(self.window_2_pane_1, -1, “I am ListControl”)
26
27 self.InspectorView = wx.grid.Grid(self.window_2_pane_2, -1, size=(1, 1))
28 self.tablecont = wx.StaticText(self.window_2_pane_2, -1, “”)
29 self.__do_layout()
30
31 def __do_layout(self):
32 object_1 = wx.BoxSizer(wx.VERTICAL)
33 object_3 = wx.BoxSizer(wx.VERTICAL)
34 object_5 = wx.BoxSizer(wx.VERTICAL)
35 object_4 = wx.BoxSizer(wx.VERTICAL)
36 object_2 = wx.BoxSizer(wx.HORIZONTAL)
37 object_2.Add(self.TreeView, 1, wx.RIGHT|wx.EXPAND, 0)
38 self.window_1_pane_1.SetSizer(object_2)
39 object_4.Add(self.TableView, 1, wx.EXPAND, 0)
40 self.window_2_pane_1.SetSizer(object_4)
41 object_5.Add(self.InspectorView, 1, wx.EXPAND, 0)
42 object_5.Add(self.tablecont, 0, wx.ALL, 3)
43 self.window_2_pane_2.SetSizer(object_5)
44 self.window_2.SplitHorizontally(self.window_2_pane_1, self.window_2_pane_2, 400)
45 object_3.Add(self.window_2, 1, wx.EXPAND, 0)
46 self.window_1_pane_2.SetSizer(object_3)
47 self.window_1.SplitVertically(self.window_1_pane_1, self.window_1_pane_2, 190)
48 object_1.Add(self.window_1, 1, wx.EXPAND, 0)
49 self.SetSizer(object_1)
50 self.Layout()
51 self.SetSize((900, 500))
52
53 if name == “main”:
54 app = wx.PySimpleApp(0)
55 svm5parser = MyFrame(None, -1, “”)
56 app.SetTopWindow(svm5parser)
57 svm5parser.Show()
58 app.MainLoop()

$ cat tmp.py
#!/usr/bin/env python

import wx
import wx.grid
import sys

class ListControl(wx.Frame):

def __init__(self, parent, id, title):
    wx.Frame.__init__(self,parent,id,title)
    wx.CallLater(100, self.Raise)
    self.Show(True)

class MyFrame(wx.Frame):
def init(self, *args, **kwds):
wx.Frame.init(self, *args, **kwds)
self.window_1 = wx.SplitterWindow(self, -1)
self.window_1_pane_2 = wx.Panel(self.window_1, -1)
self.window_2 = wx.SplitterWindow(self.window_1_pane_2, -1)
self.window_2_pane_2 = wx.Panel(self.window_2, -1)
self.window_2_pane_1 = wx.Panel(self.window_2, -1)
self.window_1_pane_1 = wx.Panel(self.window_1, -1)
self.TreeView = wx.TreeCtrl(self.window_1_pane_1, -1)

    self.TableView = ListControl(self.window_2_pane_1, -1, "I am ListControl")

    self.InspectorView = wx.grid.Grid(self.window_2_pane_2, -1, size=(1, 1))
    self.tablecont = wx.StaticText(self.window_2_pane_2, -1, "")
    self.__do_layout()

def __do_layout(self):
    object_1 = wx.BoxSizer(wx.VERTICAL)
    object_3 = wx.BoxSizer(wx.VERTICAL)
    object_5 = wx.BoxSizer(wx.VERTICAL)
    object_4 = wx.BoxSizer(wx.VERTICAL)
    object_2 = wx.BoxSizer(wx.HORIZONTAL)
    object_2.Add(self.TreeView, 1, wx.RIGHT|wx.EXPAND, 0)
    self.window_1_pane_1.SetSizer(object_2)
    object_4.Add(self.TableView, 1, wx.EXPAND, 0)
    self.window_2_pane_1.SetSizer(object_4)
    object_5.Add(self.InspectorView, 1, wx.EXPAND, 0)
    object_5.Add(self.tablecont, 0, wx.ALL, 3)
    self.window_2_pane_2.SetSizer(object_5)
    self.window_2.SplitHorizontally(self.window_2_pane_1, self.window_2_pane_2, 400)
    object_3.Add(self.window_2, 1, wx.EXPAND, 0)
    self.window_1_pane_2.SetSizer(object_3)
    self.window_1.SplitVertically(self.window_1_pane_1, self.window_1_pane_2, 190)
    object_1.Add(self.window_1, 1, wx.EXPAND, 0)
    self.SetSizer(object_1)
    self.Layout()
    self.SetSize((900, 500))

if name == “main”:
app = wx.PySimpleApp(0)
svm5parser = MyFrame(None, -1, “”)
app.SetTopWindow(svm5parser)
svm5parser.Show()
app.MainLoop()

Hello,

Hi,

I have two wxPython scripts.

One is displaying its data in a wx.SplitterWindows composed of three wx.Panels.

The other is displaying it’s data in a wx.Frame.

I want to merge the two scripts into one.

The problem is that the second script is using a subclass of wx.Frame for display (ListControl).
When I try to merge the two scripts (see below a demo, line 25 is of interest),
the frame won’t display inside the panel, but will be an autonomic window (with the OS desktop as its parent).

I have a specific and a general wxPython questions:

  1. What can I change in the demo below, to get ListControl (line 25) to display in self.window_2_pane_1 as its parent ?

A Frame is a top level window it can’t be ‘inside’ of a panel, it can be the child of a panel though. You are probably thinking about MDI, there are examples of MDI in the demo application.

  1. Where can I find which widgets may be created/displayed inside a wx.Panel (googled, but could not find the answer) ?

Any widget can be displayed in a Panel. A frame is a top level container, not really a widget like checkbox or button.

p.s) please use plain text emails (or at the very least use regular black text). I usually instantly hit the delete key when I see email like this, and am probably not the only one that does that, so you may be missing out on some potential replies.

Cody

···

On May 27, 2009, at 5:26 AM, Barak, Ron wrote: