Example #1
0
    def _initUi(self):
        self.mainLayout = QtWidgets.QVBoxLayout()
        self.setLayout(self.mainLayout)
        topSpacer = QtWidgets.QSpacerItem(20, 52,
                                          QtWidgets.QSizePolicy.Minimum,
                                          QtWidgets.QSizePolicy.Expanding)
        bottomSpacer = QtWidgets.QSpacerItem(20, 52,
                                             QtWidgets.QSizePolicy.Minimum,
                                             QtWidgets.QSizePolicy.Expanding)
        leftSpacer = QtWidgets.QSpacerItem(20, 52,
                                           QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Minimum)
        rightSpacer = QtWidgets.QSpacerItem(20, 52,
                                            QtWidgets.QSizePolicy.Expanding,
                                            QtWidgets.QSizePolicy.Minimum)
        # label to hold the thumbnail image
        self.imageLabel = QtWidgets.QLabel(parent=self)
        self.imageLabel.hide()
        # camera icon
        self.iconLayout = QtWidgets.QHBoxLayout()
        self.cameraBtn = _CameraButton(parent=self)
        self.iconLayout.addItem(leftSpacer)
        self.iconLayout.addWidget(self.cameraBtn)
        self.iconLayout.addItem(rightSpacer)
        # add the items
        self.mainLayout.addItem(topSpacer)
        self.mainLayout.addLayout(self.iconLayout)
        self.mainLayout.addItem(bottomSpacer)

        self.cameraBtn.clicked.connect(self.onCameraButtonClicked)
Example #2
0
 def buildTitleFrame(self):
     """Builds the title part of the layout with a QFrame widget
     """
     # main dark grey qframe
     self.titleFrame = frame.QFrame(parent=self)
     self.setFrameColor(self.color)
     self.titleFrame.setContentsMargins(4, 0, 4, 0)
     # the horizontal layout
     self.horizontalLayout = QtWidgets.QHBoxLayout(self.titleFrame)
     self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
     # the icon and title and spacer
     self.iconButton = QtWidgets.QToolButton(parent=self)
     if self.collapsed:
         self.iconButton.setIcon(self._collapsedIcon)
     else:
         self.iconButton.setIcon(self._expandIcon)
     self.titleLabel = QtWidgets.QLabel(self.title, parent=self)
     self.titleLabel.setStyleSheet("font: bold;")
     self.titleLabel.setContentsMargins(0, 0, 0, 0)
     spacerItem = QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
     # add to horizontal layout
     self.horizontalLayout.addWidget(self.iconButton)
     self.horizontalLayout.addWidget(self.titleLabel)
     self.horizontalLayout.addItem(spacerItem)
     self.titleFrame.setFixedHeight(self.titleFrame.sizeHint().height())
     self.setMinimumSize(self.titleFrame.sizeHint().width(), self.titleFrame.sizeHint().height())
Example #3
0
    def __init__(self, label, matrix, min, max, parent=None):
        """

        :param label: the matrix widget label
        :type label: str
        :param matrix: a list of lists the lenght of each nested list is equal to the column length of the matrix for
         example if we're dealing with a 4x4 matrix then its a length of 4, 3x3 is 3 etc
        :type matrix: list(list(float))
        :param: min: a list of floats, each float is min for each vector
        :type min: list(float)
        :param: max: a list of floats, each float is max for each vector
        :type max: list(float)
        :param parent:
        :type parent:
        """
        super(Matrix, self).__init__(parent=parent)
        self.mainLayout = QtWidgets.QGridLayout(self)
        self.mainLayout.setContentsMargins(2, 2, 2, 2)
        self.mainLayout.setSpacing(uiconstants.SPACING)
        self.label = QtWidgets.QLabel(label, parent=self)
        spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.mainLayout.addWidget(self.label, 0, 0)
        self.mainLayout.addItem(spacerItem, 1, 0)
        self._widgets = OrderedDict()
        axislabels = ("X", "Y", "Z")
        for i, c in enumerate(matrix):
            vec = VectorSpinBox(label="", value=c, min=min[i], max=max[i], axis=axislabels, parent=self)
            self.mainLayout.addWidget(vec, i, 1)
            self._widgets[i] = vec

        self.setLayout(self.mainLayout)
