V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2018-05-29 01:37:00 +08:00 · 1512 次点击
    这是一个创建于 2131 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    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 条回复    2018-05-31 00:46:17 +08:00
    qile1
        1
    qile1  
    OP
       2018-05-31 00:46:17 +08:00
    想弄个全局函数 因为 SysTrayIcon(icons.__next__(), hover_text, menu_options,on_quit, default_menu_index) 是阻塞的,没法实现,在 启动 SysTrayIcon ()时候把函数传给读文件的函数 ReadLogFile ()好像也无法实现
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1275 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:27 · PVG 07:27 · LAX 16:27 · JFK 19:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.