def __init__(self):
        super(LandmarkLocationWidget, self).__init__()
        self._active = False
        self._font = QFont()
        self._font.setPointSize(10)

        self.indexLabel = QLabel()
        self.indexLabel.setMaximumWidth(8)
        self.indexLabel.setMinimumWidth(8)

        self.doneButton = QPushButton("Done")
        self.doneButton.setMaximumWidth(50)
        self.doneButton.setFont(self._font)
        self.doneButton.clicked.connect(self.doneButtonClicked)

        self.fixedButton = QPushButton("")
        self.fixedButton.setFont(self._font)
        self.movingButton = QPushButton("")
        self.movingButton.setFont(self._font)

        layout = QGridLayout()
        layout.setAlignment(Qt.AlignTop)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setHorizontalSpacing(4)
        layout.setVerticalSpacing(0)
        layout.addWidget(self.indexLabel, 0, 0)
        layout.addWidget(self.fixedButton, 0, 1)
        layout.addWidget(self.movingButton, 0, 2)
        layout.addWidget(self.doneButton, 0, 3)
        self.setLayout(layout)
        self._updateState()
Example #2
0
 def __init__(self, *args, **kwargs ):
     
     self.uiInfoPath = Window.infoBaseDir + '/Widget_ctlListGroup.json'
     
     QWidget.__init__( self, *args, **kwargs )
     mainLayout = QVBoxLayout( self )
     buttonLayout = QHBoxLayout()
     gridLayout = QGridLayout()
     mainLayout.addLayout( buttonLayout )
     mainLayout.addLayout( gridLayout )
     
     gridLayout.setSpacing(5)
     gridLayout.setVerticalSpacing(5)
     
     b_addList = QPushButton( "Add List" )
     b_removeList = QPushButton( "Remove List" )
     buttonLayout.addWidget( b_addList )
     buttonLayout.addWidget( b_removeList )
     
     w_ctlList = Widget_ctlList()
     gridLayout.addWidget( w_ctlList )
 
     self.__gridLayout = gridLayout
     
     QtCore.QObject.connect( b_addList,    QtCore.SIGNAL( "clicked()" ), self.addList )
     QtCore.QObject.connect( b_removeList, QtCore.SIGNAL( "clicked()" ), self.removeList )
     
     self.loadInfo()
Example #3
0
class Board(QWidget):
	def __init__(self, theme, parent=None):
		super(Board, self).__init__(parent)

		self.theme = theme
		self.num = 8

		self.lay = QGridLayout(self)
		self.lay.setContentsMargins(15, 10, 15, 10)
		self.lay.setHorizontalSpacing(0)
		self.lay.setVerticalSpacing(0)

		self.setLayout(self.lay)

		self.diamonds = []
		self.selected = None
		self.generateDiamonds(self.num)

	def generateDiamonds(self, num):
		for y in range(0, num):
			for x in range(0, num):
				diamond = Diamond(random.choice(Colors), self.theme, self)
				diamond.clicked.connect(self.diamondClicked)
				self.lay.addWidget(diamond, x, y)

				self.diamonds.append(diamond)

	def paintEvent(self, event):
		painter = QPainter()

		painter.begin(self)
		self.theme.render(painter, "kdiamond-border")
		painter.end()

	@Slot(Diamond)
	def diamondClicked(self, diamond):
		if self.selected is diamond:
			self.selected = None
			diamond.select(False)
			diamond.update()
		else:
			if self.selected is not None:
				if self.selected.color is diamond.color:
					self.selected.hide()
					diamond.hide()
					self.selected = None
					return

				self.selected.select(False)
				self.selected.update()

			diamond.select(True)
			diamond.update()
			self.selected = diamond
Example #4
0
  def buildRightDataDisplays(self):
    grid = QGridLayout()

    for index, display in enumerate(constants.RIGHT_DATA_DISPLAYS):
      units = display['units'] if 'units' in display else ''
      widget = QSmallDataDisplay(self, display['label'], units)

      self.dataDisplays[display['field']] = widget
      grid.addWidget(widget, int(index / constants.RIGHT_DATA_DISPLAYS_PER_ROW), index % constants.RIGHT_DATA_DISPLAYS_PER_ROW)

    grid.setHorizontalSpacing(1)
    grid.setVerticalSpacing(1)

    return grid
