сделай расположение полей ввода информации о кредиторах более логичным и красивым
import tkinter as tk
from tkinter import ttk
from ttkthemes import ThemedTk


def calculate():
cash = float(cash_entry.get())

division = {}
debt = sum(float(cred[‘value’].get()) for cred in creditors)

for creditor in creditors:
name = creditor[‘name’].get()
value = float(creditor[‘value’].get())
is_percent = creditor[‘is_percent’].get()
percent_or_fee = float(creditor[‘percent_or_fee’].get())

ratio = value / debt * 100

if is_percent:
division[name] = (cash / 100 * ratio) / (1 + percent_or_fee / 100)
else:
division[name] = (cash / 100 * ratio) - percent_or_fee

update_results(division)


def update_results(division):
result_frame.grid(column=1, row=4, sticky=‘w’, padx=5, pady=5)
for label in result_frame.grid_slaves():
label.destroy()

for idx, (name, value) in enumerate(division.items()):
ttk.Label(result_frame, text=name).grid(column=0, row=idx, padx=5, pady=5)
ttk.Label(result_frame, text=f’%.2f’ % value).grid(column=1, row=idx, padx=5, pady=5)


def add_creditor():
cred_frame = ttk.Frame(creditors_frame, relief=‘groove’, borderwidth=2)
cred_frame.grid(column=0, row=len(creditors), sticky=‘ew’, padx=5, pady=5)

name = tk.StringVar()
value = tk.StringVar()
is_percent = tk.BooleanVar()
percent_or_fee = tk.StringVar()

ttk.Label(cred_frame, text=“Название кредитора:”).grid(column=0, row=0, sticky=‘w’, padx=5, pady=5)
ttk.Entry(cred_frame, textvariable=name).grid(column=1, row=0, sticky=‘ew’, padx=5)

ttk.Label(cred_frame, text=“Сумма долга:”).grid(column=0, row=1, sticky=‘w’, padx=5, pady=5)
ttk.Entry(cred_frame, textvariable=value).grid(column=1, row=1, sticky=‘ew’, padx=5)

check = ttk.Checkbutton(cred_frame, text=“Является ли комиссия процентами?”, variable=is_percent)
check.grid(column=0, row=2, sticky=‘w’, columnspan=2, padx=5)

ttk.Label(cred_frame, text=“Комиссия проценты/сумма:”).grid(column=0, row=3, sticky=‘w’, padx=5, pady=5)
ttk.Entry(cred_frame, textvariable=percent_or_fee).grid(column=1, row=3, sticky=‘ew’, padx=5)

delete_button = ttk.Button(cred_frame, text=“Удалить”, command=lambda: delete_creditor(cred_frame))
delete_button.grid(column=0, row=4, columnspan=2, padx=5, pady=5)

creditors.append({
‘frame’: cred_frame,
‘name’: name,
‘value’: value,
‘is_percent’: is_percent,
‘percent_or_fee’: percent_or_fee
})


def delete_creditor(frame):
for creditor in creditors:
if creditor[‘frame’] == frame:
creditor[‘frame’].destroy()
creditors.remove(creditor)
break


def clear_all():
cash_entry.delete(0, tk.END)
for creditor in creditors:
creditor[‘frame’].destroy()
creditors.clear()
result_frame.grid_forget()


root = ThemedTk(theme=“arc”)
root.title(“Распределение денежных средств”)

cash_label = ttk.Label(root, text=“Введите количество денег у должника:”)
cash_entry = ttk.Entry(root)
cash_label.grid(column=0, row=0, sticky=‘w’, padx=5, pady=5)
cash_entry.grid(column=1, row=0, sticky=‘ew’, padx=5, pady=5)

creditors_frame = ttk.Frame(root)
creditors_frame.grid(column=0, row=1, columnspan=2, padx=5, pady=5)
creditors = []

add_button = ttk.Button(root, text=“Добавить кредитора”, command=add_creditor)
add_button.grid(column=0, row=2, columnspan=2, padx=5, pady=5)

calculate_button = ttk.Button(root, text=“Рассчитать”, command=calculate)
calculate_button.grid(column=0, row=3, columnspan=2, padx=5, pady=5)

result_label = ttk.Label(root, text=“Результаты:”)
result_label.grid(column=0, row=4, sticky=‘w’, padx=5, pady=5)
result_frame = ttk.Frame(root)

clear_button = ttk.Button(root, text=“Очистить все”, command=clear_all)
clear_button.grid(column=0, row=5, columnspan=2, padx=5, pady=5)

root.columnconfigure(1, weight=1, minsize=150)
root.rowconfigure(4, weight=1, minsize=150)

root.mainloop()