【问题标题】:kivy - name Error name Thread is not definedkivy - name 错误名称 未定义线程
【发布时间】:2021-05-01 23:39:29
【问题描述】:

我有这个代码

from threading import Thread
...
Builder.load_string('''
<Urlpup>:
    size_hint: .7, .7
    auto_dismiss: False
    title: 'Enter URL'
    BoxLayout:
        orientation: 'vertical'
        CustomTextInput:
            id: url_input
            multiline: False
        Button:
            text: 'OK'    
            on_press: root.dismiss()
            on_release: Thread(target=app.create_new_article(url_input.text)).start()
''')

运行时出现 Name Error name Thread is not defined

【问题讨论】:

    标签: kivy


    【解决方案1】:

    需要在kv上下文中导入Thread,见the documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-21
      • 2022-01-01
      • 1970-01-01
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多