Example #5
0
    def create_grid_layout(self, rows=0, columns=1, v_margin=0, h_margin=0):
        """ Returns a new GUI toolkit neutral grid layout manager which
            supports a (rows,columns) sized grid, with each grid element
            having (v_margin,h_margin) pixels of space around it.

            If rows is 0, the number of rows is not predefined, but will be
            determined by the actual number of controls added to the layout.
        """
        layout = QGridLayout()
        layout.setHorizontalSpacing(h_margin)
        layout.setVerticalSpacing(v_margin)
        layout.setAlignment(Qt.AlignTop)
        ### PYSIDE: layout.setMargin( 4 )

        return layout_adapter(layout, columns=columns)
Example #6
0
    def buildRightDataDisplays(self):
        grid = QGridLayout()

        for index, display in enumerate(constants.RIGHT_DATA_DISPLAYS):
            units = display['units'] if 'units' in display else ''
            widget = QSmallDataDisplay(self, display['label'], units)

            self.dataDisplays[display['field']] = widget
            grid.addWidget(widget,
                           int(index / constants.RIGHT_DATA_DISPLAYS_PER_ROW),
                           index % constants.RIGHT_DATA_DISPLAYS_PER_ROW)

        grid.setHorizontalSpacing(1)
        grid.setVerticalSpacing(1)

        return grid
    def __init__(self):
        super(SliderWidget, self).__init__()

        self.label = QLabel()
        self.slider = QSlider(Qt.Horizontal)
        self.spinbox = QSpinBox()

        self.slider.valueChanged.connect(self.changedValue)
        self.spinbox.valueChanged.connect(self.changedValue)

        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setVerticalSpacing(0)
        layout.addWidget(self.label, 0, 0)
        layout.addWidget(self.slider, 0, 1)
        layout.addWidget(self.spinbox, 0, 2)
        self.setLayout(layout)
	def __init__(self):
		super(SliderWidget, self).__init__()

		self.label = QLabel()
		self.slider = QSlider(Qt.Horizontal)
		self.spinbox = QSpinBox()

		self.slider.valueChanged.connect(self.changedValue)
		self.spinbox.valueChanged.connect(self.changedValue)

		layout = QGridLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setVerticalSpacing(0)
		layout.addWidget(self.label, 0, 0)
		layout.addWidget(self.slider, 0, 1)
		layout.addWidget(self.spinbox, 0, 2)
		self.setLayout(layout)
	def __init__(self):
		super(LandmarkLocationWidget, self).__init__()
		self._active = False
		self._font = QFont()
		self._font.setPointSize(10)

		self.indexLabel = QLabel()
		self.indexLabel.setMaximumWidth(10)
		self.indexLabel.setMinimumWidth(10)

		self.doneButton = QPushButton("Done")
		self.doneButton.setMaximumWidth(50)
		self.doneButton.setFont(self._font)
		self.doneButton.clicked.connect(self.doneButtonClicked)

		self.deleteButton = QPushButton("X")
		self.deleteButton.setMaximumWidth(15)
		self.deleteButton.setMinimumWidth(15)
		self.deleteButton.setMaximumHeight(15)
		self.deleteButton.setMinimumHeight(15)
		self.deleteButton.setFont(self._font)
		self.deleteButton.setVisible(False)
		self.deleteButton.clicked.connect(self.deleteButtonClicked)

		self.fixedButton = SpecialButton()
		self.fixedButton.setFont(self._font)
		self.movingButton = SpecialButton()
		self.movingButton.setFont(self._font)

		layout = QGridLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setVerticalSpacing(0)
		layout.addWidget(self.deleteButton, 0, 0)
		layout.addWidget(self.indexLabel, 0, 1)
		layout.addWidget(self.fixedButton, 0, 2)
		layout.addWidget(self.movingButton, 0, 3)
		layout.addWidget(self.doneButton, 0, 4)
		self.setLayout(layout)
		self._updateState()
	def __init__(self):
		super(SliderFloatWidget, self).__init__()

		self.label = QLabel()
		self.slider = QSlider(Qt.Horizontal)
		self.spinbox = QDoubleSpinBox()

		self.slider.valueChanged.connect(self.changedValueFromSlider)
		self.spinbox.valueChanged.connect(self.changedValueFromSpinBox)

		# Keep track of whether one of the values was changed
		# By setting the value of the slider and the spinbox, valueChanged
		# events are fired. These events have to be ignored
		self._changed = False

		layout = QGridLayout()
		layout.setContentsMargins(0, 0, 0, 0)
		layout.setVerticalSpacing(0)
		layout.addWidget(self.label, 0, 0)
		layout.addWidget(self.slider, 0, 1)
		layout.addWidget(self.spinbox, 0, 2)
		self.setLayout(layout)