Example #4
0
def Spacer(width, height, hMin=QtWidgets.QSizePolicy.Minimum, vMin=QtWidgets.QSizePolicy.Minimum):
    """creates an expanding spacer (empty area) with easy options.  DPI auto handled

    Size Policies are
    https://srinikom.github.io/pyside-docs/PySide/QtGui/QSizePolicy.html#PySide.QtGui.PySide.QtGui.QSizePolicy.Policy
        QtWidgets.QSizePolicy.Fixed -  never grows or shrinks
        QtWidgets.QSizePolicy.Minimum - no advantage being larger
        QtWidgets.QSizePolicy.Maximum - no advantage being smaller
        QtWidgets.QSizePolicy.Preferred - The sizeHint() is best, but the widget can be shrunk/expanded
        QtWidgets.QSizePolicy.Expanding -  but the widget can be shrunk or make use of extra space
        QtWidgets.QSizePolicy.MinimumExpanding - The sizeHint() is minimal, and sufficient
        QtWidgets.QSizePolicy.Ignored - The sizeHint() is ignored. Will get as much space as possible

    :param width: width of the spacer in pixels, DPI is auto handled
    :type width: int
    :param height: height of the spacer in pixels, DPI is auto handled
    :type height: int
    :param hMin: height of the spacer in pixels, DPI is auto handled
    :type hMin: PySide.QtGui.QSizePolicy.Policy
    :param vMin: vertical minimum
    :type vMin: PySide.QtGui.QSizePolicy.Policy
    :return spacerItem: item returned, ie the spacerItem
    :rtype spacerItem: object
    """
    return QtWidgets.QSpacerItem(utils.dpiScale(width), utils.dpiScale(height), hMin, vMin)
Example #5
0
    def buildTitleFrame(self):
        """Builds the title part of the layout with a QFrame widget
        """

        self.layout().addWidget(self.titleFrame)

        self.titleFrame.setContentsMargins(1, 1, 4, 0)
        self.titleFrame.mousePressEvent = self.mousePressEvent

        # the horizontal layout
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.titleFrame)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)

        # the icon and title and spacer
        self.expandToggleButton.setParent(self.titleFrame)
        if self.collapsed:
            self.expandToggleButton.setIcon(self._collapsedIcon)
        else:
            self.expandToggleButton.setIcon(self._expandIcon)

        self.folderIcon.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)

        spacerItem = QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)

        # add to horizontal layout
        self.horizontalLayout.addWidget(self.expandToggleButton)
        self.horizontalLayout.addWidget(self.folderIcon)
        self.horizontalLayout.addItem(spacerItem)
        self.titleFrame.setFixedHeight(self.titleFrame.sizeHint().height())

        self.setMinimumSize(self.titleFrame.sizeHint().width(), self.titleFrame.sizeHint().height() + 3)

        self.horizontalLayout.addWidget(self.groupTextEdit)
        self.horizontalLayout.addLayout(self.titleExtrasLayout)
        self.horizontalLayout.addWidget(self.deleteBtn)

        self.horizontalLayout.setStretchFactor(self.groupTextEdit, 4)
Example #6
0
    def buildTitleFrame(self):
        """ Builds the title part of the layout with a QFrame widget
        """

        self.titleFrame.setContentsMargins(1, 1, 1, 1)

        # the horizontal layout
        self.horizontalLayout = qtutils.hBoxLayout(self.titleFrame)
        # the icon and title and spacer
        self.expandToggleButton.setParent(self.titleFrame)
        if self.collapsed:
            self.expandToggleButton.setIconByName(self._collapsedIconName)
        else:
            self.expandToggleButton.setIconByName(self._expandIconName)

        spacerItem = QtWidgets.QSpacerItem(10, 10,
                                           QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Minimum)

        # add to horizontal layout
        self.horizontalLayout.addWidget(self.expandToggleButton)
        self.horizontalLayout.addWidget(self.itemIcon)
        self.horizontalLayout.addItem(spacerItem)
        self.titleFrame.setFixedHeight(self.titleFrame.sizeHint().height())
        self.titleFrame.setObjectName("title")

        self.setMinimumSize(self.titleFrame.sizeHint().width(),
                            self.titleFrame.sizeHint().height() + 1)

        self.horizontalLayout.addWidget(self.stackTitleWgt)
        self.horizontalLayout.addLayout(self.titleExtrasLayout)
        self.horizontalLayout.addWidget(self.shiftUpBtn)
        self.horizontalLayout.addWidget(self.shiftDownBtn)
        self.horizontalLayout.addWidget(self.deleteBtn)

        self.horizontalLayout.setStretchFactor(self.stackTitleWgt, 4)