(newbie) problems with using splitter window within a notebook

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()

Andre Roberge wrote:

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.

################# 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')

The ScrolledWindow does not know that you want the spilitter to fill it, so it leaves it at the default size and position. Why use the ScrolledWindow at all, you don't specify a virtual size so it isn't going to be larger than the notebook client area anyway. Try using just the splitter as the notebook page.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!