Esempio n. 1
0
class test(QDialog):
    def __init__(self,parent=None):
        super(test,self).__init__(parent)
        self.pushbutton = MyButton('Popup Button')
        # self.pushbutton.setAutoFillBackground(False)
        self.pushbutton.move(0, 50)
        # self._alpha = 255
        # self.pushbutton.setStyle('plastique')

        # self.animation = QPropertyAnimation(self.pushbutton, "geometry")

        # self.animation.setDuration(1000)
        # self.animation.setKeyValueAt(0, QRect(100, 100, 50, 30));
        # self.animation.setKeyValueAt(0.8, QRect(150, 150, 50, 30));
        # self.animation.setKeyValueAt(1, QRect(100, 100, 50, 30));

        self.animation = QPropertyAnimation(self.pushbutton, "alpha")
        self.animation.setDuration(1000)
        # self.animation.setStartValue(20)
        # self.animation.setEndValue(255)

        self.animation.setKeyValueAt(0, 10)
        self.animation.setKeyValueAt(0.5, 200)
        self.animation.setKeyValueAt(1, 255)
        self.animation.setLoopCount(5)
        self.animation.start()
        # print(self.pushbutton)

        layout = QVBoxLayout()
        layout.addWidget(self.pushbutton)       
        # layout.addLayout(btnlayout2)
        # layout.addLayout(bottomlayout2)
        self.setLayout(layout)
        self.setGeometry(100, 100, 200, 200)

        # menu = QtGui.QMenu()
        # menu.addAction('This is Action 1', self.Action1)
        # menu.addAction('This is Action 2', self.Action2)
        # pushbutton.setMenu(menu)
        # self.setCentralWidget(pushbutton)
    

    def Action1(self):
        print('You selected Action 1')

    def Action2(self):
        print('You selected Action 2')
Esempio n. 2
0
def groupAnimation(ws, btngroup):
    # 建立一个平行的动作组
    ag = QParallelAnimationGroup()
    for w in ws:
        tmpbtn = btngroup.button(int(w[0]))
        # 对于每个按钮, 都生成一个进入的动作
        a = QPropertyAnimation(tmpbtn, "alpha")
        a.setDuration(200)
        a.setKeyValueAt(0, 10)
        # a.setKeyValueAt(0.5, 200)
        a.setKeyValueAt(1, 255)
        a.setLoopCount(-1)
        a.setEasingCurve(QEasingCurve.OutQuad)
        # a.setStartValue(QRect(-100, w.y(), w.width(), w.height()))
        # a.setEndValue(w.geometry())
        # 添加到组里面去
        ag.addAnimation(a)
    return ag