I'm trying to display side by side two "windows" within a notebook
page. The window on the right is a ScrolledWindow that is used to
display some graphics; the left one will be used
to display some text.
I got this to work (see World.py) as expected when it is NOT within a
notebook page, but in a single Frame, when I execute World.py by
itself.
When I try to do it in a Notebook page (see myNotebook.py), I can't
get it to work at all.
I've extracted the relevant parts of the programs below.
Any help would be appreciated!
André
## This works as expected #########################
# World.py
class World(wx.ScrolledWindow):
def __init__(self, parent, id = -1, size = wx.DefaultSize):
wx.ScrolledWindow.__init__(self, parent, id, (0, 0),
size=size, style=wx.SUNKEN_BORDER)
[stuff deleted]
···
#---------------------------------------------------------------------------
class worldParent(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "World", size=(600, 400),
style=wx.DEFAULT_FRAME_STYLE |
wx.NO_FULL_REPAINT_ON_RESIZE)
# that's it !
#----------------------------------------------------------------------
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = worldParent(None)
splitter = wx.SplitterWindow(frame, -1)
p1 = wx.Panel(splitter, -1)
wx.StaticText(p1, -1, "for program display", (5,5))
p2 = World(splitter, -1)
splitter.SetMinimumPaneSize(20)
splitter.SplitVertically(p1, p2, 100)
frame.Show(True)
app.MainLoop()
################# This doesn't work #################################
# myNotebook.py
from world import World, worldParent
class myNotebook(wx.Notebook):
def __init__(self, parent, id):
wx.Notebook.__init__(self, parent, id)
#=== this first notebook page doesn't display properly
win = wx.ScrolledWindow(self)
splitter = wx.SplitterWindow(win, -1)
p1 = wx.Window(splitter, -1)
wx.StaticText(p1, -1, "for program display", (5,5))
p2 = World(splitter, -1)
splitter.SetMinimumPaneSize(100)
splitter.SplitVertically(p1, p2, 100)
self.AddPage(win, 'splitted window')
#=== this one does, but it is not a splitted one.
win = World(self)
self.AddPage(win, 'World only')
#----------------------------------------------------------
class myApp(wx.App):
def OnInit(self):
frame = wx.Frame(None, -1, "Python learning environment",
pos=(10,10), size=(400,300),
style=wx.DEFAULT_FRAME_STYLE)
frame.CreateStatusBar()
frame.Show(True)
win = myNotebook(frame, -1)
frame.SetSize((640, 480))
win.SetFocus()
self.window = win
frect = frame.GetRect()
self.SetTopWindow(frame)
self.frame = frame
return True
if __name__ == "__main__":
app = myApp()
app.MainLoop()