コード例 #1
0
ファイル: boxes_view.py プロジェクト: edwbaker/inselect
    def __init__(self, scene, parent=None):
        super(BoxesView, self).__init__(scene, parent)
        self.setCursor(Qt.CrossCursor)
        self.setDragMode(QtGui.QGraphicsView.RubberBandDrag)

        # If True, resizeEvent() will cause the scale to be updated to fit the
        # scene within the view
        self.fit_to_view = True

        # Will contain a temporary Rect object while the user drag-drop-creates
        # a box
        self._pending_box = None

        colour_scheme_choice().colour_scheme_changed.connect(self.colour_scheme_changed)
コード例 #2
0
    def __init__(self, parent=None):
        super(ObjectView, self).__init__(parent)

        # Items are shown either in a grid or with a single item expanded
        # When more than one item is selected, view changes to grid.

        self.setItemDelegate(CropDelegate(self))
        self.setFlow(self.LeftToRight)
        self.setWrapping(True)
        self.setResizeMode(self.Adjust)
        self.setSelectionMode(QAbstractItemView.ExtendedSelection)

        # Activating an item toggles the expanded state
        self.activated.connect(self.toggle_expanded)

        colour_scheme_choice().colour_scheme_changed.connect(self.colour_scheme_changed)

        self._create_actions()
コード例 #3
0
    def __init__(self, scene, parent=None):
        super(BoxesView, self).__init__(scene, parent)
        self.setCursor(Qt.CrossCursor)
        self.setDragMode(QGraphicsView.RubberBandDrag)

        # If 'whole_scene', resizeEvent() will cause the scale to be updated to
        # fit the scene within the view.
        # If 'follow_selection', changes in selection cause the view to scale to
        # encompass the current selection.
        # If 'fixed', changes in selection and size do not alter the viewport.
        self.zoom_mode = 'whole_scene'

        # Will contain a temporary Rect object while the user drag-drop-creates
        # a box
        self._pending_box = None

        colour_scheme_choice().colour_scheme_changed.connect(self.colour_scheme_changed)
        self.verticalScrollBar().valueChanged.connect(self.scrolled)
        self.horizontalScrollBar().valueChanged.connect(self.scrolled)
コード例 #4
0
ファイル: object.py プロジェクト: edwbaker/inselect
    def __init__(self, parent=None):
        super(ObjectView, self).__init__(parent)

        # Items are shown in a grid if False.
        # A single item is shown expanded if True.
        # When more than one item is selected, view changes to grid.
        self.expanded = False

        self.setItemDelegate(CropDelegate(self))
        self.setFlow(self.LeftToRight)
        self.setWrapping(True)
        self.setResizeMode(self.Adjust)
        self.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.setStyleSheet("background-color: darkgray;")

        # Activating an item toggles the expanded state
        self.activated.connect(self.toggle_expanded)

        colour_scheme_choice().colour_scheme_changed.connect(self.colour_scheme_changed)
コード例 #5
0
    def colours(self):
        """Tuple of two QColors to use for the box's border and fill
        respectively. Fill might be None.
        """
        colours = colour_scheme_choice().current['Colours']
        has_mouse = self.has_mouse()
        if has_mouse:
            outline = colours['Resizing']
        elif self.isSelected():
            outline = colours['Selected']
        elif self._isvalid:
            outline = colours['Valid']
        else:
            outline = colours['Invalid']

        if not self._isvalid and not has_mouse:
            fill = colours['InvalidFill']
        else:
            fill = None

        return outline, fill