Fix old msg clearing var name

asyncify_input_modes
Tyler Goodlet 2021-06-18 09:37:55 -04:00
parent eeeeb29f71
commit 37180a4e4e
1 changed files with 9 additions and 7 deletions

View File

@ -43,7 +43,6 @@ class MultiStatus:
def __init__(self, bar, statuses) -> None: def __init__(self, bar, statuses) -> None:
self.bar = bar self.bar = bar
self.statuses = statuses self.statuses = statuses
# self._clear_last: Optional[Callable[..., None]] = None
self._to_clear: set = set() self._to_clear: set = set()
self._status_groups: dict[str, (set, Callable)] = {} self._status_groups: dict[str, (set, Callable)] = {}
@ -60,9 +59,9 @@ class MultiStatus:
when called will remove the status ``msg``. when called will remove the status ``msg``.
''' '''
for msg in self._to_clear: for old_msg in self._to_clear:
try: try:
self.statuses.remove(msg) self.statuses.remove(old_msg)
except ValueError: except ValueError:
pass pass
@ -71,16 +70,16 @@ class MultiStatus:
def remove_msg() -> None: def remove_msg() -> None:
try: try:
self.statuses.remove(msg) self.statuses.remove(msg)
self.render()
except ValueError: except ValueError:
pass pass
self.render()
if final_msg is not None: if final_msg is not None:
self.statuses.append(final_msg) self.statuses.append(final_msg)
self.render() self.render()
self._to_clear.add(final_msg) self._to_clear.add(final_msg)
ret = remove_msg ret = remove_msg
# create a "status group" such that new `.open_status()` # create a "status group" such that new `.open_status()`
@ -128,14 +127,17 @@ class MultiStatus:
self._status_groups[group_key][0].add(msg) self._status_groups[group_key][0].add(msg)
ret = pop_from_group_and_maybe_clear_group ret = pop_from_group_and_maybe_clear_group
self.render()
if clear_on_next: if clear_on_next:
self._to_clear.add(msg) self._to_clear.add(msg)
self.render()
return ret return ret
def render(self) -> None: def render(self) -> None:
'''Display all open statuses to bar.
'''
if self.statuses: if self.statuses:
self.bar.showMessage(f'{" ".join(self.statuses)}') self.bar.showMessage(f'{" ".join(self.statuses)}')
else: else: