From 9c09d346a0120241e1a99537b0b58768f95d1843 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Thu, 8 Apr 2021 23:44:11 -0400 Subject: added save capabilities --- panel.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/panel.py b/panel.py index d660af4..23c611e 100644 --- a/panel.py +++ b/panel.py @@ -12,6 +12,8 @@ import matplotlib.pyplot as plt from matplotlib.figure import Figure from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk) +import csv + import ue9qol class SinGen: @@ -210,6 +212,9 @@ class Experiment: self.bStop=Button(self.cntrlPannel,text="STOP",command=self.stop,font=('Arial','24')) self.bStop.pack(side='left') + self.bSave=Button(self.cntrlPannel,text="SAVE",command=self.saveCmd,font=('Arial','24')) + self.bSave.pack(side='left') + self.bExit=Button(self.cntrlPannel,text="EXIT",command=exit,font=('Arial','24')) self.bExit.pack(side='left') @@ -258,6 +263,17 @@ class Experiment: self.clearData() self.sweeper.cmdRestart() + def saveCmd(self): + csv_file = 'data.csv' + data = self.data + try: + with open(csv_file, 'w') as csvfile: + writer = csv.writer(csvfile) + writer.writerow(data.keys()) + writer.writerows(zip(*data.values())) + except IOError: + print('I/O error') + def onTic(self,swp=None): start = datetime.now() if swp is None: -- cgit v1.2.3