mirror of
https://github.com/wassname/sloth.git
synced 2026-07-28 11:26:26 +08:00
add option to set the scene background via config option
This commit is contained in:
@@ -135,6 +135,23 @@ PLUGINS
|
||||
Did not think to much about this yet. This is rather for v2.0. Could image to be able to define some kind of
|
||||
plugin that might do some preprocessing on an image, e.g. detect all faces and convert them into labels.
|
||||
|
||||
.. _SCENE_BACKGROUND:
|
||||
|
||||
SCENE_BACKGROUND
|
||||
----------------
|
||||
|
||||
Default::
|
||||
|
||||
Qt.darkGray
|
||||
|
||||
Allows to set the scene background to a custom color or pattern. Expects a QBrush. A more
|
||||
complex background could be a regular box pattern which might simplify the exact resizing of
|
||||
annotations that extend over image boundaries::
|
||||
|
||||
from PyQt4.QtGui import QBrush
|
||||
from PyQt4.QtCore import Qt
|
||||
SCENE_BACKGROUND = QBrush(Qt.darkGray, Qt.CrossPattern)
|
||||
|
||||
|
||||
Extending default values
|
||||
========================
|
||||
|
||||
@@ -5,6 +5,7 @@ from sloth.items import *
|
||||
from sloth.core.exceptions import InvalidArgumentException
|
||||
from sloth.annotations.model import AnnotationModelItem
|
||||
from sloth.utils import toQImage
|
||||
from sloth.conf import config
|
||||
import logging
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@@ -23,7 +24,10 @@ class AnnotationScene(QGraphicsScene):
|
||||
self._itemfactory = Factory(items)
|
||||
self._inserterfactory = Factory(inserters)
|
||||
|
||||
self.setBackgroundBrush(Qt.darkGray)
|
||||
try:
|
||||
self.setBackgroundBrush(config.SCENE_BACKGROUND)
|
||||
except:
|
||||
self.setBackgroundBrush(Qt.darkGray)
|
||||
self.reset()
|
||||
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user