對於我的應用程序中的某些過程,我使用互聯網來獲取一些數據。所以對於那些處理過的我想要一個簡單的彈出框(帶有文本加載...)出現在進程開始時,但是當我運行測試代碼時,我發現彈出框顯示在進程結束時而不是在使其無用的過程開始時。這是我正在使用的測試代碼。感謝您的幫助,謝謝。在運行過程結束時顯示kivy彈出窗口
class ScreenManagement(ScreenManager):
def popup(self):
self.pop_up=Popup(title='Loading...')
self.pop_up.open()
def popup_done(self):
self.pop_up.dismiss()
def ite(self):
for i in range(100):
App.get_running_app().root.current='second'
return i
def thread_it(self,fx):
self.popup()
mythread = threading.Thread(target=fx)
mythread.start()
def ite(self,num):
for i in range(num):
txt=str(i)*40
self.ids.lbl.text=txt
print txt
#if i==num-1: #this is not working
# self.popup_done()
class labelApp(App):
def build(self):
pass
labelApp().run()
.kv文件
ScreenManagement:
Screen:
BoxLayout:
Button:
#on_press:root.popup()
#on_release:root.popup_done()
on_press:root.thread_it(root.ite(40000))
on_press:root.current='second'
Screen:
name:'second'
BoxLayout:
Label:
id:lbl
text: 'hello'
謝謝,這解決了我的問題! – Linh