使用来自"持续时间"的变量,按钮刷新改变了wxPython GUI图。和"振幅"

时间:2015-04-28 11:53:34

标签: python numpy matplotlib plot wxpython

    self.figure0 = Figure()
    self.axes = self.figure0.add_subplot(111, axisbg="white")
    self.x_plot = FigureCanvas(self, -1, self.figure0)
    self.draw_x()

def draw_x(self):
    value1 = self.SpinCtrl0.GetValue()
    value2 = self.SpinCtrl1.GetValue()
    x = np.arange(0.0,10,0.1)
    y = value1 * np.sin( x * value2 )

    self.axes.clear()
    self.axes.plot(x, y)

我现在的问题是让情节保持不变,但刷新它的图画。

有人可以帮忙吗?!

P.S。:已经设置了按钮,我修复了" x_plot"的位置。后来在另一堂课。

1 个答案:

答案 0 :(得分:0)

除非我误解你,否则你会将(wx.EVT_BUTTON)处理程序绑定到你的按钮,并在该处理程序中调用self.draw_x(),假设上面的代码与你的按钮处理程序在同一个类中。