コード例 #1
0
    def ExpandAndCollapseAll(self,expand):
        toggleAll_animation = QtCore.QParallelAnimationGroup(self)

        toggleAll_animation.setDirection(
            QtCore.QAbstractAnimation.Forward if expand else QtCore.QAbstractAnimation.Backward)

        if self.HidingBox.isOpen: hbox_ch=self.HidingBox.content_height
        else: hbox_ch=0
        
        if not expand: #Hiding box need to be first when collapsing and last when Expanding
            for anim in self.ExpandAndCollapseAll_AnimationSet(self.HidingBox,expand): toggleAll_animation.addAnimation(anim)

        for anim in self.ExpandAndCollapseAll_AnimationSet(self.DataInput,expand): toggleAll_animation.addAnimation(anim)
        for anim in self.ExpandAndCollapseAll_AnimationSet(self.InputRegisters,expand): toggleAll_animation.addAnimation(anim)
        if not self.isSkeleton:
            for anim in self.ExpandAndCollapseAll_AnimationSet(self.allUserInput,expand): toggleAll_animation.addAnimation(anim)
            for anim in self.ExpandAndCollapseAll_AnimationSet(self.Outputs,expand): toggleAll_animation.addAnimation(anim)
            for anim in self.ExpandAndCollapseAll_AnimationSet(self.RegexChecks,expand): toggleAll_animation.addAnimation(anim)
        self.DataInput.isOpen=expand
        self.InputRegisters.isOpen=expand
        if not self.isSkeleton:
            self.allUserInput.isOpen=expand
            self.Outputs.isOpen=expand
            self.RegexChecks.isOpen=expand

        if expand: 
            for anim in self.ExpandAndCollapseAll_AnimationSet(self.HidingBox,expand, override=self.HidingBox.isOpen, startHeightOffset=hbox_ch): 
                toggleAll_animation.addAnimation(anim)
        
        self.HidingBox.isOpen=expand
        
        toggleAll_animation.start()
        
        self.HidingBox.updateAnimation(0, self.HidingBox.content_height)
コード例 #2
0
    def __init__(self, title="", parent=None):
        super(CollapsibleBox, self).__init__(parent)

        self.toggle_button = QtWidgets.QToolButton(text=title,
                                                   checkable=True,
                                                   checked=False)
        self.toggle_button.setStyleSheet("QToolButton { border: none; }")
        self.toggle_button.setToolButtonStyle(
            QtCore.Qt.ToolButtonTextBesideIcon)
        self.toggle_button.setArrowType(QtCore.Qt.RightArrow)
        self.toggle_button.pressed.connect(self.on_pressed)

        self.toggle_animation = QtCore.QParallelAnimationGroup(self)

        self.content_area = QtWidgets.QScrollArea(maximumHeight=0,
                                                  minimumHeight=0)
        self.content_area.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                        QtWidgets.QSizePolicy.Fixed)
        self.content_area.setFrameShape(QtWidgets.QFrame.NoFrame)

        lay = QtWidgets.QVBoxLayout(self)
        lay.setSpacing(0)
        lay.setContentsMargins(0, 0, 0, 0)
        lay.addWidget(self.toggle_button)
        lay.addWidget(self.content_area)

        self.toggle_animation.addAnimation(
            QtCore.QPropertyAnimation(self, b"minimumHeight"))
        self.toggle_animation.addAnimation(
            QtCore.QPropertyAnimation(self, b"maximumHeight"))
        self.toggle_animation.addAnimation(
            QtCore.QPropertyAnimation(self.content_area, b"maximumHeight"))
コード例 #3
0
ファイル: view_model.py プロジェクト: Satbek/kttm
    def applyAnimation(self, particle_scenes):
        logging.info(
            "Applying animation, scenes count: {0}, particles count: {1}".
            format(len(particle_scenes), len(particle_scenes[0])))
        logging.debug(
            "Start particles pos:{0},\n end particles pos:{1}".format(
                [(np.round(p.x, 2), np.round(p.y, 2))
                 for p in particle_scenes[0]],
                [(np.round(p.x, 2), np.round(p.y, 2))
                 for p in particle_scenes[-1]],
            ))
        for i, particles_scene in enumerate(particle_scenes[:-1]):
            sceneAnimation = QtCore.QParallelAnimationGroup()
            for j, v in enumerate(zip(particles_scene, self.particles)):
                model, particle = v
                particle_anim = QtCore.QPropertyAnimation(particle, b"pos")
                particle_anim.setDuration(self.anim_time)
                particle_anim.setStartValue(QPointF(model.x, model.y))
                particle_anim.setEndValue(
                    QPointF(
                        particle_scenes[i + 1][j].x,
                        particle_scenes[i + 1][j].y,
                    ))
                sceneAnimation.addAnimation(particle_anim)
            self.anim_group.addAnimation(sceneAnimation)

        for model, particle in zip(particle_scenes[-1], self.particles):
            particle.model = model
        self.anim_group.start()
コード例 #4
0
ファイル: stock.py プロジェクト: Stoeoef/mageknight
 def __init__(self, objectSize):
     super().__init__()
     self.objectSize = objectSize
     self._anims = QtCore.QParallelAnimationGroup(self)
     self._cols = None
     self._rows = None
     self.setRowCount(1)
コード例 #5
0
 def vehicle_move(self, states):
     self.hide_vehicleLabel()
     states = [s for s in states if s["type"] != "ARRIVAL"]
     if len(states) > 0:
         self.animations = QtCore.QParallelAnimationGroup()
         for state in states:
             self.animations.addAnimation(self.anima(state, 10 * 1000))
         self.animations.start()
コード例 #6
0
 def start(cls):
     group = QtCore.QParallelAnimationGroup()
     for i, a in enumerate(cls.animations):
         if i == 0:
             scene = a.parent()
             group.setParent(scene)
         scene.addItem(a.targetObject())
         group.addAnimation(a)
     group.start(group.DeleteWhenStopped)
コード例 #7
0
	def slideInWgt(self, newwidget):
		if self.m_active:
			return

		self.m_active = True

		_now = self.currentIndex()
		_next = self.indexOf(newwidget)

		if _now == _next:
			self.m_active = False
			return

		offsetx, offsety = self.frameRect().width(), self.frameRect().height()
		self.widget(_next).setGeometry(self.frameRect())

		if not self.m_direction == QtCore.Qt.Horizontal:
			if _now < _next:
				offsetx, offsety = 0, -offsety
			else:
				offsetx = 0
		else:
			if _now < _next:
				offsetx, offsety = -offsetx, 0
			else:
				offsety = 0

		pnext = self.widget(_next).pos()
		pnow = self.widget(_now).pos()
		self.m_pnow = pnow

		offset = QtCore.QPoint(offsetx, offsety)
		self.widget(_next).move(pnext - offset)
		self.widget(_next).show()
		self.widget(_next).raise_()

		anim_group = QtCore.QParallelAnimationGroup(
			self, finished=self.animationDoneSlot
		)

		for index, start, end in zip(
			(_now, _next), (pnow, pnext - offset), (pnow + offset, pnext)
		):
			animation = QtCore.QPropertyAnimation(
				self.widget(index),
				b"pos",
				duration=self.m_speed,
				easingCurve=self.m_animationtype,
				startValue=start,
				endValue=end,
			)
			anim_group.addAnimation(animation)

		self.m_next = _next
		self.m_now = _now
		self.m_active = True
		anim_group.start(QtCore.QAbstractAnimation.DeleteWhenStopped)
