AttributeError: 'function' object has no attribute 'zjxs' 这个问题怎么解决。。
本帖最后由 spiritual 于 2021-3-9 14:37 编辑import time
from tkinter import *
win = Tk()
win.title('xscfscq')
win.geometry('400x600')
#时间调用
def get():
week = {'Mon': '周一', 'Tue': '周二', 'Wed': '周三', 'Thu': '周四', 'Fri': '周五', 'Sat': '周六', 'Sun': '周日'}
day = week
return day
a = get()
#数据内容
lb_0 = Label (win,text ='销售总额:')
lb_1 = Label (win,text ='化妆销售:',bg='pink')
lb_2 = Label (win,text ='3 c 销售:')
lb_3 = Label (win,text ='小电销售:',bg='pink')
lb_4 = Label (win,text ='床品销售:')
lb_5 = Label (win,text ='超百销售:',bg='pink')
lb_6 = Label (win,text ='超市销售:')
lb_7 = Label (win,text ='一楼销售:',bg='pink')
lb_8 = Label (win,text ='二楼销售:')
lb_9 = Label (win,text ='三楼销售:',bg='pink')
lb_10 = Label (win,text ='四楼销售')
zx_1 = Variable()
hz_1 = Variable()
sm_1 = Variable()
xd_1 = Variable()
cp_1 = Variable()
cb_1 = Variable()
csxs_1 = Variable()
ylxs_1 = Variable()
elxs_1 = Variable()
slxs_1 = Variable()
ssxs_1 = Variable()
#输入数据转换
def shuju():
if (zx_1,hz_1,sm_1,cp_1,cb_1,csxs_1,ylxs_1,elxs_1,slxs_1,ssxs_1) == None or (zx_1,hz_1,sm_1,cp_1,cb_1,csxs_1,ylxs_1,elxs_1,slxs_1,ssxs_1) == 0:
(zx_1, hz_1, sm_1,xd_1, cp_1, cb_1, csxs_1, ylxs_1, elxs_1, slxs_1, ssxs_1) == 0
zx = float(zx_1.get())
hz = float(hz_1.get())
sm = float(sm_1.get())
xd = float(xd_1.get())
cp = float(cp_1.get())
cb = float(cb_1.get())
csxs = float(csxs_1.get())
ylxs = float(ylxs_1.get())
elxs = float(elxs_1.get())
slxs = float(slxs_1.get())
ssxs = float(ssxs_1.get())
return (zx,hz,sm,xd,cp,cb,csxs,ylxs,elxs,slxs,ssxs)
dqxs = shuju.sm + shuju.xd# 电器销售
cbxs = shuju.cb# 超市百货
bhxs = shuju.zx - dqxs - shuju.hz# 百货销售
zjxs = bhxs + shuju.csxs + shuju.hz + dqxs# 销售总和
cszh = dqxs + cbxs + shuju.csxs# 超市总和
#销售格式
def zhognwu():
print('''领导:购物中心%s月%s日(%s)14:00 时,销售总额:%.2f万元,其中:
1、百货销售%.2f万元;
2、超市销售%.2f万元;
3、电器销售%.2f万元;
4、化妆销售%.2f万元。'''% (int(time.strftime('%m')), time.strftime('%d'),a,shuju.zjxs, shuju.bhxs, shuju.csxs, shuju.dqxs, shuju.hz))
def xiawu():
print('''领导:购物中心%s月%s日(%s)18:00 时,销售总额:%.2f万元,其中:
1、百货销售%.2f万元;
2、超市销售%.2f万元;
3、电器销售%.2f万元;
4、化妆销售%.2f万元。''' % (
int(time.strftime('%m')), time.strftime('%d'), a, shuju.zjxs, shuju.bhxs, shuju.csxs, shuju.dqxs, shuju.hz))
def bidian():
print('''领导:购物中心%s月%s号(%s),21:30时,闭店销售总额:%.2f万元,其中:
1、百货销售%.2f万元;
2、超市销售%.2f万元;
3、电器销售%.2f万元;
4、化妆销售%.2f万元。
各楼层销售情况如下:
(一楼销售:%.2f万元
二楼销售:%.2f万元
三楼销售:%.2f万元
四楼销售:%.2f万元
负一楼销售:%.2f万元
其中:
超市销售:%.2f万元
电器销售:%.2f万元
百货销售:%.2f万元''' % (
int(time.strftime('%m')), time.strftime('%d'), a, shuju.zjxs, shuju.bhxs, shuju.csxs, shuju.dqxs, shuju.hz, shuju.ylxs, shuju.elxs, shuju.slxs, shuju.ssxs, shuju.cszh, shuju.csxs,
shuju.dqxs, shuju.cbxs))
#输入内容
ent_0 =Entry(win,highlightcolor = 'red',highlightthickness = 2,textvariable=zx_1)
ent_1 =Entry(win,bg='pink',highlightcolor = 'red',highlightthickness = 2,textvariable=hz_1)
ent_2 =Entry(win,highlightcolor = 'red',highlightthickness = 2,textvariable=sm_1)
ent_3 =Entry(win,bg='pink',highlightcolor = 'red',highlightthickness = 2,textvariable=xd_1)
ent_4 =Entry(win,highlightcolor = 'red',highlightthickness = 2,textvariable=cp_1)
ent_5 =Entry(win,bg='pink',highlightcolor = 'red',highlightthickness = 2,textvariable=cb_1)
ent_6 =Entry(win,highlightcolor = 'red',highlightthickness = 2,textvariable=csxs_1)
ent_7 =Entry(win,bg='pink',highlightcolor = 'red',highlightthickness = 2,textvariable=ylxs_1)
ent_8 =Entry(win,highlightcolor = 'red',highlightthickness = 2,textvariable=elxs_1)
ent_9 =Entry(win,bg='pink',highlightcolor = 'red',highlightthickness = 2,textvariable=slxs_1)
ent_10 =Entry(win,highlightcolor = 'red',highlightthickness = 2,textvariable=ssxs_1)
#按键内容
rbt = IntVar()
rbt.set(1)
but_1 = Radiobutton(win,text = '中午',font = (10),variable=rbt,value=1)
but_2 = Radiobutton(win,text = '下午',font = (10),variable=rbt,value=2)
but_3 = Radiobutton(win,text = '闭店',font = (10),variable=rbt,value=3)
but_0 = Button(win,text='生成内容')
if rbt == 1:
but_0 = Button(win, text='生成内容', command=zhognwu())
elif rbt ==2:
but_0 = Button(win, text='生成内容', command=xiawu())
elif rbt == 3:
but_0 = Button(win, text='生成内容', command=bidian())
#输出内容展示
text = Text(win)
text.insert(INSERT,zhognwu())
text.insert(END)
#表格内容安装
lb_0.grid(row=0,column=0)
lb_1.grid(row=1,column=0)
lb_2.grid(row=2,column=0)
lb_3.grid(row=3,column=0)
lb_4.grid(row=4,column=0)
lb_5.grid(row=5,column=0)
lb_6.grid(row=6,column=0)
lb_7.grid(row=7,column=0)
lb_8.grid(row=8,column=0)
lb_9.grid(row=9,column=0)
lb_10.grid(row=10,column=0)
#输入内容安转
ent_0.grid(row=0,column=1)
ent_1.grid(row=1,column=1)
ent_2.grid(row=2,column=1)
ent_3.grid(row=3,column=1)
ent_4.grid(row=4,column=1)
ent_5.grid(row=5,column=1)
ent_6.grid(row=6,column=1)
ent_7.grid(row=7,column=1)
ent_8.grid(row=8,column=1)
ent_9.grid(row=9,column=1)
ent_10.grid(row=10,column=1)
#按键安装
but_0.grid(row=12,column=1)
but_1.grid(row = 11,column=0)
but_2.grid(row = 11,column=1)
but_3.grid(row = 11,column=2)
#输出内容安装
text.grid(row = 13,column = 1)
win.mainloop() 你这把函数shuju当类用肯定不行啊,函数内的写法也有很多问题 hrp 发表于 2021-3-9 14:59
你这把函数shuju当类用肯定不行啊,函数内的写法也有很多问题
能帮我纠正一下么
页:
[1]