0
我需要一些小工具來更新我的kivy屏幕,隨着線程thread.eveything與部件的異常完美的作品在屏幕上進行更新屏幕在kivy拒絕更新
<ViewScreen>:
id:grid
pic:pic
cols:2
spinner:spinner
MDSpinner:
active:False
class ViewScreen(Screen):
grid = ObjectProperty(None)
pic = ObjectProperty(None)
spinner = ObjectProperty(None)
def load_real(self):
_thread.start_new_thread(self.list_files, ('name',))
def list_files(self, name):
time.sleep(1)
self.ids.spinner.active = True
self.ids.grid.clear_widgets()
url = 'http://po.com/{}'.format(str(self.code_url[0]))
r = requests.get(url)
data = r.text
soup = BeautifulSoup(data)
for link in soup.find_all('a'):
if link.get('href').endswith('.png'):
print(link.get('href'))
self.passed.append(link.get('href'))
print(self.passed)
for photo in self.passed:
src = 'http://po.com/{}/{}'.format(self.code_url[0],photo)
print(src)
album = AsyncImage(source=src,)
self.ids.grid.add_widget(album)
self.spinner.active = False
self.code_url.pop(0)
print(self.code_url)