コード例 #8
0
ファイル: qt_collapsible_box.py プロジェクト: Fine112358/dnf-
    def __init__(self,
                 title="",
                 title_backgroup_color="",
                 tool_tip="点击展开/折叠",
                 animation_duration_millseconds=250,
                 parent=None):
        super(CollapsibleBox, self).__init__(parent)

        self.title = title

        self.setToolTip(tool_tip)

        self.animation_duration_millseconds = animation_duration_millseconds

        self.collapsed_height = 19

        self.toggle_button = QtWidgets.QToolButton(self)
        self.toggle_button.setText(title)

        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        self.toggle_button.setSizePolicy(sizePolicy)

        self.toggle_button.setCheckable(True)
        self.toggle_button.setChecked(False)
        self.toggle_button.setStyleSheet(
            f"QToolButton {{ border: none; font-weight: bold; background-color: {title_backgroup_color}; }}"
        )
        self.toggle_button.setToolButtonStyle(
            QtCore.Qt.ToolButtonTextBesideIcon)
        self.toggle_button.setArrowType(QtCore.Qt.RightArrow)
        self.toggle_button.pressed.connect(self.on_pressed)

        self.toggle_animation = QtCore.QParallelAnimationGroup(self)

        self.content_area = QtWidgets.QScrollArea(self)
        self.content_area.setMaximumHeight(0)
        self.content_area.setMinimumHeight(0)
        self.content_area.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                        QtWidgets.QSizePolicy.Fixed)
        self.content_area.setFrameShape(QtWidgets.QFrame.NoFrame)

        lay = QtWidgets.QVBoxLayout(self)
        lay.setSpacing(0)
        lay.setContentsMargins(0, 0, 0, 0)
        lay.addWidget(self.toggle_button)
        lay.addWidget(self.content_area)

        self.toggle_animation.addAnimation(
            QtCore.QPropertyAnimation(self, b"minimumHeight"))
        self.toggle_animation.addAnimation(
            QtCore.QPropertyAnimation(self, b"maximumHeight"))
        self.toggle_animation.addAnimation(
            QtCore.QPropertyAnimation(self.content_area, b"maximumHeight"))
コード例 #9
0
ファイル: lotusHub.py プロジェクト: nipunaw/Lotus
 def animation_ui(self, flag):
     if flag == 1:
         self.fade_1 = Animations.fade_in(self, self.welcome_text)
         self.fade_2 = Animations.fade_in(self, self.line)
         self.fade_3 = Animations.fade_in(self, self.confirm_button)
         self.fade_logo = Animations.fade_in(self, self.logo)
         self.animationGroup_1 = QtCore.QParallelAnimationGroup()
         self.animationGroup_1.addAnimation(self.fade_1)
         self.animationGroup_1.addAnimation(self.fade_2)
         self.animationGroup_1.addAnimation(self.fade_3)
         self.animationGroup_1.addAnimation(self.fade_logo)
         self.animationGroup_1.start()
     elif flag == 2:
         self.fade_4 = Animations.fade_out(self, self.welcome_text)
         self.fade_5 = Animations.fade_out(self, self.line)
         self.fade_6 = Animations.fade_out(self, self.confirm_button)
         self.fade_out_logo = Animations.fade_out(self, self.logo)
         self.animationGroup_2 = QtCore.QParallelAnimationGroup()
         self.animationGroup_2.addAnimation(self.fade_4)
         self.animationGroup_2.addAnimation(self.fade_5)
         self.animationGroup_2.addAnimation(self.fade_6)
         self.animationGroup_2.addAnimation(self.fade_out_logo)
         self.animationGroup_2.start()
     else:
         self.fade_7 = Animations.fade_in(self, self.new_note_button)
         self.fade_8 = Animations.fade_in(self, self.schedule_button)
         self.fade_9 = Animations.fade_in(self, self.previous_notes_button)
         self.fade_10 = Animations.fade_in(self, self.schedule_background)
         self.fade_11 = Animations.fade_in(self, self.new_note_text)
         self.fade_12 = Animations.fade_in(self, self.schedule_text)
         self.fade_13 = Animations.fade_in(self, self.previous_notes_text)
         self.fade_14 = Animations.fade_in(self, self.user_welcome)
         self.animationGroup_3 = QtCore.QParallelAnimationGroup()
         self.animationGroup_3.addAnimation(self.fade_7)
         self.animationGroup_3.addAnimation(self.fade_8)
         self.animationGroup_3.addAnimation(self.fade_9)
         self.animationGroup_3.addAnimation(self.fade_10)
         self.animationGroup_3.addAnimation(self.fade_11)
         self.animationGroup_3.addAnimation(self.fade_12)
         self.animationGroup_3.addAnimation(self.fade_13)
         self.animationGroup_3.addAnimation(self.fade_14)
         self.animationGroup_3.start()
コード例 #10
0
	def __init__(self, leds, debug=False):
		BaseAnimation.__init__(self)

		self.leds = leds
		self.debug = debug
		self.animations = qcore.QParallelAnimationGroup()

		QColorTransform._static_animation_tracker.append(self)
		self.animations.finished.connect(self.finished)
		
		print("QColorTransform started")
コード例 #11
0
ファイル: spoiler.py プロジェクト: Parazoid/AnimatedChatroom
    def __init__(self, parent=None, title="Spoiler", animation_duration=300):
        """
        References:
            Adapted from PyQt4 version:
            https://stackoverflow.com/a/37927256 ("Erotemic")
            ...which was in turn adapted from the C++ version:
            https://stackoverflow.com/a/37119983 ("x squared")
        """
        super(Spoiler, self).__init__(parent=parent)

        self.animation_duration = animation_duration
        self.toggleAnimation = QtCore.QParallelAnimationGroup()
        self.contentArea = QtWidgets.QScrollArea()
        self.headerLine = QtWidgets.QFrame()
        self.toggleButton = QtWidgets.QToolButton()
        self.mainLayout = QtWidgets.QGridLayout()

        self.toggleButton.setStyleSheet("QToolButton { border: none; }")
        self.toggleButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        self.toggleButton.setArrowType(QtCore.Qt.RightArrow)
        self.toggleButton.setText(str(title))
        self.toggleButton.setCheckable(True)
        self.toggleButton.setChecked(False)

        self.headerLine.setFrameShape(QtWidgets.QFrame.HLine)
        self.headerLine.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.headerLine.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Maximum)

        self.contentArea.setStyleSheet("QScrollArea { background-color: white; border: none; }")
        self.contentArea.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)

        # start out collapsed
        self.contentArea.setMaximumHeight(0)
        self.contentArea.setMinimumHeight(0)

        # let the entire widget grow and shrink with its content
        self.toggleAnimation.addAnimation(QtCore.QPropertyAnimation(self, b"minimumHeight"))
        self.toggleAnimation.addAnimation(QtCore.QPropertyAnimation(self, b"maximumHeight"))
        self.toggleAnimation.addAnimation(QtCore.QPropertyAnimation(self.contentArea, b"maximumHeight"))

        # don't waste space
        self.mainLayout.setVerticalSpacing(0)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        row = 0
        self.mainLayout.addWidget(self.toggleButton, row, 0, 1, 1, QtCore.Qt.AlignLeft)
        self.mainLayout.addWidget(self.headerLine, row, 2, 1, 1)
        row += 1
        self.mainLayout.addWidget(self.contentArea, row, 0, 1, 3)
        self.setLayout(self.mainLayout)

        self.toggleButton.clicked.connect(self.start_animation)
コード例 #12
0
    def __init__(self, title, animationDuration, parent: QWidget):
        super().__init__(parent)
        self._animationDuration = animationDuration
        self._toggleButton = QCheckBox(title, self)
        headerLine = QFrame(self)
        self._toggleAnimation = QtCore.QParallelAnimationGroup(self)
        self._contentArea = QScrollArea(self)
        mainLayout = QGridLayout(self)

        self._toggleButton.setCheckable(True)
        self._toggleButton.setChecked(True)

        headerLine.setFrameShape(QFrame.HLine)
        headerLine.setFrameShadow(QFrame.Sunken)
        headerLine.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)

        self._contentArea.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Fixed)
        # start out collapsed
        self._contentArea.setMaximumHeight(0)
        self._contentArea.setMinimumHeight(0)

        # let the entire widget grow and shrink with its content
        self._toggleAnimation.addAnimation(
            QtCore.QPropertyAnimation(self, b"minimumHeight"))
        self._toggleAnimation.addAnimation(
            QtCore.QPropertyAnimation(self, b"maximumHeight"))
        self._toggleAnimation.addAnimation(
            QtCore.QPropertyAnimation(self._contentArea, b"maximumHeight"))

        mainLayout.setVerticalSpacing(0)
        mainLayout.setContentsMargins(0, 0, 0, 0)

        mainLayout.addWidget(self._toggleButton, 0, 0, 1, 1,
                             QtCore.Qt.AlignLeft)

        mainLayout.addWidget(headerLine, 1, 2, 1, 1)

        mainLayout.addWidget(self._contentArea, 1, 0, 1, 3)

        self.setLayout(mainLayout)
        self.setLayout = self._setLayout

        self._toggleButton.toggled.connect(lambda checked: [
            self._toggleAnimation.setDirection(
                QtCore.QAbstractAnimation.Forward
                if not checked else QtCore.QAbstractAnimation.Backward),
            self._toggleAnimation.start()
        ])
        self._toggleAnimation.finished.connect(
            lambda: self.stateChanged.emit(self._toggleButton.isChecked()))
