diff --git a/dokogen/ui.py b/dokogen/ui.py index 6996260..7771309 100644 --- a/dokogen/ui.py +++ b/dokogen/ui.py @@ -2439,23 +2439,15 @@ class DokoGenApp: if target: var.set(target) prefix = f"Показатель {num}. {name} — {cat} категория." - full = prefix + "\n" + txt cur = justify_txt.get('1.0', 'end-1c').strip() if prefix not in cur: - if cur: - justify_txt.insert('end', '\n' + full) - else: - justify_txt.insert('1.0', full) + _append_justify(prefix, txt) else: var.set('—') prefix = f"Показатель {num}. {name} — применим, категория не присвоена (—)." - full = prefix + "\n" + txt cur = justify_txt.get('1.0', 'end-1c').strip() if prefix not in cur: - if cur: - justify_txt.insert('end', '\n' + full) - else: - justify_txt.insert('1.0', full) + _append_justify(prefix, txt) w.grab_release() w.destroy() @@ -2526,13 +2518,9 @@ class DokoGenApp: txt = _just_text(_num) prefix = f"Показатель {_num}. {_name} — не применим." if txt: - full = prefix + " " + txt cur = justify_txt.get('1.0', 'end-1c').strip() if prefix not in cur: - if cur: - justify_txt.insert('end', '\n' + full) - else: - justify_txt.insert('1.0', full) + _append_justify(prefix, txt) combo.bind('<>', _on_pick) if not applicable_here: @@ -2562,6 +2550,21 @@ class DokoGenApp: anchor=tk.W, pady=(10, 2)) justify_txt = tk.Text(body, width=110, height=5, wrap=tk.WORD) justify_txt.pack(fill=tk.X, pady=(0, 6)) + # Висячий отступ: заголовок «Показатель N. …» — первая строка без отступа, + # перенесённые строки — с отступом (чтобы продолжение не выглядело новым пунктом); + # тело расчёта — с отступом слева; между показателями — пустая строка. + justify_txt.tag_configure('just_head', lmargin1=0, lmargin2=30, spacing1=6, spacing3=2) + justify_txt.tag_configure('just_body', lmargin1=30, lmargin2=30, spacing3=4) + + def _append_justify(prefix, body): + """Добавить запись в обоснование: заголовок с висячим отступом + тело.""" + cur = justify_txt.get('1.0', 'end-1c').strip() + if cur: + justify_txt.insert('end', '\n\n') + justify_txt.insert('end', str(prefix), 'just_head') + if body: + justify_txt.insert('end', '\n' + str(body), 'just_body') + if hasattr(self, 'is_criteria_justification_listbox') and self.is_criteria_justification_listbox.size(): justify_txt.insert('1.0', '\n'.join( self.is_criteria_justification_listbox.get(i) @@ -2719,13 +2722,9 @@ class DokoGenApp: 'указанных в п. 8 перечня показателей критериев ' 'значимости объектов КИИ.') prefix = f"Показатель {num}. {name} — не применим." - full = prefix + " " + txt cur = justify_txt.get('1.0', 'end-1c').strip() if prefix not in cur: - if cur: - justify_txt.insert('end', '\n' + full) - else: - justify_txt.insert('1.0', full) + _append_justify(prefix, txt) filled.append(f"п. {num}: не применим (тип организации)") elif g == '9': profit = _num2(getattr(self.model, 'profit', '') or '') @@ -2785,13 +2784,9 @@ class DokoGenApp: f"Категория значимости: {cat or '— (не присваивается)'}" ) prefix = f"Показатель {num}. {name} — рекомендация по расчёту:" - full = prefix + "\n" + calc_txt cur = justify_txt.get('1.0', 'end-1c').strip() if prefix not in cur: - if cur: - justify_txt.insert('end', '\n' + full) - else: - justify_txt.insert('1.0', full) + _append_justify(prefix, calc_txt) filled.append(f"п. {num}: №9 = {val:.6f}% → {cat or '—'}") # Что осталось незаполненным (применимые, без значения) left = []