简体   繁体   中英

Manually closing the kivy app makes the spyder window crash

I'm just starting to code with the kivy library, but when i run the tutorial code, i can't close the window. When i do it, the window crashes and i can't run the code anymore.

import kivy
kivy.require('1.0.6') # replace with your current kivy version !

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


class MyApp(App):

    def build(self):
        return Label(text='Hello world')


if __name__ == '__main__':
    MyApp().run()
  1. When you use the internal console, it is running the kivy file inside it, using runfile(). Click to manually close the window, which will allow for a new interactive line in the internal console. Type exit() in the console. That will close the console, which will also close the frozen kivy window. Spyder will open a new internal console.

  2. A better way is to change the setting to use an external terminal. Select "Run>Configuration per file" from the menu bar. Change the setting in the Console group to "Execute in an external system terminal" Optionally, check the box at the bottom "Always show this dialog on a first file run". Click OK at the bottom to save your changes. Now when you run the kivy file, it will run in an external terminal, not a console, and the manual close button will work.

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