[英]How to pass arguments to a custom class in python?
如何將Grid大小( self.CreateGrid(20,20)
)(行數和列數)傳遞給下面的自定義類?
import wx
class GraphicsPage(wx.grid.Grid):
def __init__(self, parent):
wx.grid.Grid.__init__(self, parent, -1)
self.CreateGrid(20,20)
self.SetRowLabelSize (0)
self.SetMargins(0,0)
self.AutoSizeColumns(False)
self.ForceRefresh()
import wx
class GraphicsPage(wx.grid.Grid):
def __init__(self, parent, width, height):
super(GraphicsPage, self).__init__(parent, -1)
self.CreateGrid(width, height)
self.SetRowLabelSize (0)
self.SetMargins(0,0)
self.AutoSizeColumns(False)
self.ForceRefresh()
然后使用以下方法實例化它:
GraphicsPage (someParent, 20, 30)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.