Fixed unicode support in export file save

This commit is contained in:
Luke Campagnola 2013-05-31 10:15:40 -04:00
parent aff70070ac
commit 9a20d051cb

View File

@ -1,6 +1,7 @@
from pyqtgraph.widgets.FileDialog import FileDialog from pyqtgraph.widgets.FileDialog import FileDialog
import pyqtgraph as pg import pyqtgraph as pg
from pyqtgraph.Qt import QtGui, QtCore, QtSvg from pyqtgraph.Qt import QtGui, QtCore, QtSvg
from pyqtgraph.python2_3 import asUnicode
import os, re import os, re
LastExportDirectory = None LastExportDirectory = None
@ -56,13 +57,13 @@ class Exporter(object):
return return
def fileSaveFinished(self, fileName): def fileSaveFinished(self, fileName):
fileName = str(fileName) fileName = asUnicode(fileName)
global LastExportDirectory global LastExportDirectory
LastExportDirectory = os.path.split(fileName)[0] LastExportDirectory = os.path.split(fileName)[0]
## If file name does not match selected extension, append it now ## If file name does not match selected extension, append it now
ext = os.path.splitext(fileName)[1].lower().lstrip('.') ext = os.path.splitext(fileName)[1].lower().lstrip('.')
selectedExt = re.search(r'\*\.(\w+)\b', str(self.fileDialog.selectedNameFilter())) selectedExt = re.search(r'\*\.(\w+)\b', asUnicode(self.fileDialog.selectedNameFilter()))
if selectedExt is not None: if selectedExt is not None:
selectedExt = selectedExt.groups()[0].lower() selectedExt = selectedExt.groups()[0].lower()
if ext != selectedExt: if ext != selectedExt: