在python的一个类中实例化另外一个类如下self.status=customStatusBar(self)这个self到底有什么含义?
importwxclasscustomStatusBar(wx.StatusBar):def__init__(self,parent):wx.StatusBar.__in...
import wx
class customStatusBar(wx.StatusBar):
def __init__(self, parent):
wx.StatusBar.__init__(self,parent,-1)
#将状态栏分割为2列,一列显示进度一列显示百分比
self.SetFieldsCount(2)
#状态栏比例是2:1
self.SetStatusWidths([-2,-1])
self.gauge=wx.Gauge(self,-1,range=100,pos=(0,0),size=(200,30))
threading.Thread(target=self.procent,args=()).start()
def procent(self):
for i in range(108):
self.gauge.SetValue(i)
self.SetStatusText('%s%%' % i, 1)
time.sleep(0.1)
class priceFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, U'带进度条的状态栏')
self.panel=wx.Panel(self,-1)
#下面就是调用状态栏实例
#问题?# self.status = customStatusBar(self)
self.SetStatusBar(self.status)
if __name__ == '__main__':
app = wx.App()
frame = priceFrame()
frame.Show()
app.MainLoop() 展开
class customStatusBar(wx.StatusBar):
def __init__(self, parent):
wx.StatusBar.__init__(self,parent,-1)
#将状态栏分割为2列,一列显示进度一列显示百分比
self.SetFieldsCount(2)
#状态栏比例是2:1
self.SetStatusWidths([-2,-1])
self.gauge=wx.Gauge(self,-1,range=100,pos=(0,0),size=(200,30))
threading.Thread(target=self.procent,args=()).start()
def procent(self):
for i in range(108):
self.gauge.SetValue(i)
self.SetStatusText('%s%%' % i, 1)
time.sleep(0.1)
class priceFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, U'带进度条的状态栏')
self.panel=wx.Panel(self,-1)
#下面就是调用状态栏实例
#问题?# self.status = customStatusBar(self)
self.SetStatusBar(self.status)
if __name__ == '__main__':
app = wx.App()
frame = priceFrame()
frame.Show()
app.MainLoop() 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询