コード例 #13
0
    def __init__(self, title="", animationDuration=100, parent=None):
        super().__init__(parent)
        self.animationDuration = animationDuration
        self.toggleButton = wd.QToolButton(self)
        self.headerLine = wd.QFrame(self)
        self.toggleAnimation = cr.QParallelAnimationGroup(self)
        self.contentArea = wd.QScrollArea(self)
        self.mainLayout = wd.QGridLayout(self)

        self.toggleButton.setStyleSheet("QToolButton {border: none;}")
        self.toggleButton.setToolButtonStyle(cr.Qt.ToolButtonTextBesideIcon)
        self.toggleButton.setArrowType(cr.Qt.RightArrow)
        self.toggleButton.setText(title)
        self.toggleButton.setCheckable(True)
        self.toggleButton.setChecked(True)

        self.headerLine.setFrameShape(wd.QFrame.HLine)
        self.headerLine.setFrameShadow(wd.QFrame.Sunken)
        self.headerLine.setSizePolicy(
            wd.QSizePolicy.Expanding, wd.QSizePolicy.Maximum)

        # self.contentArea.setLayout(wd.QHBoxLayout())
        self.contentArea.setSizePolicy(
            wd.QSizePolicy.Expanding, wd.QSizePolicy.Fixed)

        # start out collapsed
        self.contentArea.setMaximumHeight(0)
        self.contentArea.setMinimumHeight(0)

        # let the entire widget grow and shrink with its content
        self.toggleAnimation.addAnimation(
            cr.QPropertyAnimation(self, b"minimumHeight"))
        self.toggleAnimation.addAnimation(
            cr.QPropertyAnimation(self, b"maximumHeight"))
        self.toggleAnimation.addAnimation(
            cr.QPropertyAnimation(self.contentArea, b"maximumHeight"))

        self.mainLayout.setVerticalSpacing(0)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        row = 0
        self.mainLayout.addWidget(
            self.toggleButton, row, 0, 1, 1, cr.Qt.AlignLeft)
        self.mainLayout.addWidget(self.headerLine, row, 2, 1, 1)
        self.mainLayout.addWidget(self.contentArea, row+1, 0, 1, 3)
        self.setLayout(self.mainLayout)

        self.toggleButton.toggled.connect(self.toggle)
コード例 #14
0
    def __init__(self):
        super().__init__()
        self.setupUi(self)
        #self.setFixedSize(640, 480)
        self.resize(640, 600)
        self.setWindowTitle('View전체수집')
        self.chrome_driver_toggle.setStyleSheet(
            "QToolButton { border: none; }")
        self.chrome_driver_toggle.setToolButtonStyle(
            QtCore.Qt.ToolButtonTextBesideIcon)
        self.chrome_driver_toggle.setCheckable(True)
        self.chrome_driver_toggle.setArrowType(QtCore.Qt.RightArrow)
        self.chrome_driver_toggle.clicked.connect(self.on_pressed)

        self.toggle_animation = QtCore.QParallelAnimationGroup(self)
        self.FileDIR_Browser_2.hide()
        self.openFile_btn_2.hide()
        #self.verticalSpacer_3.setEnabled(False)

        self.AddQuery_btn.clicked.connect(
            self.AssociatedQuery('Func_AddQuery_btn'))
        self.Query_LineEdit.returnPressed.connect(
            self.AssociatedQuery('Func_AddQuery_btn'))
        self.openFile_btn.clicked.connect(
            self.AssociatedQuery('Func_openFile_btn'))
        self.CheckQuery_btn.clicked.connect(
            self.AssociatedQuery('Func_CheckQuery_btn'))
        self.AssociatedQuery('FileDIR_Default')

        self.activateFunc_btn.clicked.connect(self.Func_activateFunc_btn)

        self.AssociatedTable('SetDefaultTable')
        self.ViewResult_table.setEditTriggers(
            QTableWidget.NoEditTriggers)  # noqa: F405
        self.FlagEditable_chbox.stateChanged.connect(
            self.AssociatedTable('Func_FlagEditable_chbox'))
        self.SelectKeyword_cbox.currentIndexChanged.connect(
            self.AssociatedTable('Func_SelectKeyword_cbox'))
        #self.SelectKeyword_cbox.activated.connect(self.AssociatedTable('Func_ViewResult_table_admitChange')
        self.changeAdmit_btn.setEnabled(False)
        self.changeAdmit_btn.clicked.connect(
            self.AssociatedTable('Func_ViewResult_table_admitChanges'))
        self.ViewResult_table.cellDoubleClicked.connect(
            self.AssociatedTable('Func_ViewResult_table_doubleClicked'))
        self.SaveAsFIle_btn.clicked.connect(self.Func_SaveAsFile_btn)
コード例 #15
0
ファイル: game_grid.py プロジェクト: trevorxander/2048
    def __init__(self, parent=None, matrix=None):
        QtWidgets.QWidget.__init__(self, parent=parent)

        ui = GameGridUI()
        ui.setupUi(self)
        self._animation_duration = self._DEFAULT_ANIMATION_DURATION

        self._game_matrix = matrix
        self._grid = ui.grid_frame
        self._tile_length = 150
        self._grid_size = len(matrix)
        self._gui_matrix = []
        self._tile_to_delete = []
        self._initialize_grid()

        self._corner_tile = self._gui_matrix[self._grid_size -
                                             1][self._grid_size - 1]
        self._frame_thickness = 10

        self._animations = QtCore.QParallelAnimationGroup()

        self.setStyleSheet(self._DEFAULT_STYLE.format(color=self._GRID_COLOR))

        self.setMinimumWidth(self._GRID_MINIMUM_SIZE_FACTOR * self._grid_size +
                             self._MARGIN_SIZE * 2)
        self.setMinimumHeight(self._GRID_MINIMUM_SIZE_FACTOR *
                              self._grid_size + self._MARGIN_SIZE * 2)

        self.setMaximumWidth(150.75 * 1.5 * self._grid_size +
                             self._MARGIN_SIZE * 2)
        self.setMaximumHeight(100.75 * 1.5 * self._grid_size +
                              self._MARGIN_SIZE * 2)

        self.resize(self.minimumWidth(), self.minimumHeight())

        self.show()
コード例 #16
0
ファイル: icon_button.py プロジェクト: libarty/ine_client
    def __init__(self,
                 butSize=20,
                 butMargin=1,
                 butPadding=0,
                 butBack="white",
                 butBackHover=None,
                 butColor="black",
                 butColorHover=None,
                 butBorder=None,
                 butBorderHover=None,
                 butDuration=1000,
                 butIcon=["<", ">"],
                 parent=None):
        super(SetIcon, self).__init__(parent)
        # set standart val and change format color
        butBack = get_color(butBack)
        butBackHover = get_color(butBackHover or butBack)
        butColor = get_color(butColor)
        butColorHover = get_color(butColorHover or butColor)
        butBorder = get_color(butBorder or butColor)
        butBorderHover = get_color(butBorderHover or butBorder)
        # set icon
        self.icon = butIcon
        # set lay
        lay = QtWidgets.QGridLayout(self)
        lay.setSpacing(0)
        lay.setContentsMargins(0, 0, 0, 0)
        # Create Radio
        self.radio = QtWidgets.QRadioButton(self)
        self.radio.setSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                 QtWidgets.QSizePolicy.Minimum)
        # ADD
        lay.addWidget(self.radio, 0, 0, 1, 1)
        # set style for radio
        self.radio.setStyleSheet(
            'QRadioButton{background: %s;}QRadioButton::indicator {background-color:rgba(255, 255, 255, 0);}'
            % (butBorder))
        # Create Icon
        self.label = LabelIcon(self.radio, self)
        # set font for label
        fontId = QtGui.QFontDatabase.addApplicationFont(
            re.sub(r'\\', '/', BASE_DIR + r'\media\settings_post.ttf'))

        if fontId == -1:
            print('not font')
            self.icon = ["<", ">"]
        font = QtGui.QFont("settings_post", butSize)
        self.label.setFont(font)
        # set text for label
        self.label.setText(self.icon[0])
        # set position center for label
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                 QtWidgets.QSizePolicy.Fixed)
        # ADD
        lay.addWidget(self.label, 0, 0, 1, 1)
        # set style for label
        self.label.setStyleSheet(
            'background: %s;color: %s;margin:%s;padding:%s;' %
            (butBack, butColor, butMargin, butPadding))
        # set animation
        self.label.aGroup = QtCore.QParallelAnimationGroup(self)
        arry = [[butBack, butBackHover, True, True],
                [butColor, butColorHover, True, False],
                [butBorder, butBorderHover, False, True]]
        an = []
        for id, val in enumerate(arry):
            ani = QtCore.QVariantAnimation(duration=butDuration,
                                           startValue=QtGui.QColor(val[0]),
                                           endValue=QtGui.QColor(val[1]))
            an.append(ani)
            an[id].valueChanged.connect(lambda color, connect=val[2], type=val[
                3]: self.label.change_color(color, connect, type))
            self.label.aGroup.addAnimation(an[id])
        # watch when radio on or off
        self.radio.toggled.connect(self.change_text)
