標(biāo)題: 向大家請(qǐng)教wxpython中函數(shù)調(diào)用問題 [打印本頁(yè)] 作者: rita9110 時(shí)間: 2015-02-01 16:10 標(biāo)題: 向大家請(qǐng)教wxpython中函數(shù)調(diào)用問題 這是兩個(gè)函數(shù),我想在plotline函數(shù)中調(diào)用了beforeplot函數(shù)。這里我寫的語(yǔ)句是“a = self.BeforePlot(event)”,但是,我不能確定對(duì)錯(cuò)。程序運(yùn)行后沒有實(shí)現(xiàn)預(yù)期效果,還請(qǐng)大家?guī)臀铱纯础?br />
#ascertain the value of i determined by RadioButton
def BeforePlot(self,event):
radioSelected = event.GetEventObject()
if radioSelected.Label == "Elmo":
i = 2
elif radioSelected.Label == "Ernie":
i = 3
else:
i = 5
return i
#plot the line about profit
def PlotLine(self,event):
a = self.BeforePlot(event)
x_values = numpy.arange(0,math.pi*4,0.1)
y_values = [math.sin(a*x) for x in x_values]
pylab.plot(x_values,y_values)
pylab.xlabel('x values')
pylab.ylabel('sine of ax')
pylab.title('plot of profit')
pylab.grid(True)
pylab.show()作者: 十萬個(gè)菜鳥 時(shí)間: 2015-02-01 21:07
只看到函數(shù)定義,沒看到主程序,看起來像是類下的方法(成員函數(shù))定義:有self參數(shù),坐等高手解答。作者: inpool 時(shí)間: 2015-02-05 10:16