def on_draw(self, _, cairo_ctx, __, height):
"""Create Pango Layout from ._text, rotate and re-size."""
- layout = self.create_pango_layout(self._text)
+ layout = self.create_pango_layout()
+ layout.set_markup(self._text)
text_width, text_height = layout.get_pixel_size()
cairo_ctx.translate(0, text_width + (height - text_width))
cairo_ctx.rotate(radians(-90))
self._on_hit_item()
return f
- def build_rows_by_attrs(remaining_attrs,
- items_of_parent_attr_value,
- parent_attrs_values):
- if not items_of_parent_attr_value:
+ def build_rows_by_attrs(remaining, items_of_parent, ancestors):
+ if not items_of_parent:
return
- attr_name, attr_values = remaining_attrs[0]
- if 1 == len(remaining_attrs):
- v_offset = len(parent_attrs_values)
- for i, val in enumerate(parent_attrs_values):
- self._grid.attach(VerticalLabel(str(val)),
- i, i_row_ref[0], 1, 1)
+ attr_name, attr_values = remaining[0]
+ if 1 == len(remaining):
+ for i, attr in enumerate(ancestors):
+ vlabel = VerticalLabel(f'<b>{attr[0]}</b>: {attr[1]}')
+ self._grid.attach(vlabel, i, i_row_ref[0], 1, 1)
row = [None] * len(attr_values)
- for item in items_of_parent_attr_value:
+ for item in items_of_parent:
val = getattr(item, attr_name)
idx_val_in_attr_values = attr_values.index(val)
if row[idx_val_in_attr_values]:
slot = GallerySlot(GalleryItem('', '')) # dummy
self.slots += [slot]
i_slot_ref[0] += 1
- self._grid.attach(slot, i_col + v_offset,
+ self._grid.attach(slot, i_col + len(ancestors),
i_row_ref[0], 1, 1)
i_row_ref[0] += 1
return
for attr_value in attr_values:
- items_of_attr_value = [
- x for x in items_of_parent_attr_value
- if attr_value == getattr(x, attr_name)]
- build_rows_by_attrs(remaining_attrs[1:],
- items_of_attr_value,
- parent_attrs_values + [attr_value])
+ items_of_attr_value = [x for x in items_of_parent
+ if attr_value == getattr(x,
+ attr_name)]
+ build_rows_by_attrs(remaining[1:], items_of_attr_value,
+ ancestors + [(attr_name, attr_value)])
if self._grid:
self._fixed_frame.remove(self._grid)