コード例 #17
0
ファイル: blur_menu.py プロジェクト: libarty/ine_client
    def __init__(self,
                 name="default",
                 effect=False,
                 power_blur=1,
                 parent_width=False,
                 parent_height=False,
                 parent_x=0,
                 parent_y=0,
                 parent_color='white',
                 parent_pos="",
                 cldNum=1,
                 lay_type=True,
                 type_move=['L', 'Y_C', 'R', 'Y_C'],
                 parent=None,
                 kwas_val=[2, 1],
                 kwas_type=[1],
                 type_anim=True,
                 *args,
                 **kwargs):
        # set parent
        super(MoveBlurWidget, self).__init__(parent)
        # delete main object
        self.resize(0, 0)
        # set standard val
        self.effect = effect
        if self.effect:
            self.effect.setBlurRadius(power_blur)
            self.effect.setEnabled(True)
        self.name = name
        self.type_move = type_move
        # ----Widget for button-----
        self.mainWidget = QtWidgets.QWidget(parent)
        self.mainWidget.setObjectName(u"{}_mainWidget".format(self.name))
        self.mainWidget.setStyleSheet('background:{}'.format(parent_color))
        self.mainWidget.move(parent_x, parent_y)
        # ----lay for button-----
        if lay_type:
            MB_widget_lay = QtWidgets.QVBoxLayout(self.mainWidget)
        else:
            MB_widget_lay = QtWidgets.QHBoxLayout(self.mainWidget)
        # Set object name
        MB_widget_lay.setObjectName(u"{}_MB_widget_lay".format(self.name))
        # ----delete margin-----
        MB_widget_lay.setSpacing(0)
        MB_widget_lay.setContentsMargins(0, 0, 0, 0)
        # ----set QSpacer----
        if parent_pos == "DOWN":
            vs = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum,
                                       QtWidgets.QSizePolicy.Expanding)
            MB_widget_lay.addItem(vs)

        # create buttonGroup for all radio in other widgets
        self.bGroup = QtWidgets.QButtonGroup(self, exclusive=True)
        # create array id with starting value 0
        id = defaultdict(int)
        # create list for off radio
        self.off_arr = {}

        # array enumeration
        for x in range(cldNum):
            # create new array with other values
            new_arr = {}
            id['kwas_val'] = 0
            id['kwas_type'] = 0
            for key, value in sorted(kwargs.items()):
                # save in the new array
                new_arr[key] = [
                    kwargs.get(key)[id[key]],
                    kwargs.get(key)[type_fun(id[key], kwargs.get(key), 1, 1)]
                ] if key == 'but1Icon' else kwargs.get(key)[id[key]]

                # Update the id according to different logic
                id[key] = type_fun(id[key], value, kwas_type[id['kwas_type']],
                                   kwas_val[id['kwas_val']])
                id['kwas_val'] = type_fun(id['kwas_val'], kwas_val)
                id['kwas_type'] = type_fun(id['kwas_type'], kwas_type)
            # rename for butIcon
            new_arr['butIcon'] = new_arr.pop('but1Icon')

            if self.effect:
                new_arr['effect'] = self.effect

            # Create widgets
            child_wid = MB_Content(layCon=MB_widget_lay,
                                   parentCon=parent,
                                   type_move=self.type_move,
                                   save=self.save,
                                   *args,
                                   **new_arr)

            # Set name for objects
            # for general widget
            child_wid.setObjectName('{}_WidgetConnect-{}'.format(self.name, x))
            setattr(self, child_wid.objectName(), child_wid)
            # for label
            child_wid.cldActivate.setObjectName('{}_cldActivate-{}'.format(
                self.name, x))
            # for radio
            child_wid.icon_wid.radio.setObjectName('{}_radioChild-{}'.format(
                self.name, x))
            self.off_arr[child_wid.icon_wid.radio.objectName()] = False
            # add radio for switching between buttons
            self.bGroup.addButton(child_wid.icon_wid.radio, x)

        # Face Buttons radio
        self.face_radio = QtWidgets.QRadioButton(self.mainWidget)
        # skip face radio
        self.face_radio.move(-self.face_radio.width(), 0)
        # ---ADD---
        self.face_radio.setObjectName('{}_radioChild-{}'.format(
            self.name, 999999999))
        self.bGroup.addButton(self.face_radio, 999999999)

        # ----set QSpacer----
        if parent_pos == "UP":
            vs = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum,
                                       QtWidgets.QSizePolicy.Expanding)
            MB_widget_lay.addItem(vs)

        # Set geometry for parent
        # after declaring geometry of MB_Content
        if parent_width:
            self.mainWidget.setFixedWidth(parent_width)
        else:
            self.mainWidget.setFixedWidth(self.mainWidget.sizeHint().width())
        if parent_height:
            self.mainWidget.setFixedHeight(parent_height)
        else:
            self.mainWidget.setFixedHeight(self.mainWidget.sizeHint().height())

        # Save geometry
        # if need ALT_...
        self.save_geometry(self.mainWidget)
        parent_geometry = self.save[self.mainWidget.objectName()]
        for x in range(cldNum):
            # get every child widget
            chiWid = getattr(self, '{}_WidgetConnect-{}'.format(self.name, x))
            # set position relative to parent
            chiWid.cldActivate.move(
                set_pos(parent_geometry, self.type_move[0],
                        chiWid.cldActivate),
                set_pos(parent_geometry, self.type_move[1],
                        chiWid.cldActivate))
            # save geometry
            self.save_geometry(chiWid.cldActivate)
            # set values start and end
            self.update_anim(chiWid)

        # Connect all button to functions
        self.bGroup.buttonToggled.connect(self.run_animation)
        self.bGroup.buttonClicked.connect(self.offRadioButton)

        # set animation group
        if type_anim:
            self.aGroup = QtCore.QSequentialAnimationGroup(self)
        else:
            self.aGroup = QtCore.QParallelAnimationGroup(self)

        # set face widget for second animation
        self.second_widget = None
        self.remember_name = {}
        self.sum = 1
コード例 #18
0
ファイル: visual.py プロジェクト: SeverTopan/AdjSim
    def update(self, agent_set):
        """The Visual update method, called after each timestep.

        Args:
            agent_set (list): The list of VisualAgent objects that will be rendered.
        """
        # begin update function
        del self.animations
        self.animations = QtCore.QParallelAnimationGroup()
        self.animations.finished.connect(self.timestepAnimationCallback)

        # delete items whose animations are complete
        for ellipse in self.visual_items.values():
            if ellipse.exit_animation_complete:
                self.scene.removeItem(ellipse)

        self.visual_items = {
            key: val
            for key, val in self.visual_items.items()
            if not val.exit_animation_complete
        }

        # update agent ellipses
        for agent in agent_set:
            if not self.visual_items.get(agent.id):
                # Create graphics item with entrance animation.
                newEllipse = AgentEllipse(agent, self.scene)
                self.visual_items[agent.id] = newEllipse

                animation = QtCore.QPropertyAnimation(
                    self.visual_items[agent.id].adapter, b'size')
                animation.setDuration(ANIMATION_DURATION)
                animation.setStartValue(0)
                animation.setEndValue(agent.size)
                self.animations.addAnimation(animation)

                self.scene.addItem(newEllipse)
            else:
                # Move animation.
                visual_item = self.visual_items[agent.id]
                if not np.array_equal(agent.pos, visual_item.agent.pos):
                    animation = QtCore.QPropertyAnimation(
                        visual_item.adapter, b'x')
                    animation.setDuration(ANIMATION_DURATION)
                    animation.setStartValue(float(visual_item.agent.x))
                    animation.setEndValue(float(agent.x))
                    self.animations.addAnimation(animation)

                    animation = QtCore.QPropertyAnimation(
                        visual_item.adapter, b'y')
                    animation.setDuration(ANIMATION_DURATION)
                    animation.setStartValue(float(visual_item.agent.y))
                    animation.setEndValue(float(agent.y))
                    self.animations.addAnimation(animation)

                    # Store.
                    visual_item.agent.pos = agent.pos

            # Update color.
            visual_item = self.visual_items[agent.id]
            if agent.color != visual_item.agent.color or \
                    agent.style != visual_item.agent.style:
                # Paint.
                visual_item.setBrush(
                    QtGui.QBrush(agent.color, style=agent.style))

                # Store.
                visual_item.agent.color = agent.color
                visual_item.agent.style = agent.style

        # remove graphics items whose agents are no longer in the agent_set
        agent_dict = {agent.id: agent for agent in agent_set}
        for key, val in self.visual_items.items():
            if not agent_dict.get(key):
                # destroy object with exit animation
                val.exit_animation_complete = True

                animation = QtCore.QPropertyAnimation(val.adapter, b'size')
                animation.setDuration(ANIMATION_DURATION)
                animation.setStartValue(val.agent.size)
                animation.setEndValue(0)
                self.animations.addAnimation(animation)

        self.animations.start()
