免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3389 | 回复: 2
打印 上一主题 下一主题

向大家请教wxpython中函数调用问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-02-01 16:10 |只看该作者 |倒序浏览
这是两个函数,我想在plotline函数中调用了beforeplot函数。这里我写的语句是“a = self.BeforePlot(event)”,但是,我不能确定对错。程序运行后没有实现预期效果,还请大家帮我看看。

#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()

论坛徽章:
0
2 [报告]
发表于 2015-02-01 21:07 |只看该作者
只看到函数定义,没看到主程序,看起来像是类下的方法(成员函数)定义:有self参数,坐等高手解答。

论坛徽章:
0
3 [报告]
发表于 2015-02-05 10:16 |只看该作者
  1. def BeforePlot(self,event=None):
  2.     #do something
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP