tui: Q&D adaptation to new code:
use the new `quick_bridge` adapter and do few changes to make TUI work with new backend. TUI will probably be rewritten at some point, this is just an update to keep it working. `urwid` has been updated to have a version working with Python 3.14.
This commit is contained in:
parent
d3dc59b141
commit
e5ed4e3d7c
1 changed files with 135 additions and 77 deletions
|
|
@ -54,24 +54,31 @@ class Progress(urwid.WidgetWrap, quick_widgets.QuickWidget):
|
|||
|
||||
def progress_cb(self, loop, data):
|
||||
progress_id, message, profile = data
|
||||
data = self.host.bridge.progress_get(progress_id, profile)
|
||||
pbar = self.progress_dict[(progress_id, profile)]["progress"]
|
||||
if data:
|
||||
if self.progress_dict[(progress_id, profile)]["state"] == "init":
|
||||
# first answer, we must construct the bar
|
||||
self.progress_dict[(progress_id, profile)]["state"] = "progress"
|
||||
pbar.done = float(data["size"])
|
||||
|
||||
pbar.set_completion(float(data["position"]))
|
||||
self.update_not_bar()
|
||||
else:
|
||||
if self.progress_dict[(progress_id, profile)]["state"] == "progress":
|
||||
self.progress_dict[(progress_id, profile)]["state"] = "done"
|
||||
pbar.set_completion(pbar.done)
|
||||
self.update_not_bar()
|
||||
def progress_get_cb(data):
|
||||
entry = self.progress_dict.get((progress_id, profile))
|
||||
if entry is None:
|
||||
# the bar has been removed in the meantime
|
||||
return
|
||||
pbar = entry["progress"]
|
||||
if data:
|
||||
if entry["state"] == "init":
|
||||
# first answer, we must construct the bar
|
||||
entry["state"] = "progress"
|
||||
pbar.done = float(data["size"])
|
||||
|
||||
loop.set_alarm_in(0.2, self.progress_cb, (progress_id, message, profile))
|
||||
pbar.set_completion(float(data["position"]))
|
||||
self.update_not_bar()
|
||||
else:
|
||||
if entry["state"] == "progress":
|
||||
entry["state"] = "done"
|
||||
pbar.set_completion(pbar.done)
|
||||
self.update_not_bar()
|
||||
return
|
||||
|
||||
loop.set_alarm_in(0.2, self.progress_cb, (progress_id, message, profile))
|
||||
|
||||
self.host.bridge.progress_get(progress_id, profile, callback=progress_get_cb)
|
||||
|
||||
def _remove_bar(self, progress_id, profile):
|
||||
wid = self.progress_dict[(progress_id, profile)]["full"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue