Commit 1d2d7be7 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

When exporting, prefer to select PlotItem rather than ViewBox if possible

CSV exporter gets 'precision' option
parent 3c6081f3
......@@ -34,8 +34,12 @@ class ExportDialog(QtGui.QWidget):
def show(self, item=None):
if item is not None:
## Select next exportable parent of the item originally clicked on
while not isinstance(item, pg.ViewBox) and not isinstance(item, pg.PlotItem) and item is not None:
item = item.parentItem()
## if this is a ViewBox inside a PlotItem, select the parent instead.
if isinstance(item, pg.ViewBox) and isinstance(item.parentItem(), pg.PlotItem):
item = item.parentItem()
......@@ -14,6 +14,7 @@ class CSVExporter(Exporter):
Exporter.__init__(self, item)
self.params = Parameter(name='params', type='group', children=[
{'name': 'separator', 'type': 'list', 'value': 'comma', 'values': ['comma', 'tab']},
{'name': 'precision', 'type': 'int', 'value': 10, 'limits': [0, None]},
def parameters(self):
......@@ -42,18 +43,15 @@ class CSVExporter(Exporter):
fd.write(sep.join(header) + '\n')
i = 0
while True:
done = True
numFormat = '%%0.%dg' % self.params['precision']
numRows = reduce(max, [len(d[0]) for d in data])
for i in range(numRows):
for d in data:
if i < len(d[0]):
fd.write('%g%s%g%s'%(d[0][i], sep, d[1][i], sep))
done = False
fd.write(numFormat % d[0][i] + sep + numFormat % d[1][i] + sep)
fd.write(' %s %s' % (sep, sep))
if done:
i += 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment