Skip to content
Snippets Groups Projects
Commit 7266406a authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Initial commit.

parents
Branches master
No related tags found
No related merge requests found
*.pyc
*.pyo
.idea
bin
main.py 0 → 100644
from time import sleep, ctime
from kivy.app import App
from kivy.clock import Clock
from kivy.properties import BooleanProperty, StringProperty
from kivy.logger import Logger
class SlowApp(App):
loading = BooleanProperty(False)
message = StringProperty('Ready')
def _log(self, message):
Logger.info(f'{self.__class__.__name__}: {message}')
def _start_loading(self):
assert not self.loading
self.loading = True
self.message = 'Loading…'
self._log(f'Started loading at {ctime()}')
def _stop_loading(self):
assert self.loading
self.loading = False
self.message = 'Done'
self._log(f'Finished loading at {ctime()}')
def delay_improperly(self):
self._start_loading()
sleep(3)
self._stop_loading()
def delay_properly(self):
self._start_loading()
Clock.schedule_once(self._continue_delay_properly)
def _continue_delay_properly(self, delay):
sleep(3)
self._stop_loading()
Logger.info(f'{self.__class__.__name__}: (Lost {delay:.3} seconds to GUI updates.)')
def main():
app = SlowApp()
app.run()
if __name__ == '__main__':
main()
slow.kv 0 → 100644
BoxLayout:
orientation: 'vertical'
BoxLayout:
orientation: 'horizontal'
Button:
id: improper_button
text: 'Slow Operation with\nImproper User Feedback'
disabled: app.loading
on_press: app.delay_improperly()
Button:
id: proper_button
text: 'Slow Operation with\nProper User Feedback'
disabled: app.loading
on_press: app.delay_properly()
Label:
id: message
text: app.message
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment