add option to set the scene background via config option

This commit is contained in:
Martin Baeuml
2012-06-09 00:07:23 +02:00
parent e6d3fe08ad
commit db2acb268b
2 changed files with 22 additions and 1 deletions
+17
View File
@@ -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 -1
View File
@@ -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()
#