derive a class from wx.grid.Grid and use it in xrc,but it does not work

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

derive a class from wx.grid.Grid and use it in xrc,but it does not work

m.reg380
hi
i derive a class from wx.grid.Grid and use it in xrc,but it does not work,
part of the xrc file:

<object class="wxGrid" name="grd" subclass="nova_gridx.Gridx">
     <size>200,150</size>
    <style>wxSTATIC_BORDER|wxWANTS_CHARS|wxHSCROLL|wxVSCROLL</style>
</object>

and the class code:

class Gridx(wx.grid.Grid):
    def __init__(self):
        wx.grid.Grid.__init__(self)
        self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate)
        self.Bind(wx.EVT_SIZE,self.OnSize)

    def OnCreate(self,evt):
        if self is evt.GetEventObject():
            self.Unbind(wx.EVT_WINDOW_CREATE)
            self.setViewStyle()
            wx.CallAfter(self.OnSize, None)
        evt.Skip()

    def OnSize(self,evt):
        self.Unbind(wx.EVT_SIZE)
        pass

    def setViewStyle(self):
        self.SetDefaultCellAlignment(wx.ALIGN_LEFT,wx.ALIGN_CENTRE)
        self.SetDefaultRowSize(30)
        self.DisableDragRowSize()
        self.HideRowLabels()
        self.EnableEditing(False)
        self.SetCellHighlightPenWidth(0)

when i run the program,it crash but no error shows.

 i use win 10,python 3.6.2,wxpython 4.0.0b2

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.