Draft version for supporting change background color
This commit is contained in:
parent
1fb28d81a7
commit
318710c8e3
22
labelImg.py
22
labelImg.py
@ -183,6 +183,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
action = partial(newAction, self)
|
action = partial(newAction, self)
|
||||||
quit = action('&Quit', self.close,
|
quit = action('&Quit', self.close,
|
||||||
'Ctrl+Q', 'quit', u'Quit application')
|
'Ctrl+Q', 'quit', u'Quit application')
|
||||||
|
|
||||||
open = action('&Open', self.openFile,
|
open = action('&Open', self.openFile,
|
||||||
'Ctrl+O', 'open', u'Open image or label file')
|
'Ctrl+O', 'open', u'Open image or label file')
|
||||||
|
|
||||||
@ -212,6 +213,8 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
'Ctrl+L', 'color_line', u'Choose Box line color')
|
'Ctrl+L', 'color_line', u'Choose Box line color')
|
||||||
color2 = action('Box &Fill Color', self.chooseColor2,
|
color2 = action('Box &Fill Color', self.chooseColor2,
|
||||||
'Ctrl+Shift+L', 'color', u'Choose Box fill color')
|
'Ctrl+Shift+L', 'color', u'Choose Box fill color')
|
||||||
|
color3 = action('Bakground Color', self.chooseColor3,
|
||||||
|
'Ctrl+Shift+B', 'color', u'Choose background color')
|
||||||
|
|
||||||
createMode = action('Create\nRectBox', self.setCreateMode,
|
createMode = action('Create\nRectBox', self.setCreateMode,
|
||||||
'Ctrl+N', 'new', u'Start drawing Boxs', enabled=False)
|
'Ctrl+N', 'new', u'Start drawing Boxs', enabled=False)
|
||||||
@ -294,7 +297,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
|
|
||||||
# Store actions for further handling.
|
# Store actions for further handling.
|
||||||
self.actions = struct(save=save, saveAs=saveAs, open=open, close=close,
|
self.actions = struct(save=save, saveAs=saveAs, open=open, close=close,
|
||||||
lineColor=color1, fillColor=color2,
|
lineColor=color1, fillColor=color2, backgroundColor=color3,
|
||||||
create=create, delete=delete, edit=edit, copy=copy,
|
create=create, delete=delete, edit=edit, copy=copy,
|
||||||
createMode=createMode, editMode=editMode, advancedMode=advancedMode,
|
createMode=createMode, editMode=editMode, advancedMode=advancedMode,
|
||||||
shapeLineColor=shapeLineColor, shapeFillColor=shapeFillColor,
|
shapeLineColor=shapeLineColor, shapeFillColor=shapeFillColor,
|
||||||
@ -303,7 +306,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
zoomActions=zoomActions,
|
zoomActions=zoomActions,
|
||||||
fileMenuActions=(open,opendir,save,saveAs,close,quit),
|
fileMenuActions=(open,opendir,save,saveAs,close,quit),
|
||||||
beginner=(), advanced=(),
|
beginner=(), advanced=(),
|
||||||
editMenu=(edit, copy, delete, None, color1, color2),
|
editMenu=(edit, copy, delete, None, color1, color2, color3),
|
||||||
beginnerContext=(create, edit, copy, delete),
|
beginnerContext=(create, edit, copy, delete),
|
||||||
advancedContext=(createMode, editMode, edit, copy,
|
advancedContext=(createMode, editMode, edit, copy,
|
||||||
delete, shapeLineColor, shapeFillColor),
|
delete, shapeLineColor, shapeFillColor),
|
||||||
@ -355,6 +358,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.maxRecent = 7
|
self.maxRecent = 7
|
||||||
self.lineColor = None
|
self.lineColor = None
|
||||||
self.fillColor = None
|
self.fillColor = None
|
||||||
|
self.backgroundColor = None
|
||||||
self.zoom_level = 100
|
self.zoom_level = 100
|
||||||
self.fit_window = False
|
self.fit_window = False
|
||||||
|
|
||||||
@ -370,6 +374,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
'window/geometry': QByteArray,
|
'window/geometry': QByteArray,
|
||||||
'line/color': QColor,
|
'line/color': QColor,
|
||||||
'fill/color': QColor,
|
'fill/color': QColor,
|
||||||
|
'background/color': QColor,
|
||||||
'advanced': bool,
|
'advanced': bool,
|
||||||
# Docks and toolbars:
|
# Docks and toolbars:
|
||||||
'window/state': QByteArray,
|
'window/state': QByteArray,
|
||||||
@ -385,6 +390,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
'window/geometry': QByteArray,
|
'window/geometry': QByteArray,
|
||||||
'line/color': QColor,
|
'line/color': QColor,
|
||||||
'fill/color': QColor,
|
'fill/color': QColor,
|
||||||
|
'background/color': QColor,
|
||||||
'advanced': bool,
|
'advanced': bool,
|
||||||
# Docks and toolbars:
|
# Docks and toolbars:
|
||||||
'window/state': QByteArray,
|
'window/state': QByteArray,
|
||||||
@ -410,6 +416,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.restoreState(settings.get('window/state', QByteArray()))
|
self.restoreState(settings.get('window/state', QByteArray()))
|
||||||
self.lineColor = QColor(settings.get('line/color', Shape.line_color))
|
self.lineColor = QColor(settings.get('line/color', Shape.line_color))
|
||||||
self.fillColor = QColor(settings.get('fill/color', Shape.fill_color))
|
self.fillColor = QColor(settings.get('fill/color', Shape.fill_color))
|
||||||
|
self.backgroundColor = QColor(settings.get('background/color', QColor(0, 0, 0, 0)))
|
||||||
Shape.line_color = self.lineColor
|
Shape.line_color = self.lineColor
|
||||||
Shape.fill_color = self.fillColor
|
Shape.fill_color = self.fillColor
|
||||||
|
|
||||||
@ -853,6 +860,7 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
s['window/state'] = self.saveState()
|
s['window/state'] = self.saveState()
|
||||||
s['line/color'] = self.lineColor
|
s['line/color'] = self.lineColor
|
||||||
s['fill/color'] = self.fillColor
|
s['fill/color'] = self.fillColor
|
||||||
|
s['background/color'] = self.backgroundColor
|
||||||
s['recentFiles'] = self.recentFiles
|
s['recentFiles'] = self.recentFiles
|
||||||
s['advanced'] = not self._beginner
|
s['advanced'] = not self._beginner
|
||||||
if self.defaultSaveDir is not None and len(self.defaultSaveDir) > 1:
|
if self.defaultSaveDir is not None and len(self.defaultSaveDir) > 1:
|
||||||
@ -1085,6 +1093,16 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.canvas.update()
|
self.canvas.update()
|
||||||
self.setDirty()
|
self.setDirty()
|
||||||
|
|
||||||
|
def chooseColor3(self):
|
||||||
|
color = self.colorDialog.getColor(self.backgroundColor, u'Choose background color',
|
||||||
|
default=DEFAULT_FILL_COLOR)
|
||||||
|
|
||||||
|
if color:
|
||||||
|
self.backgroundColor = color
|
||||||
|
palette = QPalette(self)
|
||||||
|
palette.setColor(self.backgroundRole(), color)
|
||||||
|
self.setPalette(palette)
|
||||||
|
|
||||||
def deleteSelectedShape(self):
|
def deleteSelectedShape(self):
|
||||||
yes, no = QMessageBox.Yes, QMessageBox.No
|
yes, no = QMessageBox.Yes, QMessageBox.No
|
||||||
msg = u'You are about to permanently delete this Box, proceed anyway?'
|
msg = u'You are about to permanently delete this Box, proceed anyway?'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user