コード例 #19
0
	def __init__(
			self,
			name="default",
			effect=False,
			power_blur=1,
			parent_width=False,
			parent_height=False,
			parent_x=0,
			parent_y=0,
			parent_color='white',
			header_pos="",
			cldNum=1,
			lay_type=True,
			parent=None,
			kwas_val=[1],
			kwas_type=[1],
			type_anim=True,
			*args,
			**kwargs
	):
		# set parent
		super(ShowBlurWidget, self).__init__(parent)
		# delete main object
		self.resize(0, 0)
		# set standard val
		self.effect =effect
		if self.effect:
			self.effect.setBlurRadius(power_blur)
			self.effect.setEnabled(True)
		# set name object
		# it is need for blur effect
		self.name = name

		# ----Main widget with content-----
		self.mainWidget = QtWidgets.QWidget(parent)
		self.mainWidget.setObjectName(u"{}_mainWidget".format(self.name))
		self.mainWidget.setStyleSheet('background:{}'.format(parent_color))

		# ----horizontal Lay for mainWidget-----
		mainWidget_lay = QtWidgets.QVBoxLayout(self.mainWidget)
		# delete margin
		mainWidget_lay.setContentsMargins(0, 0, 0, 0)
		mainWidget_lay.setSpacing(0)

		# create header for buttons left right
		if lay_type:
			self.SB_header = QtWidgets.QWidget(self)
			self.SB_header .setStyleSheet('background:{}'.format(kwargs.get('cldHeaderColor')[0]))
			# vertical Lay for buttons
			self.lay_SB_header = QtWidgets.QHBoxLayout(self.SB_header )
			# set margin
			cld_header_margin = kwargs.get('cldHeaderMargin')[0]
			check = len(cld_header_margin)
			if check < 2:
				cld_header_margin.append(cld_header_margin[0])
			if check < 3:
				cld_header_margin.append(cld_header_margin[0])
			if check < 4:
				cld_header_margin.append(cld_header_margin[1])
			self.lay_SB_header.setContentsMargins(*cld_header_margin)
			self.lay_SB_header.setSpacing(0)

			# align the buttons to the right
			if header_pos == "RIGHT":
				vs_2 = QtWidgets.QSpacerItem(
					0, 0,
					QtWidgets.QSizePolicy.Expanding,
					QtWidgets.QSizePolicy.Minimum
				)
				self.lay_SB_header.addItem(vs_2)
			# add header first in mainWidget
			mainWidget_lay.addWidget(self.SB_header)

		# create buttonGroup for all radio in other widgets
		self.bGroup = QtWidgets.QButtonGroup(self, exclusive=True)
		# create array id with starting value 0
		id = defaultdict(int)
		# create list for off radio
		self.off_arr = {}
		# array enumeration
		for x in range(cldNum):
			# create new array with other values
			new_arr = {}
			id['kwas_val'] = 0
			id['kwas_type'] = 0
			for key, value in sorted(kwargs.items()):
				# save in the new array
				new_arr[key] = kwargs.get(key)[id[key]]
				# Update the id according to different logic
				id[key] = type_fun(id[key], value, kwas_type[id['kwas_type']], kwas_val[id['kwas_val']])
				id['kwas_val'] = type_fun(id['kwas_val'], kwas_val)
				id['kwas_type'] = type_fun(id['kwas_type'], kwas_type)
			if self.effect:
				new_arr['effect'] = self.effect

			# Create widgets
			child_wid = SB_Content(
				parentCon=parent,
				save=self.save,
				cld_lay_type=lay_type,
				*args,
				**new_arr
			)
			# Set name for objects
			# for general widgets
			child_wid.setObjectName('{}_WidgetConnect-{}'.format(self.name, x))
			setattr(self, child_wid.objectName(), child_wid)
			# for radio
			child_wid.icon_wid.radio.setObjectName('{}_radioChild-{}'.format(self.name, x))
			self.off_arr[child_wid.icon_wid.radio.objectName()] = False
			# for area
			child_wid.cldActivate.setObjectName('{}_cldActivate-{}'.format(self.name, x))
			# add radio for switching between buttons
			self.bGroup.addButton(child_wid.icon_wid.radio, x)

			# add widgets in different lay
			if lay_type:
				# Add in header
				self.lay_SB_header.addWidget(child_wid.icon_wid)
			else:
				# align the buttons to the right
				vs_2 = QtWidgets.QSpacerItem(
					0, 0,
					QtWidgets.QSizePolicy.Expanding,
					QtWidgets.QSizePolicy.Minimum
				)
				if header_pos == "RIGHT":
					child_wid.lay_min_header.addItem(vs_2)
				# Add buttons
				child_wid.lay_min_header.addWidget(child_wid.icon_wid)
				if header_pos == "LEFT":
					child_wid.lay_min_header.addItem(vs_2)
				# Add in main widget
				mainWidget_lay.addWidget(child_wid.min_header_but)

			# Add in main widget
			mainWidget_lay.addWidget(child_wid.cldActivate)

		# Face Buttons radio
		self.face_radio = QtWidgets.QRadioButton(self.mainWidget)
		# skip face radio
		self.face_radio.move(-self.face_radio.width(), 0)
		# ---ADD---
		self.face_radio.setObjectName('{}_radioChild-{}'.format(self.name, 999999999))
		self.bGroup.addButton(self.face_radio, 999999999)

		# ----set QSpacer----
		vs = QtWidgets.QSpacerItem(0, 0,  QtWidgets.QSizePolicy.Minimum,  QtWidgets.QSizePolicy.Expanding)
		mainWidget_lay.addItem(vs)
		if lay_type and header_pos == "LEFT":
			vs_2 = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
			self.lay_SB_header.addItem(vs_2)

		# Set main geometry settings
		# set position
		self.mainWidget.move(parent_x, parent_y)

		# Set geometry for parent
		# after declaring geometry of SB_Content
		if parent_width:
			self.mainWidget.setFixedWidth(parent_width)
		else:
			self.mainWidget.setFixedWidth(self.mainWidget.sizeHint().width())
		if parent_height:
			self.mainWidget.setFixedHeight(parent_height)
		else:
			if lay_type:
				self.mainWidget.setFixedHeight(self.SB_header.sizeHint().height())
			else:
				self.mainWidget.setFixedHeight(child_wid.min_header_but.sizeHint().height()*cldNum)

		self.save_geometry(self.mainWidget)
		for x in range(cldNum):
			# get every child widget
			chiWid = getattr(self, '{}_WidgetConnect-{}'.format(self.name, x))
			# save geometry
			self.save_geometry(child_wid.cldActivate)
			# set values start and end
			self.update_anim(
				wid=chiWid,
				pos1=chiWid.cldActivate.sizeHint().height(),
				pos2=0,
				geometry=self.mainWidget.geometry(),
				name=self.mainWidget.objectName()
			)

		# Connect all button to functions
		self.bGroup.buttonToggled.connect(self.run_animation)
		self.bGroup.buttonClicked.connect(self.offRadioButton)

		# set animation group
		if type_anim:
			self.aGroup = QtCore.QSequentialAnimationGroup(self)
		else:
			self.aGroup = QtCore.QParallelAnimationGroup(self)

		# set face widget for second animation
		self.second_widget = None
		self.remember_name = {}
		self.sum = 1
