Home > Back-end >  There's no "Start application main loop" when running a desktop app in python using k
There's no "Start application main loop" when running a desktop app in python using k

Time:01-03

I'm doing a paint program using kivy to start learning python. When I try to run the app to see if it works it opens and immediately closes. What I noticed is that when I run the program there's no "Start application main loop".

Here's my code:

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Line, Color
from kivy.core.window import Window

class MiApp(App):
    def build(self):
        pass

if __name__ == "__main_":
    MiApp().run()

There are no errors in the terminal, it's just the info line that says "Start application main loop" that is missing.

CodePudding user response:

I think you're only missing something minor, another underscore is needed in "__main_"

Example:

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Line, Color
from kivy.core.window import Window

class MiApp(App):
    def build(self):
        pass

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

CodePudding user response:

you missed one _ in

if __name__ == "__main__":

CodePudding user response:

Exactly, it does not start with your if clause. Add the second underscore after == "__main_" or run without if. Just like in Python REPL below:

>>> MiApp().run()
[INFO   ] [ProbeSysfs  ] device match: /dev/input/event4
[INFO   ] [MTD         ] Read event from </dev/input/event4>
[INFO   ] [Base        ] Start application main loop
[WARNING] [MTD         ] Unable to open device "/dev/input/event4". Please ensure you have the appropriate permissions.
  • Related