Adding movement to Loading and Refreshing text

This commit is contained in:
Vishal 2024-06-19 21:15:42 +05:30 committed by GitHub
parent b8efbd288b
commit e80d8b76a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1823,13 +1823,14 @@ class PluginManagerWindow(bui.Window):
parent=self._root_widget, parent=self._root_widget,
position=(-5, loading_pos_y), position=(-5, loading_pos_y),
size=(self._width, 25), size=(self._width, 25),
text="Loading...", text="Loading",
color=bui.app.ui_v1.title_color, color=bui.app.ui_v1.title_color,
scale=0.7, scale=0.7,
h_align="center", h_align="center",
v_align="center", v_align="center",
maxwidth=400, maxwidth=400,
) )
self._dot_timer = babase.AppTimer(0.5, self._update_dots, repeat=True)
def _back(self) -> None: def _back(self) -> None:
from bauiv1lib.settings.allsettings import AllSettingsWindow from bauiv1lib.settings.allsettings import AllSettingsWindow
@ -1852,6 +1853,7 @@ class PluginManagerWindow(bui.Window):
try: try:
yield yield
except urllib.error.URLError: except urllib.error.URLError:
self._dot_timer = None
bui.textwidget(edit=self._plugin_manager_status_text, bui.textwidget(edit=self._plugin_manager_status_text,
text="Make sure you are connected\n to the Internet and try again.") text="Make sure you are connected\n to the Internet and try again.")
self.plugin_manager._index_setup_in_progress = False self.plugin_manager._index_setup_in_progress = False
@ -1859,10 +1861,19 @@ class PluginManagerWindow(bui.Window):
# User probably went back before a bui.Window could finish loading. # User probably went back before a bui.Window could finish loading.
pass pass
except Exception as e: except Exception as e:
self._dot_timer = None
bui.textwidget(edit=self._plugin_manager_status_text, bui.textwidget(edit=self._plugin_manager_status_text,
text=str(e)) text=str(e))
raise raise
def _update_dots(self):
text = cast(str, bui.textwidget(query=self._plugin_manager_status_text))
if text.endswith('....'):
text = text[0:len(text)-4]
text = text + '.'
bui.textwidget(edit=self._plugin_manager_status_text,
text=text)
async def draw_index(self): async def draw_index(self):
self.draw_search_bar() self.draw_search_bar()
self.draw_plugins_scroll_bar() self.draw_plugins_scroll_bar()
@ -1872,6 +1883,7 @@ class PluginManagerWindow(bui.Window):
await self.plugin_manager.setup_changelog() await self.plugin_manager.setup_changelog()
with self.exception_handler(): with self.exception_handler():
await self.plugin_manager.setup_index() await self.plugin_manager.setup_index()
self._dot_timer = None
bui.textwidget(edit=self._plugin_manager_status_text, bui.textwidget(edit=self._plugin_manager_status_text,
text="") text="")
await self.select_category("All") await self.select_category("All")
@ -2215,12 +2227,15 @@ class PluginManagerWindow(bui.Window):
async def refresh(self): async def refresh(self):
self.cleanup() self.cleanup()
bui.textwidget(edit=self._plugin_manager_status_text, bui.textwidget(edit=self._plugin_manager_status_text,
text="Refreshing...") text="Refreshing")
if self._dot_timer is None:
self._dot_timer = babase.AppTimer(0.5, self._update_dots, repeat=True)
with self.exception_handler(): with self.exception_handler():
await self.plugin_manager.refresh() await self.plugin_manager.refresh()
await self.plugin_manager.setup_changelog() await self.plugin_manager.setup_changelog()
await self.plugin_manager.setup_index() await self.plugin_manager.setup_index()
self._dot_timer = None
bui.textwidget(edit=self._plugin_manager_status_text, bui.textwidget(edit=self._plugin_manager_status_text,
text="") text="")
await self.select_category(self.selected_category) await self.select_category(self.selected_category)