Breaking Main loop in kivy (Freezing Screen)

575 views
Skip to first unread message

Nisarg Jani

unread,
May 30, 2015, 4:24:13 AM5/30/15
to kivy-...@googlegroups.com
hey guys ... i got and issue that when i bind a finction with an button that works good but when i bind a function which has a infinite loop in it so screen got freezed and other button do not works as example below

from kivy.uix.popup import Popup
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.stacklayout import StackLayout



class APPLICATION_START(FloatLayout):

         def __init__(self, **kwargs):


            super(MyApp, self).__init__(**kwargs)

            self.buone = Button(text="Start Loop",pos=(0,180),size=(470,90),size_hint=(None,None))
   
            self.logi.bind(on_release=self.loooop)

            self.exitbtn = Button(text="exit",pos=(0,90),size=(235,70),size_hint=(None,None))
          
            self.exitbtn.bind(on_press=exit)

       
        def loooop(self,instance):
         
                  while True:
                             # do any Activity


#I want to break this loop when someone press on exit button

class MyApp(App):

    def build(self):
  
        return APPLICATION_START()


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


   

Any help will be appreciated thanks in advance


















Der Achim

unread,
May 30, 2015, 4:25:44 PM5/30/15
to kivy-...@googlegroups.com
Well, I think your program did exactly, what you told it to do: enter an endless loop. From that, no recovery is possible.
Kivy is event driven and you need to honour that. There is plenty of literature about that:
https://books.google.de/books?id=U-JxBgAAQBAJ&pg=PA20&lpg=PA20&dq=kivy+event+driven&source=bl&ots=VptCxHcmWP&sig=kp1IejzaZ_z6oRTkpzspDr9jpSc&hl=de&sa=X&ei=ERxqVenbNcb3UJCngaAF&ved=0CE8Q6AEwBQ#v=onepage&q=kivy%20event%20driven&f=false

A solution is often to use the Clock class:
http://stackoverflow.com/questions/12317278/trying-to-build-a-metronome-in-kivy-event-loop-management

Achim

Nisarg Jani

unread,
May 31, 2015, 12:42:07 AM5/31/15
to kivy-...@googlegroups.com

Can you please send a little code so i can understand it better...or just tell me where i have to edit in my code to pause this loop

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/0cxOu4vRz_U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages