saving reports, plot ench
This commit is contained in:
parent
5d02391096
commit
989b333244
22
forms.py
22
forms.py
@ -278,6 +278,7 @@ class ResultFrame(wx.Frame):
|
||||
|
||||
self.table = wx.grid.Grid(self)
|
||||
self.table.SetDefaultCellAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)
|
||||
self.table.DisableCellEditControl()
|
||||
|
||||
sizer.Add(self.scalar, 0, wx.EXPAND | wx.ALL, 1)
|
||||
sizer.Add(self.table, 1, wx.EXPAND | wx.ALL, 1)
|
||||
@ -366,8 +367,7 @@ class PlotFrame(wx.Frame):
|
||||
self.plot.canvas.SetCursor(wx.STANDARD_CURSOR)
|
||||
self.plot.HandCursor = wx.CursorFromImage(HandCursorImage)
|
||||
self.plot.GrabHandCursor = wx.CursorFromImage(GrabHandCursorImage)
|
||||
# все равно не используется
|
||||
# self.plot.MagCursor = wx.StockCursor(wx.CURSOR_MAGNIFIER)
|
||||
self.plot.MagCursor = wx.StockCursor(wx.CURSOR_MAGNIFIER)
|
||||
|
||||
self.plot.SetGridColour(wx.Color(200, 200, 200))
|
||||
self.plot.SetEnableGrid(True)
|
||||
@ -384,7 +384,10 @@ class PlotFrame(wx.Frame):
|
||||
menubar.Append(menu, 'Plot')
|
||||
self.SetMenuBar(menubar)
|
||||
|
||||
self.plot.Bind(wx.EVT_MOUSEWHEEL, self.OnZoom)
|
||||
self.plot.canvas.Bind(wx.EVT_MOUSEWHEEL, self.OnZoom)
|
||||
self.plot.canvas.Bind(wx.EVT_MIDDLE_DOWN, self.OnZoomReset)
|
||||
self.plot.canvas.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
|
||||
self.plot.canvas.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
|
||||
|
||||
def OnZoom(self, event):
|
||||
x = event.GetX()
|
||||
@ -394,6 +397,19 @@ class PlotFrame(wx.Frame):
|
||||
delta = 0.8/1.0 if r > 0 else 1.0/0.8
|
||||
self.plot.Zoom((x, y), (delta, delta))
|
||||
|
||||
def OnZoomReset(self, event):
|
||||
self.plot.Reset()
|
||||
|
||||
def OnKeyDown(self, event):
|
||||
if event.GetKeyCode() == wx.WXK_SHIFT:
|
||||
self.plot.SetEnableDrag(False)
|
||||
self.plot.SetEnableZoom(True)
|
||||
|
||||
def OnKeyUp(self, event):
|
||||
if event.GetKeyCode() == wx.WXK_SHIFT:
|
||||
self.plot.SetEnableZoom(False)
|
||||
self.plot.SetEnableDrag(True)
|
||||
|
||||
class AboutDialog(wx.Dialog):
|
||||
def __init__(self, parent):
|
||||
wx.Dialog.__init__(self, parent, title = 'About Opal', size = (300, 330))
|
||||
|
39
opal.py
39
opal.py
@ -625,6 +625,7 @@ class MainFrame(forms.MainFrame):
|
||||
|
||||
return lines
|
||||
|
||||
@item_protector
|
||||
def AddLines(self, line_type):
|
||||
item, data = self.GetSelectedItemData(self.m_plots)
|
||||
if data != 'plot':
|
||||
@ -649,7 +650,6 @@ class MainFrame(forms.MainFrame):
|
||||
else:
|
||||
self.m_plots.SetItemImage(child, self.icons.pline)
|
||||
|
||||
@item_protector
|
||||
def OnAddCurves(self, event):
|
||||
self.AddLines(LINE_CURVE)
|
||||
|
||||
@ -738,6 +738,9 @@ class ResultFrame(forms.ResultFrame):
|
||||
self.result = result
|
||||
self.UpdateResults()
|
||||
|
||||
self.Bind(wx.EVT_MENU, self.OnExportToCSV,
|
||||
id = forms.ID_EXPORT_CSV)
|
||||
|
||||
def UpdateResults(self):
|
||||
self.scalar.Clear()
|
||||
self.table.ClearGrid()
|
||||
@ -768,7 +771,38 @@ class ResultFrame(forms.ResultFrame):
|
||||
value = str(param.GetValue())))
|
||||
|
||||
def OnExportToCSV(self, event):
|
||||
pass
|
||||
|
||||
if not self.result or not self.result.table:
|
||||
return
|
||||
|
||||
text_file = wx.FileSelector('Save table to CSV',
|
||||
default_filename = 'table.csv',
|
||||
wildcard = 'PNG files (*.csv)|*.csv|Text files (*.txt)|*.txt',
|
||||
flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
|
||||
|
||||
if not text_file:
|
||||
return
|
||||
|
||||
tl = self.table.GetSelectionBlockTopLeft() # [(t, l)]
|
||||
br = self.table.GetSelectionBlockBottomRight() # [(b, r)]
|
||||
|
||||
if not tl:
|
||||
tl = (0, 0)
|
||||
else:
|
||||
tl = tl[0]
|
||||
|
||||
if not br:
|
||||
br = (len(self.result.rows), len(self.result.columns))
|
||||
else:
|
||||
x, y = br[0]
|
||||
br = x + 1, y + 1
|
||||
|
||||
with open(text_file, 'w') as f:
|
||||
for i in xrange(tl[0], br[0]):
|
||||
s = []
|
||||
for j in xrange(tl[1], br[1]):
|
||||
s.append(repr(self.result.GetCell(i, j)))
|
||||
f.write('; '.join(s) + '\n')
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Форма с выбором наборов значений для построения графика
|
||||
@ -856,7 +890,6 @@ class PlotFrame(forms.PlotFrame):
|
||||
self.plot.SetSize(old_size)
|
||||
self.plot.Thaw()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Приложение
|
||||
#-----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user