Example #11
0
    def __init__(self):
        super(SliderFloatWidget, self).__init__()

        self.label = QLabel()
        self.slider = QSlider(Qt.Horizontal)
        self.spinbox = QDoubleSpinBox()

        self.slider.valueChanged.connect(self.changedValueFromSlider)
        self.spinbox.valueChanged.connect(self.changedValueFromSpinBox)

        # Keep track of whether one of the values was changed
        # By setting the value of the slider and the spinbox, valueChanged
        # events are fired. These events have to be ignored
        self._changed = False

        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setVerticalSpacing(0)
        layout.addWidget(self.label, 0, 0)
        layout.addWidget(self.slider, 0, 1)
        layout.addWidget(self.spinbox, 0, 2)
        self.setLayout(layout)
Example #12
0
class MShape(QWidget, MAnimate):
    def __init__(self):
        QWidget.__init__(self)
        self.__x = 0
        self.__y = 0
        self.__width = 0
        self.__height = 0
        self.__opacity = 1.0
        self.__clip = None
        self.__max_width = 0
        self.__max_height = 0
        self.__min_width = 0
        self.__min_height = 0
        self.__max_opacity = 1.0
        self.__min_opacity = 0.0
        self.__margin_left = 0
        self.__margin_top = 0
        self.__padding_x = 0
        self.__padding_y = 0
        # Defining the layout which will hold the child shapes of the widget
        self.__layout = QGridLayout()
        self.__layout.setVerticalSpacing(0)
        self.__layout.setHorizontalSpacing(0)
        self.__layout.setContentsMargins(QMargins(0, 0, 0, 0))
        self.__children = []

    def add_layout_item(self, shape, x, y):
        self.__layout.addWidget(shape, x, y)
        self.__children.append(shape)
        self.update()

    def remove_layout_item(self, shape):
        self.__layout.removeWidget(shape)
        self.__children.remove(shape)
        shape.deleteLater()
        self.update()

    @property
    def x(self):
        return self.__x

    @x.setter
    def x(self, x):
        self.__x = x

    @property
    def y(self):
        return self.__y

    @y.setter
    def y(self, y):
        self.__y = y

    @property
    def layout(self):
        return self.__layout

    @property
    def width(self):
        return self.__width

    @width.setter
    def width(self, width):
        self.__width = width
        if self.width < self.min_width:
            self.__width = self.min_width
        elif self.width > self.max_width:
            self.__width = self.max_width

    @property
    def min_width(self):
        return self.__min_width

    @min_width.setter
    def min_width(self, width):
        self.__min_width = width

    @property
    def max_width(self):
        return self.__max_width

    @max_width.setter
    def max_width(self, width):
        self.__max_width = width

    @property
    def height(self):
        return self.__height

    @height.setter
    def height(self, height):
        self.__height = height
        if self.height < self.min_height:
            self.__height = self.min_height
        elif self.height > self.max_height:
            self.__height = self.max_height

    @property
    def min_height(self):
        return self.__min_height

    @min_height.setter
    def min_height(self, height):
        self.__min_height = height

    @property
    def max_height(self):
        return self.__max_height

    @max_height.setter
    def max_height(self, height):
        self.__max_height = height

    @property
    def opacity(self):
        return self.__opacity

    @opacity.setter
    def opacity(self, opacity):
        self.__opacity = opacity
        if self.opacity < self.min_opacity:
            self.opacity = self.min_opacity

    @property
    def min_opacity(self):
        return self.__min_opacity

    @min_opacity.setter
    def min_opacity(self, opacity):
        self.__min_opacity = opacity

    @property
    def max_opacity(self):
        return self.__max_opacity

    @max_opacity.setter
    def max_opacity(self, opacity):
        self.__max_opacity = opacity

    @property
    def margin_left(self):
        return self.__margin_left

    @margin_left.setter
    def margin_left(self, margin):
        self.__margin_left = margin

    @property
    def margin_top(self):
        return self.__margin_top

    @margin_top.setter
    def margin_top(self, margin):
        self.__margin_top = margin

    @property
    def clip(self):
        return self.__clip

    @clip.setter
    def clip(self, value):
        self.__clip = value