From: Christian Heller Date: Wed, 13 Nov 2024 02:30:42 +0000 (+0100) Subject: Browser: Simplify and improve prompt reduction in by_1st view. X-Git-Url: https://plomlompom.com/repos/do_day?a=commitdiff_plain;h=f3722f10e9bf760b43539f3176cdb14c083d3f11;p=stable_plom Browser: Simplify and improve prompt reduction in by_1st view. --- diff --git a/browser.py b/browser.py index 1e6fc42..81ec887 100755 --- a/browser.py +++ b/browser.py @@ -25,8 +25,7 @@ from stable.gen_params import (GenParams, GEN_PARAMS_FLOAT, # noqa: E402 GEN_PARAMS_INT, GEN_PARAMS_STR, # noqa: E402 GEN_PARAMS) # noqa: E402 -PromptDiff = tuple[str, str, str] -PromptsDiff = dict[str, PromptDiff] +PromptsDiff = dict[str, str] BasicItemsAttrs = dict[str, set[str]] AttrVals: TypeAlias = list[str] AttrValsByVisibility: TypeAlias = dict[str, AttrVals] @@ -856,7 +855,9 @@ class Gallery: for i, p in enumerate(cores): cores[i] = p[:-len(suffix)] for i, p in enumerate(prompts): - prompts_diff[p] = (cores[i], '', '') + pre_ell = '…' if prefix else '' + post_ell = '…' if suffix else '' + prompts_diff[p] = f'{pre_ell}{cores[i]}{post_ell}' return prompts_diff basic_items_attrs = {} @@ -1030,8 +1031,8 @@ class Gallery: for i, attr in enumerate(ancestors): parent_attr_name, parent_attr_value = attr if 'prompt' == parent_attr_name: - prompt_diff = self._prompts_diff[parent_attr_value] - parent_attr_value = f'…{prompt_diff[0]}…' + parent_attr_value = self\ + ._prompts_diff[parent_attr_value] txt = f'{parent_attr_name}: {parent_attr_value}' vlabel = VerticalLabel(txt, self._slots_geometry) self._grid.attach(vlabel, i, i_row_ref[0], 1, 1) @@ -1077,7 +1078,7 @@ class Gallery: top_attr_name: str = sort_attrs[-1][0] for i, val in enumerate(sort_attrs[-1][1]): if 'prompt' == top_attr_name: - val = f'…{self._prompts_diff[val][0]}…' + val = self._prompts_diff[val] label = Gtk.Label(label=f'{top_attr_name}: {val}', xalign=0, ellipsize=Pango.EllipsizeMode.MIDDLE)