• 转载:python原生态的输入窗口抖动+输入特效


    python原生态的输入窗口抖动+输入特效

    出处:https://coding.net/u/acee/p/PythonPowerInput/git/blob/master/test_power_input.py

    __author__ = 'Administrator'
    import sys
    from lib.qm_app import App
    from PyQt4.QtGui import *
    from PyQt4.QtCore import *
    import random
    import time
    class MoveThread(QThread):
        MoveValue = pyqtSignal(QPoint)
        def __init__(self, source_pos, parent):
            super(MoveThread, self).__init__(parent)
            self.source_pos = source_pos
        def run(self):
            for a in xrange(5):
                self.MoveValue.emit(self.source_pos + QPoint(random.randint(1, 5),
                                                             random.randint(1, 5)))
                time.sleep(0.05)
    class LoadWidget(QLabel):
        Start = pyqtSignal()
        def __init__(self, gif_path, parent=None):
            super(LoadWidget, self).__init__(parent)
            self.setAttribute(Qt.WA_TranslucentBackground, True)
            self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.Window | Qt.FramelessWindowHint)
            self.movie = QMovie(gif_path)
            self.movie.setScaledSize(QSize(50, 50))
            self.setMovie(self.movie)
            self.movie.frameChanged.connect(self.stop)
            self.movie.start()
        def start(self):
            self.movie.start()
            self.show()
            self.Start.emit()
        def stop(self, frame):
            if frame == 11:
                self.movie.stop()
                self.close()
    class PowerInput(QTextEdit):
        def __init__(self):
            super(PowerInput, self).__init__()
            self.textChanged.connect(self.play_effect)
            self.move_thread = MoveThread(None, self)
            self.move_thread.MoveValue.connect(self.move)
        def showEvent(self, event):
            super(PowerInput, self).showEvent(event)
            self.move_thread.source_pos = self.mapToGlobal(self.pos())
        def play_effect(self, *args, **k):
            rect = self.cursorRect()
            pos = self.mapToGlobal(QPoint(rect.x(), rect.y()))
            self.w = LoadWidget('d:/test.gif', self)
            self.w.Start.connect(self.set_f)
            self.w.move(pos)
            self.w.start()
        def set_f(self):
            self.setFocus()
            self.activateWindow()
            self.move_thread.start()
    if __name__ == '__main__':
        app = App(sys.argv)
        windows = PowerInput()
        windows.show()
        app.exec_()
    

      

  • 相关阅读:
    使用socket BPF/Linux内核工程导论——网络:Filter(LSF、BPF、eBPF)
    使用Iperf工具测试android系统网络wifi的吞吐量wifithrougput
    html input中 button和submit的区别
    Linux转发性能评估与优化(转发瓶颈分析与解决方案)
    交叉编译器 arm-linux-gnueabi 和 arm-linux-gnueabihf 的区别
    MySQL查询不区分大小写的sql写法
    Docker镜像保存save、加载load
    将Spring-boot应用部署到Docker容器
    Docker 安装使用
    Scalatra文件下载时中文乱码
  • 原文地址:https://www.cnblogs.com/ribavnu/p/5015333.html
Copyright © 2020-2023  润新知