zoukankan      html  css  js  c++  java
  • 采用Python-Qt5制作置顶透明桌面提醒词/座右铭/便签

    目标

    制作一款小软件,能够置顶窗口且透明不妨碍办公的形式进行桌面提醒,比如工作计划/座右铭/便签之类。
    由于tkinter不支持背景透明和无窗口模式,因此选用Qt.

    制作方法

    直接上代码:

    # reminder.py
    import sys
    from PyQt5 import QtWidgets
    from PyQt5 import QtCore, QtGui
    
    remind_text = open('remindme.txt', 'rt').read()
    
    def StartReminder():
        app = QtWidgets.QApplication(sys.argv)
        w_ = QtWidgets.QMainWindow()
        w_.resize(512, 360)
        w_.setWindowTitle("hello Qt5")
        
        w_.setWindowFlags(QtCore.Qt.SplashScreen|QtCore.Qt.FramelessWindowHint|QtCore.Qt.WindowStaysOnTopHint)
        w_.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        w_.setStyleSheet("background:transparent;")
        
        label = QtWidgets.QLabel(w_)
        label.setGeometry(QtCore.QRect(480, 240, 1024, 300))
        label.setStyleSheet("color:rgba(200,0,0,50);")
        label.setFont(QtGui.QFont("Courier New", 36))
        label.setText(remind_text)
        
        w_.showFullScreen()
        sys.exit(app.exec())
    
    if __name__ == '__main__':
        StartReminder() 
    

    效果如下:
    effects

    特别香的是,采用start /b python reminder.py启动该软件,不仅不会有窗口,甚至连任务栏上的图标都不显示,命令行也没有任何提示,进程都在后台运行中。

  • 相关阅读:
    SQLite3 of python
    爬虫半成品
    python初体验 ——>>> 模拟体育竞技
    文件操作
    numpy 库简单使用
    numpy 与 matplotlib 的应用
    面向对象的详细解读
    使用python进行微信好友分析
    我的第一个爬虫实验
    排球训练营
  • 原文地址:https://www.cnblogs.com/thisisajoke/p/13962710.html
Copyright © 2011-2022 走看看