鱼C论坛

 找回密码
 立即注册
查看: 2205|回复: 2

AttributeError: 'function' object has no attribute 'zjxs' 这个问题怎么解决。。

[复制链接]
发表于 2021-3-9 14:22:46 | 显示全部楼层 |阅读模式
5鱼币
本帖最后由 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[time.strftime('%a')]
    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()

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-3-9 14:59:48 From FishC Mobile | 显示全部楼层
你这把函数shuju当类用肯定不行啊,函数内的写法也有很多问题
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-3-9 15:12:58 | 显示全部楼层
hrp 发表于 2021-3-9 14:59
你这把函数shuju当类用肯定不行啊,函数内的写法也有很多问题

能帮我纠正一下么
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-1-16 08:51

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表