change color when label has changed
This commit is contained in:
parent
821ffae6b9
commit
7be0a01af8
12
labelImg.py
12
labelImg.py
@ -235,7 +235,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
'Ctrl+Shift+S', 'save-as', u'Save labels to a different file', enabled=False)
|
'Ctrl+Shift+S', 'save-as', u'Save labels to a different file', enabled=False)
|
||||||
|
|
||||||
close = action('&Close', self.closeFile, 'Ctrl+W', 'close', u'Close current file')
|
close = action('&Close', self.closeFile, 'Ctrl+W', 'close', u'Close current file')
|
||||||
|
|
||||||
resetAll = action('&ResetAll', self.resetAll, None, 'resetall', u'Reset all')
|
resetAll = action('&ResetAll', self.resetAll, None, 'resetall', u'Reset all')
|
||||||
|
|
||||||
color1 = action('Box Line Color', self.chooseColor1,
|
color1 = action('Box Line Color', self.chooseColor1,
|
||||||
@ -607,6 +607,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
text = self.labelDialog.popUp(item.text())
|
text = self.labelDialog.popUp(item.text())
|
||||||
if text is not None:
|
if text is not None:
|
||||||
item.setText(text)
|
item.setText(text)
|
||||||
|
item.setBackground(generateColorByText(text))
|
||||||
self.setDirty()
|
self.setDirty()
|
||||||
|
|
||||||
# Tzutalin 20160906 : Add file list and dock to move faster
|
# Tzutalin 20160906 : Add file list and dock to move faster
|
||||||
@ -699,7 +700,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
shape.fill_color = QColor(*fill_color)
|
shape.fill_color = QColor(*fill_color)
|
||||||
else:
|
else:
|
||||||
shape.fill_color = generateColorByText(label)
|
shape.fill_color = generateColorByText(label)
|
||||||
|
|
||||||
self.addLabel(shape)
|
self.addLabel(shape)
|
||||||
|
|
||||||
self.canvas.loadShapes(s)
|
self.canvas.loadShapes(s)
|
||||||
@ -752,6 +753,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
label = item.text()
|
label = item.text()
|
||||||
if label != shape.label:
|
if label != shape.label:
|
||||||
shape.label = item.text()
|
shape.label = item.text()
|
||||||
|
shape.line_color = generateColorByText(shape.label)
|
||||||
self.setDirty()
|
self.setDirty()
|
||||||
else: # User probably changed item visibility
|
else: # User probably changed item visibility
|
||||||
self.canvas.setShapeVisible(shape, item.checkState() == Qt.Checked)
|
self.canvas.setShapeVisible(shape, item.checkState() == Qt.Checked)
|
||||||
@ -912,7 +914,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
# read data first and store for saving into label file.
|
# read data first and store for saving into label file.
|
||||||
self.imageData = read(unicodeFilePath, 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',
|
||||||
@ -1081,10 +1083,10 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.'
|
defaultOpenDirPath = os.path.dirname(self.filePath) if self.filePath else '.'
|
||||||
|
|
||||||
dirpath = ustr(QFileDialog.getExistingDirectory(self,
|
dirpath = ustr(QFileDialog.getExistingDirectory(self,
|
||||||
'%s - Open Directory' % __appname__, defaultOpenDirPath,
|
'%s - Open Directory' % __appname__, defaultOpenDirPath,
|
||||||
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks))
|
QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks))
|
||||||
self.importDirImages(dirpath)
|
self.importDirImages(dirpath)
|
||||||
|
|
||||||
def importDirImages(self, dirpath):
|
def importDirImages(self, dirpath):
|
||||||
if not self.mayContinue() or not dirpath:
|
if not self.mayContinue() or not dirpath:
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user