Example #1
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 #2
0
def GridLayout(parent=None, margins=(0, 0, 0, 0), spacing=uiconstants.SREG, columnMinWidth=None):
    """One liner for QtWidgets.QGridLayout() to make it easier to create an easy Grid layout
    DPI (4k) is handled here
    Defaults use regular spacing and no margins

    :param margins:  override the margins with this value
    :type margins: tuple
    :param spacing: override the spacing with this pixel value
    :type spacing: int
    :param columnMinWidth: option for one column number then it's min width, use obj.setColumnMinimumWidth for more
    :type columnMinWidth: tuple
    """
    zooGridLayout = QtWidgets.QGridLayout()
    zooGridLayout.setContentsMargins(*utils.marginsDpiScale(*margins))
    zooGridLayout.setSpacing(utils.dpiScale(spacing))
    if columnMinWidth:  # column number then the width in pixels
        zooGridLayout.setColumnMinimumWidth(columnMinWidth[0], utils.dpiScale(columnMinWidth[1]))
    return zooGridLayout