Skip to content

Instantly share code, notes, and snippets.

@plasmoidia
Created October 9, 2013 21:52
Show Gist options
  • Save plasmoidia/6909107 to your computer and use it in GitHub Desktop.
Save plasmoidia/6909107 to your computer and use it in GitHub Desktop.
Modify pyqtgraph exporters for use with pyinstaller so that exporting works.
Exporters = []
from pyqtgraph import importModules
#from .. import frozenSupport
import os
d = os.path.split(__file__)[0]
#files = []
#for f in frozenSupport.listdir(d):
#if frozenSupport.isdir(os.path.join(d, f)) and f != '__pycache__':
#files.append(f)
#elif f[-3:] == '.py' and f not in ['__init__.py', 'Exporter.py']:
#files.append(f[:-3])
#for modName in files:
#mod = __import__(modName, globals(), locals(), fromlist=['*'])
#for mod in importModules('', globals(), locals(), excludes=['Exporter']).values():
# if hasattr(mod, '__all__'):
# names = mod.__all__
# else:
# names = [n for n in dir(mod) if n[0] != '_']
# for k in names:
# if hasattr(mod, k):
# Exporters.append(getattr(mod, k))
from . import CSVExporter
from . import SVGExporter
from . import Matplotlib
from . import PrintExporter
from . import ImageExporter
mods = [CSVExporter, SVGExporter, Matplotlib, PrintExporter, ImageExporter]
for mod in mods:
if hasattr(mod, '__all__'):
names = mod.__all__
else:
names = [n for n in dir(mod) if n[0] != '_']
for k in names:
if hasattr(mod, k):
Exporters.append(getattr(mod, k))
def listExporters():
return Exporters[:]
15c15,34
< for mod in importModules('', globals(), locals(), excludes=['Exporter']).values():
---
> #for mod in importModules('', globals(), locals(), excludes=['Exporter']).values():
> # if hasattr(mod, '__all__'):
> # names = mod.__all__
> # else:
> # names = [n for n in dir(mod) if n[0] != '_']
> # for k in names:
> # if hasattr(mod, k):
> # Exporters.append(getattr(mod, k))
>
> from . import CSVExporter
> from . import SVGExporter
> from . import Matplotlib
> from . import PrintExporter
> from . import ImageExporter
>
> mods = [CSVExporter, SVGExporter, Matplotlib, PrintExporter, ImageExporter]
> for mod in mods:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment