Screen get freez for 1min when press button

18 views
Skip to first unread message

Himanshu Pharawal

unread,
Dec 27, 2018, 11:16:53 AM12/27/18
to Kivy users support

I have a button in my code which suppose change label text to 'Status: Wait..' and when done so it should change to 'Status: Done..'when i press the whole screen get freeze for 1min :

when i press button below method invoke.

(Note:- that variable called tags in 3rd line is a list contains around 1000+ strings maybe that's why my app get freez)

  • But the problem is status.text never set to 'Status: Wait..' it directly goes to 'Status: Done..'**. I mean if it get freez because of 3rd line so at least 2nd should execute first.**


def update_logs(self):
		self.ids.status.text = 'Status: Wait..'
		for log in tags:
			self.ids.logs_grid.add_widget(Label(text=log))
		self.ids.status.text = 'Status: Done..'
  • in 2nd line status is a id of a label which is in kv.

  • in 4th line logs_grid is a id of gridlayout which is in kv

ZenCODE

unread,
Dec 27, 2018, 2:25:20 PM12/27/18
to Kivy users support
Yes, that is expected. You need to exit the function to free up the kivy event loop to update the label. One way to do it would be something like...

def update_logs(self):
   
self.ids.status.text = 'Status: Wait..'

   
def do_loop(dt):

       
for log in tags:
           
self.ids.logs_grid.add_widget(Label(text=log))
       
self.ids.status.text = 'Status: Done..'


   
from kivy.clock import Clock
   
Clock.schedule_once(do_loop)

Himanshu Pharawal

unread,
Dec 28, 2018, 12:05:15 AM12/28/18
to Kivy users support
Well my button got pressed, status also set to wait but screen still get freez, ?? do i need to use asynchronous aproach here??? and one more thing that scroll view also scroll very slow why??

ZenCODE

unread,
Dec 28, 2018, 4:15:26 PM12/28/18
to Kivy users support
The screen probably still freezes because you are adding 1000+ strings. Probably the same reason the scrollview is still slow. Try using the RecycleView. It's built for use cases like this....
Reply all
Reply to author
Forward
0 new messages