我想做的就是开设2个课程
1-创建一个网格
2-获取网格并将其放入wx.notebook
因此,基本上,一个类使网格成为另一类,将网格作为参数并将其添加到wx.notebook
但是我不断收到错误消息
self.m_grid1 = wx.grid.Grid(self) TypeError: Grid(): arguments did not match any overloaded call:
overload 1: too many arguments
overload 2: argument 1 has unexpected type 'reportGrid'
这是Grid类的代码,称为 reportGrid
class reportGrid ():
def __init__( self, list):
self.m_grid1 = wx.grid.Grid(self)
self.m_grid1.Create(parent = None, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.WANTS_CHARS, name="Grid")
# Grid
self.m_grid1.CreateGrid( 7, 18 )
self.m_grid1.EnableEditing( True )
self.m_grid1.EnableGridLines( True )
self.m_grid1.SetGridLineColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOWTEXT ) )
self.m_grid1.EnableDragGridSize( True )
self.m_grid1.SetMargins( 0, 0 )
# Columns
self.m_grid1.EnableDragColMove( False )
self.m_grid1.EnableDragColSize( True )
self.m_grid1.SetColLabelSize( 30 )
self.m_grid1.SetColLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
# Rows
self.m_grid1.EnableDragRowSize( True )
self.m_grid1.SetRowLabelSize( 80 )
self.m_grid1.SetRowLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
# Label Appearance
self.m_grid1.SetColLabelValue(0, "Yield")
self.m_grid1.SetColLabelValue(1, "64CU")
self.m_grid1.SetColLabelValue(2, "Yield")
self.m_grid1.SetColLabelValue(3, "60CU")
self.m_grid1.SetColLabelValue(4, "Chain")
self.m_grid1.SetColLabelValue(5, "Logic")
self.m_grid1.SetColLabelValue(6, "Delay")
self.m_grid1.SetColLabelValue(7, "BIST")
self.m_grid1.SetColLabelValue(8, "CREST")
self.m_grid1.SetColLabelValue(9, "HSIO")
self.m_grid1.SetColLabelValue(10, "DC-Spec")
self.m_grid1.SetColLabelValue(11, "HBM")
self.m_grid1.SetColLabelValue(12, "OS")
self.m_grid1.SetColLabelValue(13, "PS")
self.m_grid1.SetColLabelValue(14, "Alarm")
self.m_grid1.SetColLabelValue(15, "JTAG")
self.m_grid1.SetColLabelValue(16, "Thermal IDD")
self.m_grid1.SetColLabelValue(17, "Insuff Config")
self.m_grid1.SetRowLabelValue(0, "Today")
self.m_grid1.SetRowLabelValue(1, "WTD")
self.m_grid1.SetRowLabelValue(2, "WW45")
self.m_grid1.SetRowLabelValue(3, "WW44")
self.m_grid1.SetRowLabelValue(4, "WW43")
self.m_grid1.SetRowLabelValue(5, "Monthly")
self.m_grid1.SetRowLabelValue(6, "QTD")
# Cell Defaults
for i in range(len(list)):
for j in range(len(list[i])):
self.m_grid1.SetCellValue(i,j, list[i][j])
self.m_grid1.SetDefaultCellAlignment( wx.ALIGN_LEFT, wx.ALIGN_TOP )
,这里是将其作为参数并假定创建笔记本的类
class reportFrame ( wx.Frame ):
def __init__( self, parent , grid1):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Report", pos = wx.DefaultPosition, size = wx.Size( 7990,210 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
bSizer6 = wx.BoxSizer( wx.VERTICAL )
self.m_notebook1 = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_notebook1.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOBK ) )
self.m_panel2 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
bSizer14 = wx.BoxSizer( wx.HORIZONTAL )
bSizer14.Add( grid1, 0, wx.ALL, 5 )
self.m_panel2.SetSizer( bSizer14 )
self.m_panel2.Layout()
bSizer14.Fit( self.m_panel2 )
self.m_notebook1.AddPage( self.m_panel2, u"a page", False )
self.m_panel3 = wx.Panel( self.m_notebook1, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
bSizer17 = wx.BoxSizer( wx.VERTICAL )
bSizer17.Add( grid1, 0, wx.ALL, 5 )
self.m_panel3.SetSizer( bSizer17 )
self.m_panel3.Layout()
bSizer17.Fit( self.m_panel3 )
self.m_notebook1.AddPage( self.m_panel3, u"a page", True )
bSizer6.Add( self.m_notebook1, 1, wx.EXPAND |wx.ALL, 3 )
self.SetSizer( bSizer6 )
self.Layout()
self.Centre( wx.BOTH )
self.Show(show=True)
答案 0 :(得分:1)
wx.grid.Grid(self)
在这里self
必须是wx.Window(或子类)类型。在您的代码中,它是reportGrid
类型。
但是reportGrid
不是wx.Window也不是wx.Window的子类。
如果您有wx.Notebook的页面“ pagegrid”(例如,类型为wx.Panel或子类),则可以进行设置
class reportGrid (wx.Panel):
def __init__( self, list):
self.m_grid1 = wx.grid.Grid(self)
并在笔记本定义中
pagegrid = reportGrid(nb)
nb.AddPage(pagegrid , "Grid Page")