SashLayoutWindow problem

hello ML,
I can't get the grid in the left side of the wx.MDIChildFrame displayed correctly (see code below). It all works fine if I use a wx.Frame instead. Where am I going wrong?

thanks in advance for an answer

Marco

···

#---------------------------------------------------------------------------

import wx
import wx.grid

class MyChildFrame(wx.MDIChildFrame):

    def __init__(self):
        wx.MDIChildFrame.__init__(self, parent, -1, "Child Window: %d" %
                                    count)

        winids = []

        # A window to the left of the client window
        leftwin1 = wx.SashLayoutWindow(
                self, -1, wx.DefaultPosition, (200, 30),
                wx.NO_BORDER|wx.SW_3D
                )

        leftwin1.SetDefaultSize((120, 1000))
        leftwin1.SetOrientation(wx.LAYOUT_VERTICAL)
        leftwin1.SetAlignment(wx.LAYOUT_LEFT)
        leftwin1.SetBackgroundColour(wx.Colour(0, 255, 0))
        leftwin1.SetSashVisible(wx.SASH_RIGHT, True)
        textWindow = wx.grid.Grid(leftwin1)
        textWindow.CreateGrid(40,10)

        self.leftWindow1 = leftwin1
        winids.append(leftwin1.GetId())

        # will occupy the space not used by the Layout Algorithm
        self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)

        self.Bind(
            wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag,
            id=min(winids), id2=max(winids)
            )

        self.Bind(wx.EVT_SIZE, self.OnSize)

    def OnSashDrag(self, event):
        if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
            return

        eobj = event.GetEventObject()

        if eobj is self.leftWindow1:
            self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000))

        wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)
        self.remainingSpace.Refresh()

    def OnSize(self, event):
        wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)

class MyParentFrame(wx.MDIParentFrame):
    def __init__(self):
        wx.MDIParentFrame.__init__(self, None, -1, "MDI Parent", size=(600,400))

        self.winCount = 0
        menu = wx.Menu()
        menu.Append(ID_New, "&New Window")
        menu.AppendSeparator()
        menu.Append(ID_Exit, "E&xit")

        menubar = wx.MenuBar()
        menubar.Append(menu, "&File")
        self.SetMenuBar(menubar)

        self.CreateStatusBar()

        self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ID_New)
        self.Bind(wx.EVT_MENU, self.OnExit, id=ID_Exit)

    def OnExit(self, evt):
        self.Close(True)

    def OnNewWindow(self, evt):
        self.winCount = self.winCount + 1
        win = MyChildFrame(self, self.winCount)
        win.Show(True)

if __name__ == '__main__':
    app = wx.PySimpleApp()
    wx.InitAllImageHandlers()
    frame = MyParentFrame()
    frame.Show(True)
    app.SetTopWindow(frame)
    app.MainLoop()

____________________________________________________________
6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di Libero!
Scaricalo su INTERNET GRATIS 6X http://www.libero.it

Getting the call parameters can be somewhat of a PITA. See below.

Ray

hello ML,
I can't get the grid in the left side of the wx.MDIChildFrame displayed correctly (see code below). It all works fine if I use a wx.Frame instead. Where am I going wrong?

thanks in advance for an answer

Marco

#---------------------------------------------------------------------------

import wx
import wx.grid

class MyChildFrame(wx.MDIChildFrame):

   def __init__(self):

    def __init__ (self, parent, count):

···

m.prosperi@libero.it wrote:

       wx.MDIChildFrame.__init__(self, parent, -1, "Child Window: %d" %
                                   count)

       winids =

       # A window to the left of the client window
       leftwin1 = wx.SashLayoutWindow(
               self, -1, wx.DefaultPosition, (200, 30), wx.NO_BORDER|wx.SW_3D
               )

       leftwin1.SetDefaultSize((120, 1000))
       leftwin1.SetOrientation(wx.LAYOUT_VERTICAL)
       leftwin1.SetAlignment(wx.LAYOUT_LEFT)
       leftwin1.SetBackgroundColour(wx.Colour(0, 255, 0))
       leftwin1.SetSashVisible(wx.SASH_RIGHT, True)
       textWindow = wx.grid.Grid(leftwin1)
       textWindow.CreateGrid(40,10)

       self.leftWindow1 = leftwin1
       winids.append(leftwin1.GetId())

       # will occupy the space not used by the Layout Algorithm
       self.remainingSpace = wx.Panel(self, -1, style=wx.SUNKEN_BORDER)

       self.Bind(
           wx.EVT_SASH_DRAGGED_RANGE, self.OnSashDrag,
           id=min(winids), id2=max(winids)
           )

       self.Bind(wx.EVT_SIZE, self.OnSize)

   def OnSashDrag(self, event):
       if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
           return

       eobj = event.GetEventObject()

       if eobj is self.leftWindow1:
           self.leftWindow1.SetDefaultSize((event.GetDragRect().width, 1000))

       wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)

       self.remainingSpace.Refresh()

   def OnSize(self, event):
       wx.LayoutAlgorithm().LayoutWindow(self, self.remainingSpace)

class MyParentFrame(wx.MDIParentFrame):
   def __init__(self):
       wx.MDIParentFrame.__init__(self, None, -1, "MDI Parent", size=(600,400))

       self.winCount = 0
       menu = wx.Menu()
       menu.Append(ID_New, "&New Window")
       menu.AppendSeparator()
       menu.Append(ID_Exit, "E&xit")

       menubar = wx.MenuBar()
       menubar.Append(menu, "&File")
       self.SetMenuBar(menubar)

       self.CreateStatusBar()

       self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ID_New)
       self.Bind(wx.EVT_MENU, self.OnExit, id=ID_Exit)

   def OnExit(self, evt):
       self.Close(True)

   def OnNewWindow(self, evt):
       self.winCount = self.winCount + 1

       win = MyChildFrame(self, self.winCount)
       win.Show(True)

if __name__ == '__main__':
   app = wx.PySimpleApp()
   wx.InitAllImageHandlers()
   frame = MyParentFrame()
   frame.Show(True)
   app.SetTopWindow(frame)
   app.MainLoop()

____________________________________________________________
6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di Libero!
Scaricalo su INTERNET GRATIS 6X http://www.libero.it

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

Please describe what you mean by displayed correctly. Once I correct the NammeErrors and TypeErrors in your code it appears to work exactly the way the code is written. You should also mention the platform and version that you are using.

···

m.prosperi@libero.it wrote:

hello ML,
I can't get the grid in the left side of the wx.MDIChildFrame displayed correctly (see code below). It all works fine if I use a wx.Frame instead. Where am I going wrong?

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