Beispiel #1
0
    def __init__(self, parent):
        super(ItemHolder, self).__init__(parent)

        layout = QtWidgets.QGraphicsLinearLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
Beispiel #2
0
    def __init__(self, parent, graph, name, color, dataType,
                 connectionPointType):
        super(BasePort, self).__init__(parent)

        self._node = parent
        self._graph = graph
        self._name = name
        self._dataType = dataType
        self._connectionPointType = connectionPointType

        self.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Fixed))

        layout = QtWidgets.QGraphicsLinearLayout()
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self._color = color

        self._inCircle = None
        self._outCircle = None
        self._labelItem = None

        self._inCircleHolder = ItemHolder(self)
        self._outCircleHolder = ItemHolder(self)
        self._labelItemHolder = ItemHolder(self)

        self.layout().addItem(self._inCircleHolder)
        self.layout().setAlignment(
            self._inCircleHolder, QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)

        self.layout().addItem(self._labelItemHolder)
        self.layout().setAlignment(
            self._labelItemHolder,
            QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)

        self.layout().addItem(self._outCircleHolder)
        self.layout().setAlignment(
            self._outCircleHolder,
            QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
Beispiel #3
0
    def __init__(self, parent, match):
        super().__init__(parent)
        self.setBackgroundBrush(QtGui.QBrush(Qt.darkGray))
        self.match = match
        self.combat = match.combat
        self.match.stateChanged.connect(self._refresh)

        fm = QtGui.QFontMetrics(self.font())
        group = misc.VerticalGroup(alignment=Qt.AlignLeft)
        self.addItem(group)

        self.title1 = misc.Title()
        group.addItem(self.title1)
        self.enemies = stock.Stock(EnemyItem.size(fm))
        group.addItem(self.enemies)
        self.title2 = misc.Title()
        group.addItem(self.title2)

        # Button bar
        buttonBar = QtWidgets.QGraphicsWidget()
        layout = QtWidgets.QGraphicsLinearLayout(Qt.Horizontal, buttonBar)
        self.okButton = QtWidgets.QPushButton(self.tr("Ok"))
        self.okButton.clicked.connect(
            lambda: self.match.combatNext())  # does not work without lambda!
        self.skipButton = QtWidgets.QPushButton(self.tr("Skip"))
        self.skipButton.clicked.connect(
            lambda: self.match.combatSkip())  # same
        for button in self.okButton, self.skipButton:
            proxy = QtWidgets.QGraphicsProxyWidget()
            proxy.setWidget(button)
            layout.addItem(proxy)
        group.addItem(buttonBar)
        layout.activate(
        )  # otherwise the following item will be positioned on top of the buttons

        self.stock = stock.Stock(EnemyItem.size(fm))
        group.addItem(self.stock)
        self.combat.enemiesChanged.connect(self._refresh)

        self._refresh()
Beispiel #4
0
	def __init__(
			self,
			move_x,
			move_y,

			min_size=20,
			max_size=None,
			color='black',
			min_rotate=0,
			max_rotate=None,
			duration=1000,
			if_rotate=True,

			parent=None):
		super(ShapeAnimation, self).__init__(parent)
		if max_size is None:
			max_size = min_size
		if max_rotate is None:
			max_rotate = min_rotate
		self.if_rotate = if_rotate
		# set random value
		rotate = random.randint(min_rotate, max_rotate)
		size = random.randint(min_size, max_size)
		# set type shape 1= square 2 = circle 3 =triangle
		type_ = random.randint(1, 3)
		# set style for shape
		if type_ == 1:
			style = 'background:{};'.format(color)
		elif type_ == 2:
			style = 'background:qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0.999499 {}, stop:1 rgba(255, 255, 255, 0));'.format(
				color
			)
		elif type_ == 3:
			style = 'background:qconicalgradient(cx:0.5 , cy:0, angle:244, stop:0.145 {}, stop:0.1451 rgba(50, 52, 58, 0));'.format(
				color
			)

		# set scene for shape
		# it is need for rotate shape
		val = size / 100
		# hide visibility
		self.setStyleSheet('background:rgba(27, 28, 35, 0); border:none')

		self.resize(145 * val / 1.0000005536974035, 145 * val / 1.0000005536974035)

		self.scene = QtWidgets.QGraphicsScene()
		self.scene.setSceneRect(0, 0, 115 * val / 1.1949939621227593, 115 * val / 1.1949939621227593)

		self.view = QtWidgets.QGraphicsView()
		self.view.setRenderHint(QtGui.QPainter.HighQualityAntialiasing)
		self.view.setScene(self.scene)
		self.view.setSceneRect(0, 0, 00, 0)
		# self.view.setAlignment(Qt.AlignTop | Qt.AlignLeft)
		scene_layout = QtWidgets.QGraphicsLinearLayout(QtCore.Qt.Horizontal)

		form = QtWidgets.QGraphicsWidget()
		form.setLayout(scene_layout)

		self.scene.addItem(form)

		self.main_layout = QtWidgets.QHBoxLayout()
		self.main_layout.addWidget(self.view)

		self.main_layout.setSpacing(0)
		self.main_layout.setContentsMargins(0, 0, 0, 0)
		self.setLayout(self.main_layout)
		# set shape
		self.shape = QtWidgets.QLabel()
		self.shape.resize(size, size)
		self.shape.setStyleSheet(style)
		# set cursor
		pixmap = QtGui.QPixmap(BASE_DIR+r'\media\cur\1.png').scaled(20, 20) 
		cursor = QtGui.QCursor(pixmap)
		self.shape.setCursor(cursor)
		# set rotate shape
		self.shape.setMinimumSize(QtCore.QSize(self.shape.width(), self.shape.height()))

		scene_layout.setContentsMargins(0, 0, 0, 0)

		self.proxy_rb1 = self.scene.addWidget(self.shape)
		self.proxy_rb1.setRotation(rotate)
		self.proxy_rb1.setTransformOriginPoint(self.shape.width() / 2, self.shape.height() / 2)

		scene_layout.addItem(self.proxy_rb1)

		# animation

		self.menuAnimation = QtCore.QVariantAnimation()
		self.menuAnimation.setDuration(duration)

		self.menuAnimation.valueChanged.connect(self.value_change)
		self.menuAnimation.finished.connect(self.again)
		# set standard value for animation
		self.poi_x = move_x
		self.poi_y = move_y
		self.deg = random.randint(0, 360)
		self.mor_les = 1
		#
		self.start_fun()
Beispiel #5
0
	def __init__(
			self,

			color='black',
			duration=1000,

			size=50,
			rotate=0,
			pause=0,
			distance=1,
			size_back=1.2,
			triangle=True,
			circle=True,
			parent=None


	):
		super(LoadFigure, self).__init__(parent)
		# set start value
		self.size = size
		self.color = color
		self.duration = duration
		self.pause = pause
		self.triangle = triangle
		self.circle = circle
		self.distance = distance
		val = size / 100

		# hide visibility
		self.setStyleSheet('background:rgba(27, 28, 35, 0); border:none')
		self.setFixedWidth(round(size*size_back))
		#self.setFixedHeight(50)
		# set scene for shape

		self.resize(145 * val / 1.0000005536974035, 145 * val / 1.0000005536974035)

		self.scene = QtWidgets.QGraphicsScene()
		self.scene.setSceneRect(0, 0, 115 * val / 1.1949939621227593, 115 * val / 1.1949939621227593)

		self.view = QtWidgets.QGraphicsView()
		self.view.setRenderHint(QtGui.QPainter.HighQualityAntialiasing)
		self.view.setScene(self.scene)
		self.view.setSceneRect(0, 0, 0, 0)
		# self.view.setAlignment(Qt.AlignTop | Qt.AlignLeft)
		scene_layout = QtWidgets.QGraphicsLinearLayout(QtCore.Qt.Horizontal)

		form = QtWidgets.QGraphicsWidget()
		form.setLayout(scene_layout)

		self.scene.addItem(form)

		self.main_layout = QtWidgets.QGridLayout()
		self.main_layout.addWidget(self.view)

		self.main_layout.setSpacing(0)
		self.main_layout.setContentsMargins(0, 0, 0, 0)
		self.setLayout(self.main_layout)
		# set shape
		self.shape = QtWidgets.QLabel()
		self.shape.resize(size, size)
		self.shape.setStyleSheet('background:{};'.format(self.color))
		# set rotate shape
		self.shape.setMinimumSize(QtCore.QSize(self.shape.width(), self.shape.height()))

		scene_layout.setContentsMargins(0, 0, 0, 0)

		self.proxy_rb1 = self.scene.addWidget(self.shape)
		self.proxy_rb1.setRotation(rotate)
		self.proxy_rb1.setTransformOriginPoint(self.shape.width() / 2, self.shape.height() / 2)

		scene_layout.addItem(self.proxy_rb1)

		# animation
		self.frame = 0
		self.start_fun()