擅长:python、mysql、java
<p>在所有请求工作完成之前,您可以使用<code>threading</code>或<code>Clock.schedule</code>移动到加载屏幕。查看更多详细信息<a href="https://kivy.org/doc/stable/api-kivy.clock.html" rel="nofollow noreferrer">here</a></p>
<pre><code>def get_data(self):
self.root.ids.MainScreen.pos_hint = {"center_x": .5, "center_y": 50} # Hide main screen
self.root.ids.LoadingScreen.pos_hint = {"center_x": .5, "center_y": .5} # Show load screen
Clock.schedule_once(function_to_get_data)
def function_to_get_data(self, *args):
#code to get data
</code></pre>
<p><strong>更新:</strong>
以下是带参数的线程代码:</p>
<pre><code>def get_data(self):
self.root.ids.MainScreen.pos_hint = {"center_x": .5, "center_y": 50} # Hide main screen
self.root.ids.LoadingScreen.pos_hint = {"center_x": .5, "center_y": .5} # Show load screen
threading.Thread(target = function_to_get_data, args=(param,))
def function_to_get_data(self, param):
#code to get data
</code></pre>