コード例 #20
0
	def start_fun(self):
		self.frame += 1
		# set animation group
		frame_1 = QtCore.QParallelAnimationGroup(self)
		frame_2 = QtCore.QSequentialAnimationGroup(self)
		frame_3 = QtCore.QSequentialAnimationGroup(self)
		# set pause value
		if self.frame == 1:
			pause_ani = QtCore.QPauseAnimation()
			pause_ani.setDuration(self.pause)
			frame_3.addAnimation(pause_ani)

			if not self.triangle and self.circle:
				self.frame = 4
			else:
				self.frame = 2

		if not self.triangle and not self.circle:
			rotate_start = 0
			rotate_end = 90

			translate_start = 70
			translate_end = 70

			style = True

			self.frame = 9
	
		# set start value

		if self.frame == 2:

			rotate_start = 0
			rotate_end = 90+26

			translate_start = 70
			translate_end = 0

			style = False

		elif self.frame == 3:

			rotate_start = 90+29
			rotate_end = 180

			translate_start = 0
			translate_end = 70

			style = False

			if self.triangle and not self.circle:
				self.frame = 1

		elif self.frame == 4:
			rotate_start = 0
			rotate_end = 90

			translate_start = 70
			translate_end = 50

			style = True

		elif self.frame == 5:
			rotate_start = 0
			rotate_end = 90

			translate_start = 50
			translate_end = 70

			style = True

			if not self.triangle and self.circle:
				self.frame = 3
			else:
				self.frame = 1

		# set animations

		# set rotation
		ani_rotate = QtCore.QVariantAnimation()
		ani_rotate.setDuration(self.duration*2)
		ani_rotate.valueChanged.connect(self.value_change_r)
		ani_rotate.setEasingCurve(QtCore.QEasingCurve.OutSine)
		ani_rotate.setStartValue(rotate_start)
		ani_rotate.setEndValue(rotate_end)

		# set change shape of figure
		translate = QtCore.QVariantAnimation()
		translate.setDuration(self.duration*2)
		translate.valueChanged.connect(
			lambda value, qss=style: self.value_change_t(value, qss)
		)
		translate.setEasingCurve(QtCore.QEasingCurve.OutSine)
		translate.setStartValue(translate_start)
		translate.setEndValue(translate_end)

		# set change position
		move_front = QtCore.QVariantAnimation()
		move_front.setDuration(self.duration)
		move_front.valueChanged.connect(self.value_change_p)
		move_front.setEasingCurve(QtCore.QEasingCurve.OutSine)
		move_front.setStartValue(0)
		move_front.setEndValue(round(self.size * self.distance))

		# set change position inside out
		move_back = QtCore.QVariantAnimation()
		move_back.setDuration(self.duration)
		move_back.valueChanged.connect(self.value_change_p)
		move_back.setEasingCurve(QtCore.QEasingCurve.OutSine)
		move_back.setStartValue(round(self.size * self.distance))  # self.size
		move_back.setEndValue(0)

		# save animations
		frame_2.addAnimation(move_front)
		frame_2.addAnimation(move_back)

		frame_1.addAnimation(frame_2)
		frame_1.addAnimation(ani_rotate)
		frame_1.addAnimation(translate)

		frame_3.addAnimation(frame_1)

		frame_3.finished.connect(self.again)
		frame_3.start()
コード例 #21
0
    def __init__(self):
        """MainWindow constructor.

        This widget will be our main window.
        We'll define all the UI components in here.
        """
        super().__init__()
        # Main UI code goes here

        # Basic Form Definition
        self.setWindowTitle('Fight Fighter Game Lobby')
        cx_form = qtw.QWidget()
        self.setCentralWidget(cx_form)
        cx_form.setLayout(qtw.QFormLayout())

        heading = qtw.QLabel("Fight Fighter!")
        cx_form.layout().addRow(heading)

        inputs = {
            'Server': qtw.QLineEdit(),
            'Name': qtw.QLineEdit(),
            'Password': qtw.QLineEdit(echoMode=qtw.QLineEdit.Password),
            'Team': qtw.QComboBox(),
            'Ready': qtw.QCheckBox('Check when ready')
        }
        teams = ('Crimson Sharks', 'Shadow Hawks', 'Night Terrors',
                 'Blue Crew')
        inputs['Team'].addItems(teams)

        for label, widget in inputs.items():
            cx_form.layout().addRow(label, widget)
        #self.submit = qtw.QPushButton(
        self.submit = ColorButton(
            'Connect',
            clicked=lambda: qtw.QMessageBox.information(
                None, 'Connecting', 'Prepare for Battle!'))

        #self.cancel = qtw.QPushButton(
        self.cancel = ColorButton('Cancel', clicked=self.close)
        cx_form.layout().addRow(self.submit, self.cancel)

        #self.show()
        #return
        #########
        # Fonts #
        #########

        # Configuring Fonts
        heading_font = qtg.QFont('Impact', 32, qtg.QFont.Bold)
        heading_font.setStretch(qtg.QFont.ExtraExpanded)
        heading.setFont(heading_font)

        # Explicit font configuration
        label_font = qtg.QFont()
        label_font.setFamily('Impact')
        label_font.setPointSize(14)
        label_font.setWeight(qtg.QFont.DemiBold)
        label_font.setStyle(qtg.QFont.StyleItalic)

        for inp in inputs.values():
            cx_form.layout().labelForField(inp).setFont(label_font)

        # Locating Alternative fonts

        button_font = qtg.QFont('Totally Nonexistant Font Family XYZ', 15.233)
        print(f'Font is {button_font.family()}')
        actual_font = qtg.QFontInfo(button_font).family()
        print(f'Actual font used is {actual_font}')

        # Set a style hint
        button_font.setStyleHint(qtg.QFont.Fantasy)  # Use a "fantasy font"
        button_font.setStyleStrategy(qtg.QFont.PreferAntialias
                                     | qtg.QFont.PreferQuality)

        actual_font = qtg.QFontInfo(button_font)
        print(f'Actual font used is {actual_font.family()}'
              f' {actual_font.pointSize()}')

        self.submit.setFont(button_font)
        self.cancel.setFont(button_font)

        #self.show()
        #return
        ####################
        # Images and Icons #
        ####################

        # Display a simple raster image
        logo = qtg.QPixmap('logo.png')
        if logo.width() > 400:
            logo = logo.scaledToWidth(400, qtc.Qt.SmoothTransformation)
        heading.setPixmap(logo)

        # Create images

        go_pixmap = qtg.QPixmap(qtc.QSize(32, 32))
        stop_pixmap = qtg.QPixmap(qtc.QSize(32, 32))
        go_pixmap.fill(qtg.QColor('green'))
        stop_pixmap.fill(qtg.QColor('red'))

        # Creating icons

        connect_icon = qtg.QIcon()
        connect_icon.addPixmap(go_pixmap, qtg.QIcon.Active)
        connect_icon.addPixmap(stop_pixmap, qtg.QIcon.Disabled)
        self.submit.setIcon(connect_icon)
        self.submit.setDisabled(True)
        inputs['Server'].textChanged.connect(
            lambda x: self.submit.setDisabled(x == ''))

        # using resources
        # note import of "resources" at top
        inputs['Team'].setItemIcon(0, qtg.QIcon(':/teams/crimson_sharks.png'))
        inputs['Team'].setItemIcon(1, qtg.QIcon(':/teams/shadow_hawks.png'))
        inputs['Team'].setItemIcon(2, qtg.QIcon(':/teams/night_terrors.png'))
        inputs['Team'].setItemIcon(3, qtg.QIcon(':/teams/blue_crew.png'))

        # Loading a font from a resource file
        libsans_id = qtg.QFontDatabase.addApplicationFont(
            ':/fonts/LiberationSans-Regular.ttf')
        family = qtg.QFontDatabase.applicationFontFamilies(libsans_id)[0]
        libsans = qtg.QFont(family)
        inputs['Team'].setFont(libsans)

        #self.show()
        #return

        ##########
        # Colors #
        ##########
        app = qtw.QApplication.instance()
        palette = app.palette()
        palette.setColor(qtg.QPalette.Button, qtg.QColor('#333'))
        palette.setColor(qtg.QPalette.ButtonText, qtg.QColor('#3F3'))
        palette.setColor(qtg.QPalette.Disabled, qtg.QPalette.ButtonText,
                         qtg.QColor('#F88'))
        palette.setColor(qtg.QPalette.Disabled, qtg.QPalette.Button,
                         qtg.QColor('#888'))
        self.submit.setPalette(palette)
        self.cancel.setPalette(palette)

        # Using Brushes
        dotted_brush = qtg.QBrush(qtg.QColor('white'), qtc.Qt.Dense2Pattern)

        gradient = qtg.QLinearGradient(0, 0, self.width(), self.height())
        gradient.setColorAt(0, qtg.QColor('navy'))
        gradient.setColorAt(0.5, qtg.QColor('darkred'))
        gradient.setColorAt(1, qtg.QColor('orange'))
        gradient_brush = qtg.QBrush(gradient)

        window_palette = app.palette()
        window_palette.setBrush(qtg.QPalette.Window, gradient_brush)
        window_palette.setBrush(qtg.QPalette.Active, qtg.QPalette.WindowText,
                                dotted_brush)
        self.setPalette(window_palette)

        #self.show()
        #return
        ##################
        # Qt StyleSheets #
        ##################

        stylesheet = """
        QMainWindow {
            background-color: black;
        }
        QWidget {
            background-color: transparent;
            color: #3F3;
        }
        QLineEdit, QComboBox, QCheckBox {
            font-size: 16pt;
        }"""
        #self.setStyleSheet(stylesheet)

        #self.show()
        #return
        # oops, we've lost our controls!
        stylesheet += """
         QPushButton {
             background-color: #333;
         }
         QCheckBox::indicator:unchecked {
             border: 1px solid silver;
             background-color: darkred;
         }
         QCheckBox::indicator:checked {
             border: 1px solid silver;
             background-color: #3F3;
         }
         """

        #self.setStyleSheet(stylesheet)

        # Using discrete classes
        stylesheet += """
        .QWidget {
           background: url(tile.png);
        }
        """

        # Using object names
        self.submit.setObjectName('SubmitButton')
        stylesheet += """
        #SubmitButton:disabled {
            background-color: #888;
            color: darkred;
        }
        """
        #self.setStyleSheet(stylesheet)
        for inp in ('Server', 'Name', 'Password'):
            inp_widget = inputs[inp]
            inp_widget.setStyleSheet('background-color: black')

        #self.show()
        #return
        #############
        # Qt Styles #
        #############

        # See main execution block for style setting call
        # app.setStyle(qtw.QStyleFactory.create('QtCurve'))

        #############
        # Animation #
        #############

        # Simple property animation
        self.heading_animation = qtc.QPropertyAnimation(
            heading, b'maximumSize')
        self.heading_animation.setStartValue(qtc.QSize(10, logo.height()))
        self.heading_animation.setEndValue(qtc.QSize(400, logo.height()))
        self.heading_animation.setDuration(2000)
        #self.heading_animation.start()

        # Parallel animations
        # See ColorButton class
        # you'll have to disable all stylesheets
        self.text_color_animation = qtc.QPropertyAnimation(
            self.submit, b'color')
        self.text_color_animation.setStartValue(qtg.QColor('#FFF'))
        self.text_color_animation.setEndValue(qtg.QColor('#888'))
        self.text_color_animation.setLoopCount(-1)
        self.text_color_animation.setEasingCurve(qtc.QEasingCurve.InOutQuad)
        self.text_color_animation.setDuration(2000)
        #self.text_color_animation.start()

        self.bg_color_animation = qtc.QPropertyAnimation(
            self.submit, b'backgroundColor')
        self.bg_color_animation.setStartValue(qtg.QColor('#000'))
        self.bg_color_animation.setKeyValueAt(0.5, qtg.QColor('darkred'))
        self.bg_color_animation.setEndValue(qtg.QColor('#000'))
        self.bg_color_animation.setLoopCount(-1)
        self.bg_color_animation.setDuration(1500)
        #self.bg_color_animation.start()

        self.button_animations = qtc.QParallelAnimationGroup()
        self.button_animations.addAnimation(self.text_color_animation)
        self.button_animations.addAnimation(self.bg_color_animation)
        #self.button_animations.start()

        self.all_animations = qtc.QSequentialAnimationGroup()
        self.all_animations.addAnimation(self.heading_animation)
        self.all_animations.addAnimation(self.button_animations)
        self.all_animations.start()

        # End main UI code
        self.show()
