trouble stealing wx.splitter code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eric dexter
    New Member
    • Sep 2006
    • 46

    trouble stealing wx.splitter code

    I am trying to steal this code from the wxpython demo but it appears that mb comes from nowhere and I am having errors because of it

    Code:
    import  wx
    
    #---------------------------------------------------------------------------
    
    class MySplitter(wx.SplitterWindow):
        def __init__(self, parent, ID, log):
            wx.SplitterWindow.__init__(self, parent, ID,
                                       style = wx.SP_LIVE_UPDATE
                                       )
            self.log = log
            
            self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChanged)
            self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChanging)
    
        def OnSashChanged(self, evt):
            self.log.WriteText("sash changed to %s\n" % str(evt.GetSashPosition()))
    
        def OnSashChanging(self, evt):
            self.log.WriteText("sash changing to %s\n" % str(evt.GetSashPosition()))
            # uncomment this to not allow the change
            #evt.SetSashPosition(-1)
    
    
    #---------------------------------------------------------------------------
    
    def runTest(frame, nb, log):
        splitter = MySplitter(nb, -1, log)
    
        #sty = wx.BORDER_NONE
        #sty = wx.BORDER_SIMPLE
        sty = wx.BORDER_SUNKE
        
        p1 = wx.Window(splitter, style=sty)
        p1.SetBackgroundColour("pink")
        wx.StaticText(p1, -1, "Panel One", (5,5))
    
        p2 = wx.Window(splitter, style=sty)
        p2.SetBackgroundColour("sky blue")
        wx.StaticText(p2, -1, "Panel Two", (5,5))
    
        splitter.SetMinimumPaneSize(20)
        splitter.SplitVertically(p1, p2, -100)
    
        return splitter
    
    
    #---------------------------------------------------------------------------
    
    
    overview = """\
    This class manages up to two subwindows. The current view can be split
    into two programmatically (perhaps from a menu command), and unsplit
    either programmatically or via the wx.SplitterWindow user interface.
    """
    
    if __name__ == '__main__':
        import sys,os
        import run
        run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
    File "C:\Python2 5\wx-2.6-msw-ansi\wx\_window s.py", line 1013, in __init__
    newobj = _windows_.new_S plitterWindow(* args, **kwargs)
    TypeError: argument number 1: a 'wxWindow *' is expected, 'int(-1)' is received
  • eric dexter
    New Member
    • Sep 2006
    • 46

    #2
    to extend and revise it is in the run test code. When I try to cut and paste this where would I get the value from??

    Comment

    • eric dexter
      New Member
      • Sep 2006
      • 46

      #3
      Here is what I was wanting to split in two (I don't know that I need a splitter but I have buttons that go one under the other and when I change that I get wierd glitches)

      Code:
      ):
      
              wx.Frame.__init__(self, parent, -1, "Dex Tracker Score Editor", size=(640,480))
              p = wx.Panel(self, -1, style=0)
              self.grid = WordGrid(p, log)
              b = wx.Button(p, -1, "Save Grid")            #b gets numbered per button and then description set
              b2 = wx.Button(p, 100, "Add Line")
              b3 = wx.Button(p, -1, "Insert Line")
              b4 = wx.Button(p, -1, "Delete Line")
              b5 = wx.Button(p, -1, "Play from line to line")
              
              b.SetDefault()
              self.Bind(wx.EVT_BUTTON, self.OnButton, b)    #bind to the button I am numbering them
              self.Bind(wx.EVT_BUTTON, self.OnButton2, b2)
              self.Bind(wx.EVT_BUTTON, self.OnButton3, b3)
              self.Bind(wx.EVT_BUTTON, self.OnButton4, b4)
              self.Bind(wx.EVT_BUTTON, self.OnButton5, b5)
              b.Bind(wx.EVT_SET_FOCUS, self.OnButtonFocus)  #bind button focus if needed
              #bs = wx.BoxSizer(wx.ALIGN_BOTTOM)
              #bs = wx.StaticBoxSizer(wx.
              bs = wx.BoxSizer(wx.HORIZONTAL)#(wx.VERTICAL)#|wx.ALIGN_BOTTOM)   #(wx.HORIZONTAL_HATCH)   #(wx.VERTICAL)
              #bs.Add(self.grid, 1, wx.GROW|wx.ALL, 5)
              bs.Add(b)                                     #add the button here numbered in par
              bs.Add(b2)
              bs.Add(b3)
              bs.Add(b4)
              bs.Add(b5)
              #p.placed
              bs = wx.BoxSizer(wx.VERTICAL)
              bs.Add(self.grid, 1, wx.GROW|wx.ALL, 5)
              p.SetSizer(bs)

      Comment

      Working...