wxPython特定参数的绘图更新

2024-06-28 18:44:19 发布

您现在位置:Python中文网/ 问答频道 /正文

亲爱的所有热情的程序员们

我正在编写一个GUI来调查我的数据。这些数据显示在面板上的三维绘图中。当我按下一个按钮时,这个情节正在我的GUI上填充一个准备好的图形。Plot函数从我的界面收集一些参数信息并创建。 我想通过使函数在参数更改时始终创建新的绘图来自动化该过程

我现在非常无助。也许我遗漏了什么。 有什么模块我可以用吗?或者有没有一种常见的方法来做这样的事情:

class MainFrame(wx.Frame):

def __init__(self, *args, **kwargs):
    super(MainFrame, self).__init__(*args, **kwargs) 

    self.InitUI()
    self.Show(True)

def InitUI(self):    
    print __doc__
    self.figure1 = Figure(figsize=(1,1))
    self.mft_plot = FigureCanvas(panel, -1, self.figure1)

    self.SpinCtrl_Y = wx.SpinCtrl(panel, value="0", size=(60,30), max = 10000) # Y
self.SpinCtrl_times = wx.SpinCtrl(panel, value="0",size=(100,30),min=-200, max=500) # time

    btn5 = wx.Button(panel, label = 'Create Vol. Image', pos = ((650), 10),
                     size = (150, 25))
    btn5.Bind(wx.EVT_BUTTON, self.OnPlotCreation)

def OnPlotCreation(self, e):
    print 'Waiting for time point..'


    t_enter = self.SpinCtrl_times.GetValue()
      # Transform time sample point to dimensional time point ..
    self.t_in_ms0 = t_enter * 1e3

    print 'Seleted time point is: %.2f ms' %self.t_in_ms0

    # Check for a threshold..
    threshold = self.mftthreshold.GetValue()

    self.figure1.clear()
    print 'Plot.'
    plotting.plot_stat_map( index_img( self.img, float(t_enter) ), figure = self.figure1, threshold= threshold, cut_coords=(self.SpinCtrl_Y.GetValue()),
                             annotate=True, title='t=%.2f ms' %self.t_in_ms0 )

作为一个简单的例子,我向您发布了一个很长的代码示例。我想实现的目标是函数在 self.mftthresholdself.SpinCtrl_timesself.SpinCtrl_Y已更改

我希望任何人都能给我一点帮助,让这成为可能

感谢你的问候, 丹尼尔


Tags: 函数selfsizethresholdtimedefpointwx
1条回答
网友
1楼 · 发布于 2024-06-28 18:44:19

所以解决办法是:

class MainFrame(wx.Frame):

def __init__(self, *args, **kwargs):
    super(MainFrame, self).__init__(*args, **kwargs) 

    self.InitUI()
    self.Show(True)

def InitUI(self):    
    print __doc__
    self.figure1 = Figure(figsize=(1,1))
    self.mft_plot = FigureCanvas(panel, -1, self.figure1)

    self.SpinCtrl_Y = wx.SpinCtrl(panel, value="0", size=(60,30), max = 10000) # Y
    self.SpinCtrl_times = wx.SpinCtrl(panel, value="0",size=(100,30),min=-200, max=500) # time

    btn5 = wx.Button(panel, label = 'Create Vol. Image', pos = ((650), 10),
                     size = (150, 25))

    btn5.Bind(wx.EVT_BUTTON, self.OnPlot)
    ***self.SpinCtrl_times.Bind(wx.EVT_SPINCTRL , self.OnPlot)***

def OnPlotCreation(self, e):
    print 'Waiting for time point..'


    t_enter = self.SpinCtrl_times.GetValue()
      # Transform time sample point to dimensional time point ..
    self.t_in_ms0 = t_enter * 1e3

    print 'Seleted time point is: %.2f ms' %self.t_in_ms0

    # Check for a threshold..
    threshold = self.mftthreshold.GetValue()

    self.figure1.clear()
    print 'Plot.'
    plotting.plot_stat_map( index_img( self.img, float(t_enter) ), figure = self.figure1, threshold= threshold, cut_coords=(self.SpinCtrl_Y.GetValue()),
                             annotate=True, title='t=%.2f ms' %self.t_in_ms0 )

谢谢你对萨克森的帮助

相关问题 更多 >