コード例 #22
0
ファイル: toast.py プロジェクト: Daosp/pesterchum-Dpeta-rus
    def __init__(self, machine, title, msg, icon, time=3000, parent=None):
        logging.info(isinstance(parent, QtWidgets.QWidget))
        kwds = dict(machine=machine, title=title, msg=msg, icon=icon)
        super().__init__(parent, **kwds)

        self.machine = machine
        self.time = time

        if ostools.isWin32():
            self.setWindowFlags(QtCore.Qt.ToolTip)
        else:
            self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.ToolTip)

        self.m_animation = QtCore.QParallelAnimationGroup()
        anim = QtCore.QPropertyAnimation(self)
        anim.setTargetObject(self)
        self.m_animation.addAnimation(anim)
        anim.setEasingCurve(QtCore.QEasingCurve.OutBounce)
        anim.setDuration(1000)
        anim.finished.connect(self.reverseTrigger)

        self.m_animation.setDirection(QtCore.QAnimationGroup.Forward)

        self.title = QtWidgets.QLabel(title, self)
        self.msg = QtWidgets.QLabel(msg, self)
        self.content = msg
        if icon:
            self.icon = QtWidgets.QLabel("")
            self.icon.setPixmap(QtGui.QPixmap(icon).scaledToWidth(30))
        else:
            self.icon = QtWidgets.QLabel("")
            self.icon.setPixmap(QtGui.QPixmap(30, 30))
            self.icon.pixmap().fill(QtGui.QColor(0,0,0,0))

        layout_0 = QtWidgets.QVBoxLayout()
        layout_0.setContentsMargins(0, 0, 0, 0)
        layout_0.setContentsMargins(0, 0, 0, 0)

        if self.icon:
            layout_1 = QtWidgets.QGridLayout()
            layout_1.addWidget(self.icon, 0,0, 1,1)
            layout_1.addWidget(self.title, 0,1, 1,7)
            layout_1.setAlignment(self.msg, QtCore.Qt.AlignTop)
            layout_0.addLayout(layout_1)
        else:
            layout_0.addWidget(self.title)
        layout_0.addWidget(self.msg)

        self.setMaximumWidth(self.parent().theme["toasts/width"])
        self.msg.setMaximumWidth(self.parent().theme["toasts/width"])
        self.title.setMinimumHeight(self.parent().theme["toasts/title/minimumheight"])

        self.setLayout(layout_0)

        self.setGeometry(0,0, self.parent().theme["toasts/width"], self.parent().theme["toasts/height"])
        self.setStyleSheet(self.parent().theme["toasts/style"])
        self.title.setStyleSheet(self.parent().theme["toasts/title/style"])
        if self.icon:
            self.icon.setStyleSheet(self.parent().theme["toasts/icon/style"])
        self.msg.setStyleSheet(self.parent().theme["toasts/content/style"])
        self.layout().setSpacing(0)

        self.msg.setText(PesterToast.wrapText(self.msg.font(), str(self.msg.text()), self.parent().theme["toasts/width"], self.parent().theme["toasts/content/style"]))

        p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight()
        o = QtWidgets.QApplication.desktop().screenGeometry(self).bottomRight()
        anim.setStartValue(p.y() - o.y())
        anim.setEndValue(100)
        anim.valueChanged[QtCore.QVariant].connect(self.updateBottomLeftAnimation)

        self.byebye = False
