推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
qile1
V2EX  ›  Python

Python 的 SysTrayIcon 如何和循环读取文件一起使用,当检测到文件变化是,控制桌面右下角图标变化

  •  
  •   qile1 · May 29, 2018 · 2397 views
    This topic created in 3049 days ago, the information mentioned may be changed or developed.

    如题,我用多线程启动了一个桌面右下角图像显示的类和一个循环读取日志文件的函数,现在想实现当读取到文件变化时,控制右下角图标变换显示下,不知道如何实现 主要代码如下

    def ReadLogFile("01.log"):

    switch_icon2(SysTrayIcon)#切换右下角图标失败

    t1=threading.Thread(target=SysTrayIcon,args=(icons.__next__(), hover_text, menu_options,on_quit, default_menu_index))
    t1.start()#启动右下角图标程序
    t2=threading.Thread(target=ReadLogFile,args=("01.log"))
    t2.start()#启动右下角图标程序
    

    代码地址: https://paste.ubuntu.com/p/H8gqZs6RPx/

    1 replies  •  2018-05-31 00:46:17 +08:00
    qile1
        1
    qile1  
    OP
       May 31, 2018
    想弄个全局函数 因为 SysTrayIcon(icons.__next__(), hover_text, menu_options,on_quit, default_menu_index) 是阻塞的,没法实现,在 启动 SysTrayIcon ()时候把函数传给读文件的函数 ReadLogFile ()好像也无法实现
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2246 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 05:50 · PVG 13:50 · LAX 22:50 · JFK 01:50
    ♥ Do have faith in what you're doing.