how to exit app

6,973 views
Skip to first unread message

Janette Bode

unread,
Feb 11, 2014, 4:36:18 AM2/11/14
to kivy-...@googlegroups.com
from kivy.app import App
from kivy.uix.label import Label
from kivy.clock import Clock
import socket

class MyApp(App):
     
def build(self):
       
return Label(text="test app")

def timer_callback(dt):
   
try:
        data
, addr = sock.recvfrom( 1024 )
       
if data == "exit\n":
            sock
.close()
           
Clock.unschedule(timer_callback)

            quit
()      # how do i quit GUI (MyApp) ???

   
except socket.error, e:
       
if e.errno != 10035:
           
raise e

if __name__ == '__main__':
    IP
= "127.0.0.1"
    PORT
= 1234
    sock
= socket.socket(socket.AF_INET, # Internet
                      socket
.SOCK_DGRAM) # UDP
    sock
.setblocking(0)
    sock
.bind((IP, PORT))

   
Clock.schedule_interval(timer_callback, 1)

   
MyApp().run()


Hello, in timer_callback() i wanna quit the app if 'exit' is received. 
But my GUI still is open after quit() (Kivy on Windows)

How do i exit an Kivy-App with code ??

greets Janette


ZenCODE

unread,
Feb 11, 2014, 9:33:15 AM2/11/14
to kivy-...@googlegroups.com
frim kivy.app import App
App.get_running_app().stop()


That should do it?

Peace

ZenCODE

unread,
Feb 11, 2014, 1:05:44 PM2/11/14
to kivy-...@googlegroups.com
from kivy.app import App
App.get_running_app().stop()



Message has been deleted

Janette Bode

unread,
Feb 12, 2014, 2:44:52 AM2/12/14
to kivy-...@googlegroups.com
the GUI Window didnt close and i must kill it with task manager.
Any further idea ?

 btw on android it works app and gui close

Ben Rousch

unread,
Feb 12, 2014, 6:22:37 AM2/12/14
to kivy-...@googlegroups.com
So where does it not work?


--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
 Ben Rousch
   bro...@gmail.com
   http://clusterbleep.net/

ZenCODE

unread,
Feb 12, 2014, 7:21:47 AM2/12/14
to kivy-...@googlegroups.com
It's probably an issue with background threads. If the socket is creating any background threads for listening, that's probably it. Unfortunately, I've not used the socket module but a scan through the docs suggests calling sock.shutdown() before sock.close()?

Cheers
Message has been deleted

Janette Bode

unread,
Feb 12, 2014, 5:42:19 PM2/12/14
to kivy-...@googlegroups.com
Ive found the problem. Code works well with Python shell. The prob belongs to PyScripter IDE.
Thx for your help.

Janette Bode

unread,
Feb 12, 2014, 5:48:38 PM2/12/14
to kivy-...@googlegroups.com
eee


Am Mittwoch, 12. Februar 2014 13:21:47 UTC+1 schrieb ZenCODE:

Janette Bode

unread,
Feb 12, 2014, 5:49:09 PM2/12/14
to kivy-...@googlegroups.com
eee

Am Mittwoch, 12. Februar 2014 13:21:47 UTC+1 schrieb ZenCODE:

Janette Bode

unread,
Feb 12, 2014, 5:51:36 PM2/12/14
to kivy-...@googlegroups.com
Ive found the prob. The code works direct with Python shell. The prob belongs to Pyscripter-IDE.
Thx for your help.
Reply all
Reply to author
Forward
0 new messages