@Magixy

Проблема с типом данных пишет unsupported operand type(s) for /: 'int' and 'str' ( Почему программа не может подсчитать сумму с процентом )?

from tkinter import *
from tkinter.ttk import Combobox
from tkinter import ttk

class LoanCalculator:
 
    def __init__(self):
 
        window = Tk()
        window.title("⭐️Gazprom Bank⭐️")
        window.configure(background = "#2F3136")
        window.geometry("460x350")
        Label(window, text = "Стоимость авто:", background = "#2F3136", fg = "#7289DA", font=('Arial Black', 8 , )).grid(row = 1,
                                          column = 1, sticky = W)
        Label(window, text = "Начальный взнос:", background = "#2F3136", fg = "#7289DA", font=('Arial Black', 8 , )).grid(row = 2,
                                      column = 1, sticky = W)
        Label(window, text = "Срок кредита:", background = "#2F3136", fg = "#7289DA", font=('Arial Black', 8 , )).grid(row = 3,
                                  column = 1, sticky = W)
        Label(window, text = "Процентная ставка:", background = "#2F3136", fg = "#7289DA", font=('Arial Black', 8 , )).grid(row = 4,
                                      column = 1, sticky = W)
       
        Label(window, text = "Дневная оплата:", background = "#2F3136", fg = "#9B84EE", font=('Arial Black', 12 , )).grid(row = 5,
                                    column = 1, sticky = W)
        Label(window, text = "Прибыль банка:", background = "#2F3136", fg = "#9B84EE", font=('Arial Black', 12 , )).grid(row = 6,
                                    column = 1, sticky = W)
        Label(window, text = "Итоговая сумма:", background = "#2F3136", fg = "#9B84EE", font=('Arial Black', 12 , )).grid(row = 7,
                                    column = 1, sticky = W)
 
        self.CarCostVar = StringVar()
        Entry(window, textvariable = self.CarCostVar,
                     justify = LEFT, background = "#36393F").grid(row = 1, column = 2, ipadx=6)
        
        DepCar = self.DepCarVar = StringVar()
        Entry(window, textvariable = self.DepCarVar,
                 justify = LEFT, background = "#36393F").grid(row = 2, column = 2, ipadx=6)
        
        DaysCar = self.DaysCarVar = StringVar()
        Entry(window, textvariable = self.DaysCarVar,
              justify = LEFT, background = "#36393F").grid(row = 3, column = 2, ipadx=6)
        

 
        self.totalPaymentVar = StringVar()
        lblTotalPayment = Label(window, textvariable =
                       self.totalPaymentVar, background = "#36393F").grid(row = 5,
                       column = 2, rowspan = 1, ipadx=59,  sticky = E)

        self.TotalPriceVar = StringVar()
        lblTotalPrice = Label(window, textvariable =
                       self.TotalPriceVar, background = "#36393F").grid(row = 6,
                       column = 2, rowspan = 1, ipadx=59, sticky = E)

        self.TotalCostVar = StringVar()
        lblTotalCost = Label(window, textvariable =
                       self.TotalCostVar, background = "#36393F").grid(row = 7,
                       column = 2, rowspan = 1, ipadx=59, sticky = E)

        Prc = self.PrcVar = StringVar()
        lblPrc = Label(window, textvariable = self.PrcVar)
        combo = Combobox(window)
        combo['values'] = ('2,3', '2%', '1,5%', '1%', '0,75%', "0,5%")  
        combo.current(0) 
        combo.grid(column=2, row=4)
        combostyle = ttk.Style()
        combostyle.theme_create('combostyle', parent='alt',
                         settings = {'TCombobox':
                                     {'configure':
                                      {"fieldbackground": "#36393F",
                                      "fg": "#36393F",
                                       'background': '#FF73FA'
                                       }}}
                        )
        combostyle.theme_use('combostyle') 
        combo['state'] = 'readonly' 

         
        btnComputePayment = Button(window, text = "Рассчитать",
                                  command = self.computePayment).grid(
                                  row = 8, column = 2, rowspan = 2, ipady=6, padx=5, pady=5, sticky = E)
        window.mainloop() 
 
 
    def computePayment(self):       
        TotalCost = self.getTotalCost(
        (self.PrcVar.get()),
        int(self.DepCarVar.get()),
        int(self.DaysCarVar.get()),
        (self.CarCostVar.get()),
        (self.PrcVar.get()))

        self.TotalCostVar.set(format(TotalCost, '10.2f'))
        TotalCost = float(self.TotalCostVar.get())
 
        self.TotalCostVar.set(format(TotalCost, '10.2f'))
 
    def getTotalCost(self, DaysCar, monthlyInterestRate, DepCar, TotalCostVar, Prc):
        TotalCost = DaysCar + DepCar * Prc
        TotalPrice = DepCar / DaysCar
        totalPayment = TotalPrice * Prc
        return TotalCost;
        root = Tk()


LoanCalculator()
  • Вопрос задан
  • 65 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
23 нояб. 2024, в 01:31
1000 руб./за проект
23 нояб. 2024, в 00:16
2000 руб./за проект
22 нояб. 2024, в 23:55
3000 руб./за проект