繁体   English   中英

使用 KIVY 弹出窗口我有 NameError

[英]Using KIVY Popup I have NameError

上次我解决了这个错误,多亏了你。 但是,由于我缺乏技能,我查了很多数据,但无法解决错误。

  1. 如果我单击信息按钮会发生此错误消息。 NameError 中的文件“”第 27 行:未定义名称“工厂”

  2. 我想做项目。 这张照片。 但是按钮位置总是不好。 在此处输入图像描述 这是我的 Python KIVY 代码

#project.kv file

kv = '''
BoxLayout:
orientation: 'vertical'
Upper_bar:
size_hint: (1, 0.1)
Label:
text: 'Select Mode'
BoxLayout:
padding: [90, 40]
size_hint: (1, 0.5)
orientation: 'horizontal'
Button:
        size_hint: (0.5, 1)
        text: 'Object'

    BoxLayout:

    Button:
        size_hint: (0.5, 1)
        text: 'Street'

<Upper_bar>:
BoxLayout:
Button:
    size_hint: (0.3, 1)
    text: 'Information'
    on_press: Factory.InformationPop().open()

<InformationPop@Popup>:
size_hint: 0.5, 0.5
tittle: 'Information'
auto_dismiss: True
BoxLayout:
    orientation: 'vertical'
    Label:
        text:
            """Name:
            Student Number:
            E-mail: """

    Button:
        text:
            'Close'
        on_press:
            root.dismiss()
            size_hint_y: None
            height: '40dp'
'''

class Upper_bar(BoxLayout):
    pass

class AIObjectCameraApp(App): 

def build(self): 
    return Builder.load_string(kv)


if __name__ == '__main__': 
    AIObjectCameraApp().run()

您只是忘记在kv字符串的顶部添加Factory的导入:

#:import Factory kivy.factory.Factory

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM