BInaryBard2020
BInaryBard2020

Reputation: 55

Blank white screen when running kivyMD app. No compiler errors

So I'm new to kivyMD and am trying to use it to develop a mobile app. I'm trying to run a simple script that will have the various types of buttons that are used in kivyMD. I'm using the kitchensink demo to try and learn how everything within the framework works. However when I run my script I get no compiler errors in the terminal and the app opens but it's a blank white screen. I don't know how to fix this as I can't effectively diagnose the problem. Does anybody have any ideas?

In the main.py file

from kivy.lang import Builder
from kivymd.app import MDApp

class MainApp(MDApp):
    def build(self):
        pass


if __name__ == '__main__':
    app = MainApp()
    app.run()

In the main.kv file:

MDScreen:

    MDFlatButton:
        text: 'MDFlatButton'
        pos_hint: {'center_x': 0.5, 'center_y': 0.9}

    MDRaisedButton:
        text: 'MDRaisedButton'
        pos_hint: {'center_x': 0.5, 'center_y': 0.8}

    MDRectangleFlatButton:
        text: 'MDRectangleFlatButton'
        pos_hint: {'center_x': 0.5, 'center_y': 0.7}

    MDRectangleFlatIconButton:
        icon: 'language-python'
        text: 'MDRectangleFlatIconButton'
        pos_hint: {'center_x': 0.5, 'center_y': 0.6}

    MDRoundFlatButton:
        text: 'MDRoundFlatButton'
        pos_hint: {'center_x': 0.5, 'center_y': 0.5}

    MDRoundFlatIconButton:
        icon: 'language-python'
        text: 'MDRoundFlatIconButton'
        pos_hint: {'center_x': 0.5, 'center_y': 0.4}

    MDFillRoundFlatIconButton:
        icon: 'language-python'
        text: 'MDFillRoundFlatIconButton'
        pos_hint: {'center_x': 0.5, 'center_y': 0.3}

    MDFillRoundFlatButton:
        text: 'MDFillRoundButton'
        pos_hint: {'center_x': 0.5, 'center_y': 0.2}

    MDTextButton:
        text: 'MDTextButton'
        pos_hint: {'center_x': 0.3, 'center_y': 0.1}

    MDIconButton:
        icon: 'language-python'
        pos_hint: {'center_x': 0.7, 'center_y': 0.1}

    MDFloatingActionButtonSpeedDial:
        data: app.data
        rotation_root_button: True

Upvotes: 1

Views: 561

Answers (2)

adfinem_rising
adfinem_rising

Reputation: 43

There is this weird bug in PyCharm for Ubuntu wherein you have to

name your .kv file in all lower case!! (eg. "main.kv" instead of "Main.kv")

or else!

your kivy file (.kv file) would not be recognized by PyCharm at all.

It's very weird. And I have only experienced it with PyCharm installed in Ubuntu and when working with Kivy or KivyMD.

Upvotes: 0

Ne1zvestnyj
Ne1zvestnyj

Reputation: 1397

You can directly specify where your kv file is.

from kivy.lang.builder import Builder
from kivymd.app import MDApp


class MainApp(MDApp):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.data = {
            'Python': 'language-python',
            'PHP': 'language-php',
            'C++': 'language-cpp',
        }

    def build(self):
        return Builder.load_file('main.kv')


if __name__ == '__main__':
    app = MainApp()
    app.run()

Upvotes: 1

Related Questions