Mercurial > libervia-backend
diff libervia/frontends/quick_frontend/quick_widgets.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 26b7ed2817da |
children |
line wrap: on
line diff
--- a/libervia/frontends/quick_frontend/quick_widgets.py Tue Jun 18 12:06:45 2024 +0200 +++ b/libervia/frontends/quick_frontend/quick_widgets.py Wed Jun 19 18:44:57 2024 +0200 @@ -55,7 +55,8 @@ class QuickWidgetsManager(object): """This class is used to manage all the widgets of a frontend - A widget can be a window, a graphical thing, or someting else depending of the frontend""" + A widget can be a window, a graphical thing, or someting else depending of the frontend + """ def __init__(self, host): self.host = host @@ -257,20 +258,26 @@ recreate_args(_args, _kwargs) widget = cls(*_args, **_kwargs) widgets_map[hash_].append(widget) - log.debug("widget <{wid}> already exists, a new one has been recreated" - .format(wid=widget)) + log.debug( + "widget <{wid}> already exists, a new one has been recreated".format( + wid=widget + ) + ) elif callable(on_existing_widget): widget = on_existing_widget(widget) if widget is None: raise exceptions.InternalError( - "on_existing_widget method must return the widget to use") + "on_existing_widget method must return the widget to use" + ) if widget not in widgets_map[hash_]: log.debug( - "the widget returned by on_existing_widget is new, adding it") + "the widget returned by on_existing_widget is new, adding it" + ) widgets_map[hash_].append(widget) else: raise exceptions.InternalError( - "Unexpected on_existing_widget value ({})".format(on_existing_widget)) + "Unexpected on_existing_widget value ({})".format(on_existing_widget) + ) return widget @@ -296,13 +303,14 @@ """ # TODO: all_instances must be independante kwargs, this is not possible with Python 2 # but will be with Python 3 - all_instances = kwargs.get('all_instances', False) + all_instances = kwargs.get("all_instances", False) if all_instances: for w in self.get_widget_instances(widget_to_delete): if w.on_delete(**kwargs) == False: log.debug( - f"Deletion of {widget_to_delete} cancelled by widget itself") + f"Deletion of {widget_to_delete} cancelled by widget itself" + ) return else: if widget_to_delete.on_delete(**kwargs) == False: @@ -318,8 +326,9 @@ except KeyError: log.error("no widgets_map found for class {cls}".format(cls=class_)) return - widget_hash = str(class_.get_widget_hash(widget_to_delete.target, - widget_to_delete.profiles)) + widget_hash = str( + class_.get_widget_hash(widget_to_delete.target, widget_to_delete.profiles) + ) try: widget_instances = widgets_map[widget_hash] except KeyError: @@ -340,13 +349,17 @@ # all instances with this hash have been deleted # we remove the hash itself del widgets_map[widget_hash] - log.debug("All instances of {cls} with hash {widget_hash!r} have been deleted" - .format(cls=class_, widget_hash=widget_hash)) + log.debug( + "All instances of {cls} with hash {widget_hash!r} have been deleted".format( + cls=class_, widget_hash=widget_hash + ) + ) self.host.call_listeners("widgetDeleted", widget_to_delete) class QuickWidget(object): """generic widget base""" + # FIXME: sometime a single target is used, sometimes several ones # This should be sorted out in the same way as for profiles: a single # target should be possible when appropriate attribute is set.