简体   繁体   中英

python: kivy app not closing

my kivy simple hello world app is not closing I'm using raspberry pi B and I can't close it I must unplug my raspberry pi 5v adapter to close it

I'm using rasbian jessie this is the very simple code

import kivy
from kivy.app import App
from kivy.uix.label import Label

class mamdouh(App):
    def build(self):
        return Label(text='mamdouh')

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

What I was trying to say in the comment was. That you need to have some action to cause the quit, as the run method will run in a loop indefinitely otherwise.

If you now click on the Button labeled ' paul ' it will quit.

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button


class mamdouh(App):

    def build(self):
        lbl = Label(text='paul')
        btn = Button(text='mamdouh')
        btn.bind(on_press=lambda b: app.stop())

        lbl.add_widget(btn)

        return lbl

if __name__ == '__main__':

    app = mamdouh()
    app.run()

I know nothing about kivy but I can see that this should allow you to quit, whether you want a Button in your app is another question.

Another way to kill it and avoid the reboot is simply to go back to the prompt where you launched your app and do CTRL + C . This will only work from the prompt though, not from the app window itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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