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

tkinter join() 界面卡住

  •  
  •   302766392 · 2018-05-30 09:44:33 +08:00 · 2105 次点击
    这是一个创建于 2155 天前的主题,其中的信息可能已经有所发展或是发生改变。
    import sys
    import time
    import threading
    from tkinter import *
    from tkinter.messagebox import showinfo

    class Demo:

    def __init__(self, master):
    Button(master, text='execute', command=self.a).pack()

    def a(self):
    t = threading.Thread(target=self.b, args=(123, ))
    t.start()
    t.join()
    print('over')

    def b(self, val):
    showinfo('xx', 'xxxx')
    print(val)
    sys.stdout.flush()

    root = Tk()
    display = Demo(root)
    root.mainloop()


    请问为什么用了 join()之后点击界面就卡住了 不用 tkinter 一切都正常
    302766392
        1
    302766392  
    OP
       2018-05-30 09:54:18 +08:00
    问题已解决 是界面的问题 在 join()前加上界面刷新一切正常
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3254 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 13:29 · PVG 21:29 · LAX 06:29 · JFK 09:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.