莫愁前路无知己,天下谁人不识君。。。。

python小编程------交互界面计算工资(五险一金不按比例缴纳)

上一篇 / 下一篇  2017-12-13 16:17:14 / 个人分类:python 小编程

# coding:utf-8
from Tkinter import *
root = Tk()
Label(root, text='应发总工资 :').grid(row=0, column=0)   # 对Label内容进行表格式布局
Label(root, text='五种保险费 :').grid(row=1, column=0)
Label(root, text='住房公积金 :').grid(row=2, column=0)
Label(root, text='个税起征点 :').grid(row=3, column=0)
Label(root, text='你拥有财富 :').grid(row=4, column=0)
v1 = StringVar()  # 设置变量 .
v2 = StringVar()
v3 = StringVar()
v4 = StringVar()
v5 = StringVar()
e1 = Entry(root, textvariable=v1, show='$') # 用于储存 输入的内容
e2 = Entry(root, textvariable=v2)
e3 = Entry(root, textvariable=v3)
e4 = Entry(root, textvariable=v4)
e5 = Entry(root, textvariable=v5)
e1.grid(row=0, column=1, padx=10, pady=5) # 进行表格式布局 .
e2.grid(row=1, column=1, padx=10, pady=5)
e3.grid(row=2, column=1, padx=10, pady=5)
e4.grid(row=3, column=1, padx=10, pady=5)
e5.grid(row=4, column=1, padx=10, pady=5)
def calculator():
    salary = int(e1.get())
    five_money = int(e2.get())
    one_base = int(e3.get())
    point = int(e4.get())
    five_one_money = five_money + one_base
    rest_money = salary - five_one_money - point
    res_money = salary - five_one_money
    if rest_money <= 1500:
        res_money -= rest_money * 0.03
        v5.set(res_money)
    elif 1500 < rest_money <= 4500:
        tax_money = rest_money * 0.1
        res_money -= tax_money - 105
        v5.set(res_money)
    elif 4500 < rest_money <= 9000:
        tax_money = rest_money * 0.2
        res_money -= tax_money - 555
        v5.set(res_money)
    elif 9000 < rest_money <= 35000:
        tax_money = rest_money * 0.25
        res_money -= tax_money - 1005
        v5.set(res_money)
    elif 35000 < rest_money <= 55000:
        tax_money = rest_money * 0.3
        res_money -= tax_money - 2755
        v5.set(res_money)
    elif 55000 < rest_money <= 80000:
        tax_money = rest_money * 0.35
        res_money -= tax_money - 5505
        v5.set(res_money)
    else:
        tax_money = rest_money * 0.45
        res_money -= tax_money - 13505
        v5.set(res_money)
    print u'税前工资为:{0},税后工资为:{1}'.format(salary, res_money)
Button(root, text='点击得财宝', width=10, command=calculator).grid(row=5, column=0, sticky=W, padx=10, pady=5)
Button(root, text='可以退出来', width=10, command=root.quit).grid(row=5, column=1, sticky=E, padx=10, pady=5)
mainloop()
注:Label(root, fg='blue', bg='green', text='你拥有财富 :').grid(row=4, column=0)可以加上颜色
也可以加上图片:格式一定是gif格式
photo = PhotoImage(file='e:\\123.gif')
label = Label(image=photo)
label.image = photo
label.grid(row=0, column=2, columnspan=2, rowspan=4, sticky=W+E+N+S, padx=10, pady=10)
Button(root, text='点击得财宝', width=10, command=calculator).grid(row=4, column=2, sticky=W, padx=10, pady=5)
Button(root, text='可以藏起来', width=10, command=root.quit).grid(row=4, column=3, sticky=E, padx=10, pady=5)

TAG: Python python

 

评分:0

我来说两句

Open Toolbar