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
qsnow6
V2EX  ›  Python

IronPython ui 线程怎么调用?

  •  
  •   qsnow6 · 2017-05-18 11:04:18 +08:00 · 1352 次点击
    这是一个创建于 2560 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在 IronPython 想把 UI 线程和主线程分开,避免被卡死 但是敲好代码后发现代码在 UI 下不起作用?

    import wpf
    from System.Windows import Application, Window
    from threading import Thread
    import time
    
    class TiebaClientTools(Window):
    
        def __init__(self):
            wpf.LoadComponent(self, 'TiebaClientTools.xaml')
    
    
            
    
        def Button_Click(self, sender, e):
            def set_text(num):
                time.sleep(num)
                self.textbox.Text = "new text"
            t = Thread(target=set_text, args=(3,))
            t.start()
    
    if __name__ == '__main__':
        Application().Run(TiebaClientTools())
    
    
    1 条回复    2017-05-18 12:45:14 +08:00
    sujin190
        1
    sujin190  
       2017-05-18 12:45:14 +08:00
    首先,ui 线程还是在主线程下的,而且我记得操作系统对主线程启动为 ui 线程是有特殊处理的,你这样是没办法把 ui 线程放到其他线程的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1150 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 22:58 · PVG 06:58 · LAX 15:58 · JFK 18:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.