mirror of https://github.com/kivy/kivy.git
Updated Using Asynchronous programming inside a Kivy application (markdown)
parent
b374b496df
commit
066d0051f2
|
@ -30,8 +30,6 @@ class MyApp(App):
|
|||
|
||||
grid.add_widget(Button(text='Check Primes',
|
||||
on_press=self.cpu_bound))
|
||||
grid.add_widget(Button(text='Check async def',
|
||||
on_press=self.async_def))
|
||||
self.status = Label(text='Status')
|
||||
grid.add_widget(self.status)
|
||||
return grid
|
||||
|
@ -48,20 +46,6 @@ class MyApp(App):
|
|||
for n, prime in zip(PRIMES, prime_flags))
|
||||
self.status.text = text
|
||||
|
||||
async def async_def(self, *_):
|
||||
t = time.time()
|
||||
self.status.text = "calculating..."
|
||||
prime_flags = []
|
||||
for n in PRIMES:
|
||||
result = await is_prime(n)
|
||||
prime_flags.append(result)
|
||||
print(time.time() - t)
|
||||
text = '\n'.join("%s: %s" % (n, prime)
|
||||
for n, prime in zip(PRIMES, prime_flags))
|
||||
self.status.text = text
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
MyApp().run()
|
||||
```
|
Loading…
Reference in New Issue