tkinter 个人所得税
时间: 2023-12-03 18:40:25 浏览: 29
以下是一个使用tkinter搭建的个人所得税计算器的Python代码,你可以通过运行该代码来计算个人所得税:
```python
import tkinter as tk
def calc():
income = float(income_entry.get())
insurance = float(insurance_entry.get())
deduction = float(deduction_entry.get())
taxable_income = income - insurance - deduction - 5000
if taxable_income <= 0:
tax = 0
elif taxable_income <= 3000:
tax = taxable_income * 0.03
elif taxable_income <= 12000:
tax = taxable_income * 0.1 - 210
elif taxable_income <= 25000:
tax = taxable_income * 0.2 - 1410
elif taxable_income <= 35000:
tax = taxable_income * 0.25 - 2660
elif taxable_income <= 55000:
tax = taxable_income * 0.3 - 4410
elif taxable_income <= 80000:
tax = taxable_income * 0.35 - 7160
else:
tax = taxable_income * 0.45 - 15160
result_label.config(text='个人所得税:{:.2f} 元'.format(tax))
root = tk.Tk()
root.title('个人所得税计算器')
income_label = tk.Label(root, text='税前收入:')
income_label.grid(row=0, column=0)
income_entry = tk.Entry(root)
income_entry.grid(row=0, column=1)
insurance_label = tk.Label(root, text='五险一金:')
insurance_label.grid(row=1, column=0)
insurance_entry = tk.Entry(root)
insurance_entry.grid(row=1, column=1)
deduction_label = tk.Label(root, text='专项扣除:')
deduction_label.grid(row=2, column=0)
deduction_entry = tk.Entry(root)
deduction_entry.grid(row=2, column=1)
calc_button = tk.Button(root, text='计算', command=calc)
calc_button.grid(row=3, column=0)
result_label = tk.Label(root, text='')
result_label.grid(row=3, column=1)
root.mainloop()
```
该计算器需要输入税前收入、五险一金和专项扣除三个参数,然后根据个人所得税的计算公式计算出个人所得税。计算结果会显示在窗口中。