Fix the issue when failing to open unicode dir and rename filename to
filePath
This commit is contained in:
parent
70721ad597
commit
c5ceaa687d
138
labelImg.py
138
labelImg.py
@ -35,6 +35,7 @@ from colorDialog import ColorDialog
|
|||||||
from labelFile import LabelFile, LabelFileError
|
from labelFile import LabelFile, LabelFileError
|
||||||
from toolBar import ToolBar
|
from toolBar import ToolBar
|
||||||
from pascal_voc_io import PascalVocReader
|
from pascal_voc_io import PascalVocReader
|
||||||
|
from pascal_voc_io import XML_EXT
|
||||||
|
|
||||||
__appname__ = 'labelImg'
|
__appname__ = 'labelImg'
|
||||||
|
|
||||||
@ -89,7 +90,7 @@ class HashableQListWidgetItem(QListWidgetItem):
|
|||||||
class MainWindow(QMainWindow, WindowMixin):
|
class MainWindow(QMainWindow, WindowMixin):
|
||||||
FIT_WINDOW, FIT_WIDTH, MANUAL_ZOOM = list(range(3))
|
FIT_WINDOW, FIT_WIDTH, MANUAL_ZOOM = list(range(3))
|
||||||
|
|
||||||
def __init__(self, filename=None):
|
def __init__(self, defaultFilename=None):
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
self.setWindowTitle(__appname__)
|
self.setWindowTitle(__appname__)
|
||||||
# Save as Pascal voc xml
|
# Save as Pascal voc xml
|
||||||
@ -353,7 +354,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
|
|
||||||
# Application state.
|
# Application state.
|
||||||
self.image = QImage()
|
self.image = QImage()
|
||||||
self.filename = u(filename)
|
self.filePath = u(defaultFilename)
|
||||||
self.recentFiles = []
|
self.recentFiles = []
|
||||||
self.maxRecent = 7
|
self.maxRecent = 7
|
||||||
self.lineColor = None
|
self.lineColor = None
|
||||||
@ -400,10 +401,10 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
position = settings.get('window/position', QPoint(0, 0))
|
position = settings.get('window/position', QPoint(0, 0))
|
||||||
self.resize(size)
|
self.resize(size)
|
||||||
self.move(position)
|
self.move(position)
|
||||||
saveDir = settings.get('savedir', None)
|
saveDir = u(settings.get('savedir', None))
|
||||||
self.lastOpenDir = settings.get('lastOpenDir', None)
|
self.lastOpenDir = u(settings.get('lastOpenDir', None))
|
||||||
if os.path.exists(str(saveDir)):
|
if os.path.exists(saveDir):
|
||||||
self.defaultSaveDir = str(saveDir)
|
self.defaultSaveDir = saveDir
|
||||||
self.statusBar().showMessage('%s started. Annotation will be saved to %s' %(__appname__, self.defaultSaveDir))
|
self.statusBar().showMessage('%s started. Annotation will be saved to %s' %(__appname__, self.defaultSaveDir))
|
||||||
self.statusBar().show()
|
self.statusBar().show()
|
||||||
|
|
||||||
@ -427,7 +428,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
# Populate the File menu dynamically.
|
# Populate the File menu dynamically.
|
||||||
self.updateFileMenu()
|
self.updateFileMenu()
|
||||||
# Since loading the file may take some time, make sure it runs in the background.
|
# Since loading the file may take some time, make sure it runs in the background.
|
||||||
self.queueEvent(partial(self.loadFile, self.filename))
|
self.queueEvent(partial(self.loadFile, self.filePath))
|
||||||
|
|
||||||
# Callbacks:
|
# Callbacks:
|
||||||
self.zoomWidget.valueChanged.connect(self.paintCanvas)
|
self.zoomWidget.valueChanged.connect(self.paintCanvas)
|
||||||
@ -500,7 +501,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.itemsToShapes.clear()
|
self.itemsToShapes.clear()
|
||||||
self.shapesToItems.clear()
|
self.shapesToItems.clear()
|
||||||
self.labelList.clear()
|
self.labelList.clear()
|
||||||
self.filename = None
|
self.filePath = None
|
||||||
self.imageData = None
|
self.imageData = None
|
||||||
self.labelFile = None
|
self.labelFile = None
|
||||||
self.canvas.resetState()
|
self.canvas.resetState()
|
||||||
@ -511,12 +512,12 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
return items[0]
|
return items[0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def addRecentFile(self, filename):
|
def addRecentFile(self, filePath):
|
||||||
if filename in self.recentFiles:
|
if filePath in self.recentFiles:
|
||||||
self.recentFiles.remove(filename)
|
self.recentFiles.remove(filePath)
|
||||||
elif len(self.recentFiles) >= self.maxRecent:
|
elif len(self.recentFiles) >= self.maxRecent:
|
||||||
self.recentFiles.pop()
|
self.recentFiles.pop()
|
||||||
self.recentFiles.insert(0, filename)
|
self.recentFiles.insert(0, filePath)
|
||||||
|
|
||||||
def beginner(self):
|
def beginner(self):
|
||||||
return self._beginner
|
return self._beginner
|
||||||
@ -557,12 +558,12 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.toggleDrawMode(True)
|
self.toggleDrawMode(True)
|
||||||
|
|
||||||
def updateFileMenu(self):
|
def updateFileMenu(self):
|
||||||
current = self.filename
|
currFilePath = self.filePath
|
||||||
def exists(filename):
|
def exists(filename):
|
||||||
return os.path.exists(filename)
|
return os.path.exists(filename)
|
||||||
menu = self.menus.recentFiles
|
menu = self.menus.recentFiles
|
||||||
menu.clear()
|
menu.clear()
|
||||||
files = [f for f in self.recentFiles if f != current and exists(f)]
|
files = [f for f in self.recentFiles if f != currFilePath and exists(f)]
|
||||||
for i, f in enumerate(files):
|
for i, f in enumerate(files):
|
||||||
icon = newIcon('labels')
|
icon = newIcon('labels')
|
||||||
action = QAction(
|
action = QAction(
|
||||||
@ -637,7 +638,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
shape.fill_color = QColor(*fill_color)
|
shape.fill_color = QColor(*fill_color)
|
||||||
self.canvas.loadShapes(s)
|
self.canvas.loadShapes(s)
|
||||||
|
|
||||||
def saveLabels(self, filename):
|
def saveLabels(self, filePath):
|
||||||
lf = LabelFile()
|
lf = LabelFile()
|
||||||
def format_shape(s):
|
def format_shape(s):
|
||||||
return dict(label=s.label,
|
return dict(label=s.label,
|
||||||
@ -650,15 +651,15 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
shapes = [format_shape(shape) for shape in self.canvas.shapes]
|
shapes = [format_shape(shape) for shape in self.canvas.shapes]
|
||||||
# Can add differrent annotation formats here
|
# Can add differrent annotation formats here
|
||||||
try:
|
try:
|
||||||
filename = u(filename)
|
unicodeFilePath = u(filePath)
|
||||||
if self.usingPascalVocFormat is True:
|
if self.usingPascalVocFormat is True:
|
||||||
lf.savePascalVocFormat(filename, shapes, filename, self.imageData,
|
lf.savePascalVocFormat(unicodeFilePath, shapes, unicodeFilePath, self.imageData,
|
||||||
self.lineColor.getRgb(), self.fillColor.getRgb())
|
self.lineColor.getRgb(), self.fillColor.getRgb())
|
||||||
else:
|
else:
|
||||||
lf.save(filename, shapes, filename, self.imageData,
|
lf.save(unicodeFilePath, shapes, unicodeFilePath, self.imageData,
|
||||||
self.lineColor.getRgb(), self.fillColor.getRgb())
|
self.lineColor.getRgb(), self.fillColor.getRgb())
|
||||||
self.labelFile = lf
|
self.labelFile = lf
|
||||||
self.filename = filename
|
self.filePath = unicodeFilePath
|
||||||
return True
|
return True
|
||||||
except LabelFileError as e:
|
except LabelFileError as e:
|
||||||
self.errorMessage(u'Error saving label data',
|
self.errorMessage(u'Error saving label data',
|
||||||
@ -746,31 +747,31 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
for item, shape in self.itemsToShapes.items():
|
for item, shape in self.itemsToShapes.items():
|
||||||
item.setCheckState(Qt.Checked if value else Qt.Unchecked)
|
item.setCheckState(Qt.Checked if value else Qt.Unchecked)
|
||||||
|
|
||||||
def loadFile(self, filename=None):
|
def loadFile(self, filePath=None):
|
||||||
"""Load the specified file, or the last opened file if None."""
|
"""Load the specified file, or the last opened file if None."""
|
||||||
self.resetState()
|
self.resetState()
|
||||||
self.canvas.setEnabled(False)
|
self.canvas.setEnabled(False)
|
||||||
if filename is None:
|
if filePath is None:
|
||||||
filename = self.settings.get('filename')
|
filePath = self.settings.get('filename')
|
||||||
|
|
||||||
|
unicodeFilePath = u(filePath)
|
||||||
# Tzutalin 20160906 : Add file list and dock to move faster
|
# Tzutalin 20160906 : Add file list and dock to move faster
|
||||||
# Highlight the file item
|
# Highlight the file item
|
||||||
if filename and self.fileListWidget.count() > 0:
|
if unicodeFilePath and self.fileListWidget.count() > 0:
|
||||||
index = self.mImgList.index(filename)
|
index = self.mImgList.index(unicodeFilePath)
|
||||||
fileWidgetItem = self.fileListWidget.item(index)
|
fileWidgetItem = self.fileListWidget.item(index)
|
||||||
fileWidgetItem.setSelected(True)
|
fileWidgetItem.setSelected(True)
|
||||||
|
|
||||||
if filename and QFile.exists(filename):
|
if unicodeFilePath and os.path.exists(unicodeFilePath):
|
||||||
filename = u(filename)
|
if LabelFile.isLabelFile(unicodeFilePath):
|
||||||
if LabelFile.isLabelFile(filename):
|
|
||||||
try:
|
try:
|
||||||
self.labelFile = LabelFile(filename)
|
self.labelFile = LabelFile(unicodeFilePath)
|
||||||
except LabelFileError as e:
|
except LabelFileError as e:
|
||||||
self.errorMessage(u'Error opening file',
|
self.errorMessage(u'Error opening file',
|
||||||
(u"<p><b>%s</b></p>"
|
(u"<p><b>%s</b></p>"
|
||||||
u"<p>Make sure <i>%s</i> is a valid label file.")\
|
u"<p>Make sure <i>%s</i> is a valid label file.") \
|
||||||
% (e, filename))
|
% (e, unicodeFilePath))
|
||||||
self.status("Error reading %s" % filename)
|
self.status("Error reading %s" % unicodeFilePath)
|
||||||
return False
|
return False
|
||||||
self.imageData = self.labelFile.imageData
|
self.imageData = self.labelFile.imageData
|
||||||
self.lineColor = QColor(*self.labelFile.lineColor)
|
self.lineColor = QColor(*self.labelFile.lineColor)
|
||||||
@ -778,17 +779,17 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
else:
|
else:
|
||||||
# Load image:
|
# Load image:
|
||||||
# read data first and store for saving into label file.
|
# read data first and store for saving into label file.
|
||||||
self.imageData = read(filename, None)
|
self.imageData = read(unicodeFilePath, None)
|
||||||
self.labelFile = None
|
self.labelFile = None
|
||||||
image = QImage.fromData(self.imageData)
|
image = QImage.fromData(self.imageData)
|
||||||
if image.isNull():
|
if image.isNull():
|
||||||
self.errorMessage(u'Error opening file',
|
self.errorMessage(u'Error opening file',
|
||||||
u"<p>Make sure <i>%s</i> is a valid image file." % filename)
|
u"<p>Make sure <i>%s</i> is a valid image file." % unicodeFilePath)
|
||||||
self.status("Error reading %s" % filename)
|
self.status("Error reading %s" % unicodeFilePath)
|
||||||
return False
|
return False
|
||||||
self.status("Loaded %s" % os.path.basename(filename))
|
self.status("Loaded %s" % os.path.basename(unicodeFilePath))
|
||||||
self.image = image
|
self.image = image
|
||||||
self.filename = u(filename)
|
self.filePath = unicodeFilePath
|
||||||
self.canvas.loadPixmap(QPixmap.fromImage(image))
|
self.canvas.loadPixmap(QPixmap.fromImage(image))
|
||||||
if self.labelFile:
|
if self.labelFile:
|
||||||
self.loadLabels(self.labelFile.shapes)
|
self.loadLabels(self.labelFile.shapes)
|
||||||
@ -796,15 +797,15 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.canvas.setEnabled(True)
|
self.canvas.setEnabled(True)
|
||||||
self.adjustScale(initial=True)
|
self.adjustScale(initial=True)
|
||||||
self.paintCanvas()
|
self.paintCanvas()
|
||||||
self.addRecentFile(self.filename)
|
self.addRecentFile(self.filePath)
|
||||||
self.toggleActions(True)
|
self.toggleActions(True)
|
||||||
|
|
||||||
## Label xml file and show bound box according to its filename
|
## Label xml file and show bound box according to its filename
|
||||||
if self.usingPascalVocFormat is True and \
|
if self.usingPascalVocFormat is True and \
|
||||||
self.defaultSaveDir is not None:
|
self.defaultSaveDir is not None:
|
||||||
basename = os.path.basename(os.path.splitext(self.filename)[0]) + '.xml'
|
basename = os.path.basename(os.path.splitext(self.filePath)[0]) + XML_EXT
|
||||||
xmlPath = os.path.join(self.defaultSaveDir, basename)
|
xmlPath = os.path.join(self.defaultSaveDir, basename)
|
||||||
self.loadPascalXMLByFilename(xmlPath)
|
self.loadPascalXMLByFilename(xmlPath)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -848,7 +849,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
s = self.settings
|
s = self.settings
|
||||||
# If it loads images from dir, don't load it at the begining
|
# If it loads images from dir, don't load it at the begining
|
||||||
if self.dirname is None:
|
if self.dirname is None:
|
||||||
s['filename'] = self.filename if self.filename else ''
|
s['filename'] = self.filePath if self.filePath else ''
|
||||||
else:
|
else:
|
||||||
s['filename'] = ''
|
s['filename'] = ''
|
||||||
|
|
||||||
@ -865,7 +866,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
s['savedir'] = ""
|
s['savedir'] = ""
|
||||||
|
|
||||||
if self.lastOpenDir is not None and len(self.lastOpenDir) > 1:
|
if self.lastOpenDir is not None and len(self.lastOpenDir) > 1:
|
||||||
s['lastOpenDir'] = str(self.lastOpenDir)
|
s['lastOpenDir'] = self.lastOpenDir
|
||||||
else:
|
else:
|
||||||
s['lastOpenDir'] = ""
|
s['lastOpenDir'] = ""
|
||||||
|
|
||||||
@ -905,11 +906,11 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.statusBar().show()
|
self.statusBar().show()
|
||||||
|
|
||||||
def openAnnotation(self, _value=False):
|
def openAnnotation(self, _value=False):
|
||||||
if self.filename is None:
|
if self.filePath is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
path = os.path.dirname(u(self.filename))\
|
path = os.path.dirname(u(self.filePath))\
|
||||||
if self.filename else '.'
|
if self.filePath else '.'
|
||||||
if self.usingPascalVocFormat:
|
if self.usingPascalVocFormat:
|
||||||
formats = ['*.%s' % str(fmt).lower()\
|
formats = ['*.%s' % str(fmt).lower()\
|
||||||
for fmt in QImageReader.supportedImageFormats()]
|
for fmt in QImageReader.supportedImageFormats()]
|
||||||
@ -923,13 +924,13 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
if not self.mayContinue():
|
if not self.mayContinue():
|
||||||
return
|
return
|
||||||
|
|
||||||
path = os.path.dirname(self.filename)\
|
path = os.path.dirname(self.filePath)\
|
||||||
if self.filename else '.'
|
if self.filePath else '.'
|
||||||
|
|
||||||
if self.lastOpenDir is not None and len(self.lastOpenDir) > 1:
|
if self.lastOpenDir is not None and len(self.lastOpenDir) > 1:
|
||||||
path = self.lastOpenDir
|
path = self.lastOpenDir
|
||||||
|
|
||||||
dirpath = str(QFileDialog.getExistingDirectory(self,
|
dirpath = u(QFileDialog.getExistingDirectory(self,
|
||||||
'%s - Open Directory' % __appname__, path, QFileDialog.ShowDirsOnly
|
'%s - Open Directory' % __appname__, path, QFileDialog.ShowDirsOnly
|
||||||
| QFileDialog.DontResolveSymlinks))
|
| QFileDialog.DontResolveSymlinks))
|
||||||
|
|
||||||
@ -937,6 +938,8 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.lastOpenDir = dirpath
|
self.lastOpenDir = dirpath
|
||||||
|
|
||||||
self.dirname = dirpath
|
self.dirname = dirpath
|
||||||
|
self.filePath = None
|
||||||
|
self.fileListWidget.clear()
|
||||||
self.mImgList = self.scanAllImages(dirpath)
|
self.mImgList = self.scanAllImages(dirpath)
|
||||||
self.openNextImg()
|
self.openNextImg()
|
||||||
for imgPath in self.mImgList:
|
for imgPath in self.mImgList:
|
||||||
@ -950,10 +953,10 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
if len(self.mImgList) <= 0:
|
if len(self.mImgList) <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.filename is None:
|
if self.filePath is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
currIndex = self.mImgList.index(self.filename)
|
currIndex = self.mImgList.index(self.filePath)
|
||||||
if currIndex -1 >= 0:
|
if currIndex -1 >= 0:
|
||||||
filename = self.mImgList[currIndex-1]
|
filename = self.mImgList[currIndex-1]
|
||||||
if filename:
|
if filename:
|
||||||
@ -972,10 +975,10 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
return
|
return
|
||||||
|
|
||||||
filename = None
|
filename = None
|
||||||
if self.filename is None:
|
if self.filePath is None:
|
||||||
filename = self.mImgList[0]
|
filename = self.mImgList[0]
|
||||||
else:
|
else:
|
||||||
currIndex = self.mImgList.index(self.filename)
|
currIndex = self.mImgList.index(self.filePath)
|
||||||
if currIndex + 1 < len(self.mImgList):
|
if currIndex + 1 < len(self.mImgList):
|
||||||
filename = self.mImgList[currIndex+1]
|
filename = self.mImgList[currIndex+1]
|
||||||
|
|
||||||
@ -985,8 +988,8 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
def openFile(self, _value=False):
|
def openFile(self, _value=False):
|
||||||
if not self.mayContinue():
|
if not self.mayContinue():
|
||||||
return
|
return
|
||||||
path = os.path.dirname(str(self.filename))\
|
path = os.path.dirname(str(self.filePath))\
|
||||||
if self.filename else '.'
|
if self.filePath else '.'
|
||||||
formats = ['*.%s' % str(fmt).lower()\
|
formats = ['*.%s' % str(fmt).lower()\
|
||||||
for fmt in QImageReader.supportedImageFormats()]
|
for fmt in QImageReader.supportedImageFormats()]
|
||||||
filters = "Image & Label files (%s)" % \
|
filters = "Image & Label files (%s)" % \
|
||||||
@ -1000,13 +1003,13 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
assert not self.image.isNull(), "cannot save empty image"
|
assert not self.image.isNull(), "cannot save empty image"
|
||||||
if self.hasLabels():
|
if self.hasLabels():
|
||||||
if self.defaultSaveDir is not None and len(str(self.defaultSaveDir)):
|
if self.defaultSaveDir is not None and len(str(self.defaultSaveDir)):
|
||||||
print('handle the image:' + self.filename)
|
print('handle the image:' + self.filePath)
|
||||||
imgFileName = os.path.basename(self.filename)
|
imgFileName = os.path.basename(self.filePath)
|
||||||
savedFileName = os.path.splitext(imgFileName)[0] + LabelFile.suffix
|
savedFileName = os.path.splitext(imgFileName)[0] + LabelFile.suffix
|
||||||
savedPath = os.path.join(str(self.defaultSaveDir), savedFileName)
|
savedPath = os.path.join(str(self.defaultSaveDir), savedFileName)
|
||||||
self._saveFile(savedPath)
|
self._saveFile(savedPath)
|
||||||
else:
|
else:
|
||||||
self._saveFile(self.filename if self.labelFile\
|
self._saveFile(self.filePath if self.labelFile\
|
||||||
else self.saveFileDialog())
|
else self.saveFileDialog())
|
||||||
|
|
||||||
def saveFileAs(self, _value=False):
|
def saveFileAs(self, _value=False):
|
||||||
@ -1021,18 +1024,17 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
dlg = QFileDialog(self, caption, openDialogPath, filters)
|
dlg = QFileDialog(self, caption, openDialogPath, filters)
|
||||||
dlg.setDefaultSuffix(LabelFile.suffix[1:])
|
dlg.setDefaultSuffix(LabelFile.suffix[1:])
|
||||||
dlg.setAcceptMode(QFileDialog.AcceptSave)
|
dlg.setAcceptMode(QFileDialog.AcceptSave)
|
||||||
filenameWithoutExtension = os.path.splitext(self.filename)[0]
|
filenameWithoutExtension = os.path.splitext(self.filePath)[0]
|
||||||
dlg.selectFile(filenameWithoutExtension)
|
dlg.selectFile(filenameWithoutExtension)
|
||||||
dlg.setOption(QFileDialog.DontUseNativeDialog, False)
|
dlg.setOption(QFileDialog.DontUseNativeDialog, False)
|
||||||
if dlg.exec_():
|
if dlg.exec_():
|
||||||
return dlg.selectedFiles()[0]
|
return dlg.selectedFiles()[0]
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def _saveFile(self, filename):
|
def _saveFile(self, annotationFilePath):
|
||||||
if filename and self.saveLabels(filename):
|
if annotationFilePath and self.saveLabels(annotationFilePath):
|
||||||
self.addRecentFile(filename)
|
|
||||||
self.setClean()
|
self.setClean()
|
||||||
self.statusBar().showMessage('Saved to %s' % filename)
|
self.statusBar().showMessage('Saved to %s' % annotationFilePath)
|
||||||
self.statusBar().show()
|
self.statusBar().show()
|
||||||
|
|
||||||
def closeFile(self, _value=False):
|
def closeFile(self, _value=False):
|
||||||
@ -1065,7 +1067,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
'<p><b>%s</b></p>%s' % (title, message))
|
'<p><b>%s</b></p>%s' % (title, message))
|
||||||
|
|
||||||
def currentPath(self):
|
def currentPath(self):
|
||||||
return os.path.dirname(self.filename) if self.filename else '.'
|
return os.path.dirname(self.filePath) if self.filePath else '.'
|
||||||
|
|
||||||
def chooseColor1(self):
|
def chooseColor1(self):
|
||||||
color = self.colorDialog.getColor(self.lineColor, u'Choose line color',
|
color = self.colorDialog.getColor(self.lineColor, u'Choose line color',
|
||||||
@ -1133,7 +1135,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.labelHist.append(line)
|
self.labelHist.append(line)
|
||||||
|
|
||||||
def loadPascalXMLByFilename(self, xmlPath):
|
def loadPascalXMLByFilename(self, xmlPath):
|
||||||
if self.filename is None:
|
if self.filePath is None:
|
||||||
return
|
return
|
||||||
if os.path.isfile(xmlPath) is False:
|
if os.path.isfile(xmlPath) is False:
|
||||||
return
|
return
|
||||||
|
|||||||
@ -7,6 +7,7 @@ from xml.etree.ElementTree import Element, SubElement
|
|||||||
from lxml import etree
|
from lxml import etree
|
||||||
import codecs
|
import codecs
|
||||||
|
|
||||||
|
XML_EXT = '.xml'
|
||||||
|
|
||||||
class PascalVocWriter:
|
class PascalVocWriter:
|
||||||
|
|
||||||
@ -101,7 +102,7 @@ class PascalVocWriter:
|
|||||||
self.appendObjects(root)
|
self.appendObjects(root)
|
||||||
out_file = None
|
out_file = None
|
||||||
if targetFile is None:
|
if targetFile is None:
|
||||||
out_file = codecs.open(self.filename + '.xml', 'w', encoding='utf-8')
|
out_file = codecs.open(self.filename + XML_EXT, 'w', encoding='utf-8')
|
||||||
else:
|
else:
|
||||||
out_file = codecs.open(targetFile, 'w', encoding='utf-8')
|
out_file = codecs.open(targetFile, 'w', encoding='utf-8')
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user