【问题标题】:My kivy code is not displaying anything. Please tell me where I am going wrong我的 kivy 代码没有显示任何内容。请告诉我哪里出错了
【发布时间】:2020-06-19 12:32:25
【问题描述】:

我设计了一个 kivy 表单,它从用户那里获取一些信息..但是没有一个显示出来..请告诉我哪里出错了。

我的代码:

import kivy
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.screenmanager import ScreenManager
from kivy.uix.floatlayout import FloatLayout    

class Widgets(Widget):
    pass


class YourDiaryApp(App):
    def build(self):
        return Widgets()

if __name__ == "__main__":
    YourDiaryApp().run()

基维码:

<Widgets>:
    FloatLayout:

        Label:
            text:'What do you want me to call you'
        TextInput:
            id:username

        Label:
            text:'What do you wanna call me'
        TextInput:
            id:diaryname

        Label:
            text:'What will be your password'
        TextInput:
            id:password

        Button:
            text:'Complete Setup'

【问题讨论】:

    标签: python-3.x user-interface kivy kivy-language


    【解决方案1】:

    您的 KV 文件是否名为“yourDiaryApp.kv”?来自docs

    有两种方法可以将 Kv 代码加载到您的应用程序中:

    按名称约定:

    Kivy 查找与您的 App 类同名的小写 Kv 文件,如果以“App”结尾则减去“App”,例如:

    MyApp -> my.kv
    

    我的猜测是没有加载 KV 代码。

    【讨论】:

    • 是的兄弟!我的命名约定错误..我将 kv 文件命名为 yourdiaryapp.kv..感谢您的帮助...
    猜你喜欢
    • 2021-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-23
    • 1970-01-01
    • 2012-09-07
    • 1970-01-01
    相关资源
    最近更新 更多