diff --git a/src/ccma/ui/member_tab.py b/src/ccma/ui/member_tab.py index 12321b7..2eed828 100644 --- a/src/ccma/ui/member_tab.py +++ b/src/ccma/ui/member_tab.py @@ -37,11 +37,18 @@ from ccma.ui.messages import MessageAction, MessageBannerList, TabMessage from ccma.ui.payment_dialog import PaymentCreateDialog, PaymentEditDialog from ccma.ui.scrolling import ScrollableFrame +# Shared column sizing for the ledger-style tables (Forderungen/Zahlungen/Spenden): date- +# and amount-like columns get the same fixed width, status columns get a third more +# (they tend to hold longer label text), and only the trailing description/reference +# column stretches to take up whatever space remains. +FIXED_COLUMN_WIDTH = 90 +STATUS_COLUMN_WIDTH = round(FIXED_COLUMN_WIDTH * 4 / 3) + CLAIM_TABLE_COLUMNS = ( + ("due", "Fällig", FIXED_COLUMN_WIDTH), + ("amount", "Betrag", FIXED_COLUMN_WIDTH), + ("status", "Status", STATUS_COLUMN_WIDTH), ("title", "Forderung", 220), - ("due", "Fällig", 100), - ("amount", "Betrag", 90), - ("status", "Status", 110), ) @@ -127,7 +134,7 @@ class MemberTab(ttk.Frame): self.details_pane = ttk.Frame(self.pane, padding=(0, 0, 10, 0)) self.timeline_pane = ttk.Frame(self.pane, padding=(10, 0, 0, 0)) self.pane.add(self.details_pane, weight=2) - self.pane.add(self.timeline_pane, weight=3) + self.pane.add(self.timeline_pane, weight=1) self._build_details(self.details_pane) self._build_timeline(self.timeline_pane) self._pane_position_initialized = False @@ -139,7 +146,8 @@ class MemberTab(ttk.Frame): try: width = int(getattr(event, "width", 0)) or self.pane.winfo_width() if width > 1: - self.pane.sashpos(0, max(360, int(width * 0.4))) + # Chronik (timeline_pane) defaults to a third of the available width. + self.pane.sashpos(0, max(360, round(width * 2 / 3))) self._pane_position_initialized = True except tk.TclError: return @@ -283,13 +291,13 @@ class MemberTab(ttk.Frame): row=0, column=0, sticky="w", pady=(0, 10) ) self.claims = ttk.Treeview( - contribution_tab, columns=("title", "due", "amount", "status"), show="headings" + contribution_tab, columns=("due", "amount", "status", "title"), show="headings" ) self.claim_sort_column = "due" self.claim_sort_descending = False for key, title, width in CLAIM_TABLE_COLUMNS: self.claims.heading(key, text=title, command=lambda column=key: self._toggle_claim_sort(column)) - self.claims.column(key, width=width, anchor="w") + self.claims.column(key, width=width, anchor="w", stretch=key == "title") self.claims.grid(row=1, column=0, sticky="nsew") self.claims.bind("", lambda _event: self._open_selected_claim()) self.claims.bind("", lambda _event: self._open_selected_claim()) @@ -307,14 +315,14 @@ class MemberTab(ttk.Frame): selectmode="browse", ) for key, title, width in ( - ("date", "Datum", 100), - ("amount", "Betrag", 90), - ("allocated", "Zugeordnet", 90), - ("available", "Frei", 90), + ("date", "Datum", FIXED_COLUMN_WIDTH), + ("amount", "Betrag", FIXED_COLUMN_WIDTH), + ("allocated", "Zugeordnet", FIXED_COLUMN_WIDTH), + ("available", "Frei", FIXED_COLUMN_WIDTH), ("reference", "Referenz", 320), ): self.payments.heading(key, text=title) - self.payments.column(key, width=width, anchor="w") + self.payments.column(key, width=width, anchor="w", stretch=key == "reference") self.payments.grid(row=1, column=0, sticky="nsew") self.payments.bind("", lambda _event: self._edit_selected_payment()) self.payments.bind("", lambda _event: self._edit_selected_payment()) @@ -347,15 +355,15 @@ class MemberTab(ttk.Frame): selectmode="browse", ) for key, title, width in ( - ("date", "Datum", 100), - ("amount", "Betrag", 90), - ("allocated", "Zugeordnet", 90), - ("balance", "Offen", 90), - ("status", "Status", 150), + ("date", "Datum", FIXED_COLUMN_WIDTH), + ("amount", "Betrag", FIXED_COLUMN_WIDTH), + ("allocated", "Zugeordnet", FIXED_COLUMN_WIDTH), + ("balance", "Offen", FIXED_COLUMN_WIDTH), + ("status", "Status", STATUS_COLUMN_WIDTH), ("reference", "Referenz / Zweck", 260), ): self.donations.heading(key, text=title) - self.donations.column(key, width=width, anchor="w") + self.donations.column(key, width=width, anchor="w", stretch=key == "reference") self.donations.grid(row=1, column=0, sticky="nsew") self.donations.bind("", lambda _event: self._edit_selected_donation()) self.donations.bind("", lambda _event: self._edit_selected_donation()) @@ -602,10 +610,10 @@ class MemberTab(ttk.Frame): "end", iid=claim_id, values=( - claim.get("title", "Beitrag"), format_date_for_display(str(claim.get("due_date", ""))), money_text(claim_total(claim)), CLAIM_STATUS_LABELS.get(status, status.upper()), + claim.get("title", "Beitrag"), ), ) for payment in sorted(