简体   繁体   English

带有colab的黑屏简单kivy

[英]black screen simple kivy with colab

I have made a simple app with kivy, just to test how to create a .apk and using colab to compile I get a black screen on my phone and in BlueStacks.我用 kivy 制作了一个简单的应用程序,只是为了测试如何创建 .apk 并使用 colab 进行编译,我的手机和 BlueStacks 出现黑屏。 This is the app:这是应用程序:

main.py:主要.py:

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.widget import Widget


class BoxLayoutMain(BoxLayout):
    pass

class MainWidget(Widget):
    pass

class dctApp(App):
    pass

dctApp().run()

and dctApp.kv:和 dctApp.kv:

BoxLayoutMain:

<MainWidget>:

<BoxLayoutMain>:
    orientation: "vertical"

    Label:
        text: "Lash"
        font_name: "fonts/DINNeuzeitGrotesk-Light Regular.ttf"
        font_size: "40dp"
        size_hint: 1, 0.1
        background_color: (255/255, 142/255, 142/255, 1)
        canvas.before:
            Color:
                rgba: self.background_color
            Rectangle:
                size: self.size
                pos: self.pos


    Carousel:
        direction: "bottom"

        Button:
            text: "this is a test"

    BoxLayout:
        orientation: "horizontal"
        size_hint: 1, 0.1

        Button:
            text: "B"
            background_normal: ""
            background_color: (255/255, 142/255, 142/255, 255/255)

        Button:
            text: "B"
            background_normal: ""
            background_color: (255/255, 142/255, 142/255, 255/255)

        Button:
            text: "B"
            background_normal: ""
            background_color: (255/255, 142/255, 142/255, 255/255)

It's basically a .py file and a .kv file to show some items.它基本上是一个 .py 文件和一个 .kv 文件来显示一些项目。 When I run it in Pycharm it works fine, but when I create the .apk in Colab, it's just black.当我在 Pycharm 中运行它时它工作正常,但是当我在 Colab 中创建 .apk 时,它只是黑色的。 Please help!请帮忙! I have no idea what to do!我不知道该怎么做! Thank you谢谢

Your kv file name is wrong.你的kv文件名是错误的。 It should be dct.kv .它应该是dct.kv See the documentation .请参阅文档

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

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