PyQt叠加淡入/淡出动画框架

时间:2016-05-14 06:14:06

标签: python qt pyqt

我一直在研究涉及Qt / PyQt GUI的学校项目。我目前正在尝试使用特定菜单覆盖主窗口。我很乐意在切换时添加一种渐弱的过渡,但我似乎找不到很多可靠的例子。在这方面似乎也缺乏python文档。如果有人可以提供一些功能代码,那就太棒了!

到目前为止我发现的内容,叠加:

from PyQt4.QtCore import *
from PyQt4.QtGui import *
import time
import threading

class overlay(QWidget):
    def __init__(self, parent=None):
        super(overlay, self).__init__(parent)

        self.verticalLayout = QVBoxLayout(self)
        self.button = QPushButton("Hello world!")
        self.verticalLayout.addWidget(self.button)
        self.percent = 0


class windowOverlay(QWidget):
    def __init__(self, parent=None):
        super(windowOverlay, self).__init__(parent)

        self.editor = QTextEdit()
        self.editor.setPlainText("OVERLAY"*100)

        self.button = QPushButton("Toggle Overlay")

        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.addWidget(self.editor)
        self.verticalLayout.addWidget(self.button)

        self.overlay = overlay(self.editor)
        self.overlay.hide()

        self.button.clicked.connect(lambda: self.overlay.setVisible(False) if self.overlay.isVisible() else self.overlay.setVisible(True))

    def resizeEvent(self, event):
        self.overlay.resize(event.size())
        event.accept()

if __name__ == "__main__":
    import  sys

    app = QApplication(sys.argv)
    main = windowOverlay()
    main.show()
sys.exit(app.exec_())

0 个答案:

没有答案