コード例 #23
0
    def __init__(self, title="", parent=None, *buttons):
        parent:CollapsibleBox
        self.parent:CollapsibleBox
        super(CollapsibleBox, self).__init__()
        self.parent=parent
        self.title=title
        lay = QtWidgets.QVBoxLayout(self)
        lay.setSpacing(0)
        lay.setContentsMargins(0, 0, 0, 0)
        frame=QtWidgets.QFrame(self)
        frame.setObjectName("CollapsibleBox")
        lay.addWidget(frame)

        self.toggle_button = QtWidgets.QToolButton( text=title, checkable=True, checked=False)
        self.toggle_button.setObjectName("toggle_button")
        self.toggle_button.setStyleSheet("QToolButton#toggle_button { border: None; }")
        #self.toggle_button.setStyleSheet("background-color: rgb(255, 200, 200);")
        self.toggle_button.setToolButtonStyle( QtCore.Qt.ToolButtonTextBesideIcon)
        self.toggle_button.setMaximumWidth(100000)
        
        #if index is None: self.toggle_button.setMinimumHeight(20)
        #else: self.toggle_button.setMinimumHeight(30)
        self.toggle_button.setArrowType(QtCore.Qt.RightArrow)
        self.toggle_button.pressed.connect(self.on_pressed)

        lay1 =QtWidgets.QHBoxLayout()
        lay1.setSpacing(8)
        lay1.setContentsMargins(0,0,0,0)
        lay1.addWidget(self.toggle_button)
        self.Buttons = buttons
        for button in self.Buttons: 
            button.setStyleSheet("QToolButton#toggle_button { border: None; }")
            lay1.addWidget(button)
            button.hide()
        self.lay1=lay1
        self.toggle_animation = QtCore.QParallelAnimationGroup(self)

        self.content_area = QtWidgets.QScrollArea( maximumHeight=0, minimumHeight=0)
        self.content_area.setObjectName("content_area")
        self.content_area.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
        self.content_area.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.content_area.setLayout(QtWidgets.QVBoxLayout())
        self.content_area.setContentsMargins(0, 0, 0, 0)
        self.content_area.layout().addStretch()
        self.content_height=0
        
        lay = QtWidgets.QVBoxLayout(frame)
        lay.setSpacing(0)
        lay.setContentsMargins(0, 0, 0, 0)
        lay.addLayout(lay1)
        lay.addWidget(self.content_area) 

        self.animationDuration=150
        self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self, b"minimumHeight"))
        self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self, b"maximumHeight"))
        self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self.content_area, b"maximumHeight"))

        self.collapsed_height=self.sizeHint().height() - self.content_area.maximumHeight()
        self._isOpen = False
        self.setContentsMargins(0,0,0,0)
        self.toggle_animation.finished.connect(self.toggle_animation_finished)
        if type(parent) is CollapsibleBox:
            self.parent.addWidget(self)
            self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self.parent, b"minimumHeight"))
            self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self.parent, b"maximumHeight"))
            self.toggle_animation.addAnimation( QtCore.QPropertyAnimation(self.parent.content_area, b"maximumHeight"))
コード例 #24
0
ファイル: sidebar.py プロジェクト: ireneher/andre_jukebox
    def __init__(self, parent=None, title=None, animationDuration=200):
        super().__init__(parent=parent)

        self.animationDuration = animationDuration
        self.toggleAnimation = QtCore.QParallelAnimationGroup()
        self.contentArea = QScrollArea()
        self.headerLine = QFrame()
        self.toggleButton = QToolButton()
        self.mainLayout = QGridLayout()

        toggleButton = self.toggleButton
        self.toggleButtonQStyle = QStyleSheet(QToolButton, border="none")
        toggleButton.setStyleSheet(str(self.toggleButtonQStyle))
        toggleButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        toggleButton.setArrowType(QtCore.Qt.RightArrow)
        toggleButton.setText(title or "")
        toggleButton.setCheckable(True)
        toggleButton.setChecked(False)
        toggleButton.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

        headerLine = self.headerLine
        self.headerLineQStyle = QStyleSheet(QFrame)
        headerLine.setFrameShape(
            QFrame.NoFrame
        )  # see: https://doc.qt.io/archives/qt-4.8/qframe.html#Shape-enum
        headerLine.setFrameShadow(
            QFrame.Plain
        )  # see: https://doc.qt.io/archives/qt-4.8/qframe.html#Shape-enum
        headerLine.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)

        self.contentAreaQStyle = QStyleSheet(QScrollArea, border="none")
        self.contentArea.setStyleSheet(str(self.contentAreaQStyle))
        self.contentArea.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Fixed)
        # start out collapsed
        self.contentArea.setMaximumHeight(0)
        self.contentArea.setMinimumHeight(0)
        # let the entire widget grow and shrink with its content
        toggleAnimation = self.toggleAnimation
        toggleAnimation.addAnimation(
            QtCore.QPropertyAnimation(self, b"minimumHeight"))
        toggleAnimation.addAnimation(
            QtCore.QPropertyAnimation(self, b"maximumHeight"))
        toggleAnimation.addAnimation(
            QtCore.QPropertyAnimation(self.contentArea, b"maximumHeight"))
        # don't waste space
        mainLayout = self.mainLayout
        mainLayout.setVerticalSpacing(0)
        mainLayout.setContentsMargins(0, 0, 0, 0)
        row = 0
        mainLayout.addWidget(self.toggleButton, row, 0, 1, 1,
                             QtCore.Qt.AlignLeft)
        mainLayout.addWidget(self.headerLine, row, 2, 1, 1)
        row += 1
        mainLayout.addWidget(self.contentArea, row, 0, 1, 3)
        super().setLayout(self.mainLayout)

        def start_animation(checked):
            arrow_type = QtCore.Qt.DownArrow if checked else QtCore.Qt.RightArrow
            direction = (QtCore.QAbstractAnimation.Forward
                         if checked else QtCore.QAbstractAnimation.Backward)
            toggleButton.setArrowType(arrow_type)
            self.toggleAnimation.setDirection(direction)
            self.toggleAnimation.start()

        self.toggleButton.clicked.connect(start_animation)
コード例 #25
0
    def __init__(self, parent=None, title='', animationDuration=300):
        """
        References:
            # Adapted from c++ version
            http://stackoverflow.com/questions/32476006/how-to-make-an-expandable-collapsable-section-widget-in-qt
        """
        super(Spoiler, self).__init__(parent=parent)

        self.animationDuration = 300
        self.toggleAnimation = QtCore.QParallelAnimationGroup()
        self.contentArea = QtWidgets.QScrollArea()
        self.headerLine = QtWidgets.QFrame()
        self.toggleButton = QtWidgets.QToolButton()
        self.mainLayout = QtWidgets.QGridLayout()

        toggleButton = self.toggleButton
        toggleButton.setStyleSheet("QToolButton { border: none; }")
        toggleButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        toggleButton.setArrowType(QtCore.Qt.RightArrow)
        toggleButton.setText(str(title))
        toggleButton.setCheckable(True)
        toggleButton.setChecked(False)

        headerLine = self.headerLine
        headerLine.setFrameShape(QtWidgets.QFrame.HLine)
        headerLine.setFrameShadow(QtWidgets.QFrame.Sunken)
        headerLine.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                 QtWidgets.QSizePolicy.Maximum)

        self.contentArea.setStyleSheet(
            "QScrollArea { background-color: white; border: none; }")
        self.contentArea.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                       QtWidgets.QSizePolicy.Fixed)
        # start out collapsed
        self.contentArea.setMaximumHeight(0)
        self.contentArea.setMinimumHeight(0)
        # let the entire widget grow and shrink with its content
        toggleAnimation = self.toggleAnimation
        toggleAnimation.addAnimation(
            QtCore.QPropertyAnimation(self, "minimumHeight"))
        toggleAnimation.addAnimation(
            QtCore.QPropertyAnimation(self, "maximumHeight"))
        toggleAnimation.addAnimation(
            QtCore.QPropertyAnimation(self.contentArea, "maximumHeight"))
        # don't waste space
        mainLayout = self.mainLayout
        mainLayout.setVerticalSpacing(0)
        mainLayout.setContentsMargins(0, 0, 0, 0)
        row = 0
        mainLayout.addWidget(self.toggleButton, row, 0, 1, 1,
                             QtCore.Qt.AlignLeft)
        mainLayout.addWidget(self.headerLine, row, 2, 1, 1)
        row += 1
        mainLayout.addWidget(self.contentArea, row, 0, 1, 3)
        self.setLayout(self.mainLayout)

        def start_animation(checked):
            arrow_type = QtCore.Qt.DownArrow if checked else QtCore.Qt.RightArrow
            direction = QtCore.QAbstractAnimation.Forward if checked else QtCore.QAbstractAnimation.Backward
            toggleButton.setArrowType(arrow_type)
            self.toggleAnimation.setDirection(direction)
            self.toggleAnimation.start()

        self.toggleButton.clicked.connect(start_animation)