你知道吗 首先对不起我的英语。你知道吗
我用我的Agilent
进行测量。
我编写了一些高级函数来简单地实现它。
现在我想在测量过程中绘制结果。
我使用wxPython
和matplotlib
。你知道吗
我的代码(简体):
class MyInstr():
def __measurement(self, start, step, stop, plt, result):
if plt:
app = wx.PySimpleApp()
app.f = MeasGraph(result)
app.f.Show()
def st(app):
app.MainLoop()
th = threading.Thread(target=st, args=(app,))
th.start()
for ...
get_data():
...
result.append(new_data)
app.f.redraw_plot(result)
def bsweep(self, start, step, stop, plt=True):
result = {'info': {}, 'prim': [], 'sec': [], 'swp:' []}
self.__measurement(start, step, stop, plt, result)
class MeasGraph(wx.Frame):
def __init__(self, result):
self.data = result
wx.Frame.__init__(self, None, -1, 'Measurement Result')
self.create_main_panel()
def create_main_panel(self):
self.panel = wx.Panel(self)
self.init_plot()
self.canvas = FigureCanvas(self.panel, -1, self.fig)
self.vbox = wx.BoxSizer(wx.VERTICAL)
self.vbox.Add(self.canvas, 1, flag=wx.LEFT | wx.TOP | wx.GROW)
self.panel.SetSizer(self.vbox)
self.vbox.Fit(self)
def init_plot(self):
self.fig = Figure()
self.axes = self.fig.add_subplot(111)
self.primary = self.axes.plot([0], [0])[0]
def redraw_plot(self, result):
self.data = result
self.primary.set_xdata(self.data['swp'])
self.primary.set_ydata(self.data['prim'])
self.canvas.draw()
def main():
instr = MyInstr()
instr.bsweep(0, -0.1, -5, plt=True)
除了带绘图的窗口外,它工作正常。它很忙,当我点击它我的应用程序崩溃。你知道吗
谢谢你。你知道吗
UPD 1:好,但我希望能够运行多次测量,并希望同时查看所有以前的绘图和当前绘图。 例如:
instr.bsweep(0, -0.1, -5, plt=True) # measurement (up to 5 Volts) and plot
现在我知道我需要测量10伏的电压。因此:
instr.bsweep(0, -0.1, -10, plt=True)
我想比较一个情节和另一个情节。你知道吗
但我不能这样做,因为之前的情节(如果它将在一个主线程中)阻止了我的shell或我的应用程序。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