|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
自己用easygui写的程序,到最后步可以调用self.weight self.heigt self.depth这三个参数并返回,self.door_header_height和self.door_header_weight这两个函数,无论如何都调用不了 显示类型错误,str和int和list都显示错误,有没有大佬来解答下
源码如下
import easygui as f
class Login_data:
def __init__(self):
#登录窗口的数据,包括帐号和密码
self.account_num = '123'
self.password = '123'
self.msg = '请输入正确的帐号和密码'
self.title = '帐号中心'
self.list_enterbox = ['用户名','密码']
#登录信息的判定函数
def getlogin(self,x,y):
if x == self.account_num and y == self.password:
return False
elif x == ''or y == '':
return True
else:
return True
class Choice_box:
def __init__(self):
self.msg = '请选择下一步'
self.title = '选择中心'
self.choices = ['提供门洞尺寸,计算房门尺寸','提供柜体尺寸,报价整个柜体']
class Doorway:
def __init__(self):
self.msg = '高度,宽度,深度为必填项!'
self.title = '门洞数据'
self.list_doorway = ['门洞高度','门洞宽度','门洞深度','套线宽度','外到顶','内到顶','门洞左侧离墙距离','门洞右侧离墙距离']
def getdoor(self,x):
#计算房门的宽度
if x[6] == '' and x[7] == '':
self.weight = int(x[1]) - 55
if x[6] != '' and x[7] =='':
if int(x[3])-10 < int(x[6]):
self.weight = int(x[1]) - 55
elif int(x[3])-10 == int(x[6]):
self.weight = int(x[1]) - 55
else:
self.weight = int(x[1]) - 55 - (int(x[3])-10-int(x[6]))
if x[6] == '' and x[7] !='':
if int(x[3])-10 < int(x[7]):
self.weight = int(x[1]) - 55
elif int(x[3])-10 == int(x[7]):
self.weight = int(x[1]) - 55
else:
self.weight = int(x[1]) - 55 - (int(x[3])-10-int(x[7]))
#计算房门的高度
if x[4] =='' and x[5] =='':
self.height = int(x[0]) - 45
self.door_header_height = 0
self.door_header_weight = 0
if x[4] !='' and x[5] =='':
if int(x[4])-int(x[0]) <= int(x[3])-15:
self.height = int(x[4])-10-(int(x[3])+8)
self.door_header_height = 0
self.door_header_weight = 0
else:
self.height = int(x[0]) - 45
self.door_header_height = int(x[4])-int(x[0])-45
self.door_header_weight = int(self.weight) + 30
if x[5] !='' and x[4] =='':
if int(x[5])-int(x[0]) <= x[3]-15:
self.height = int(x[5])-10-(int(x[3])+8)
self.door_header_height = 0
self.door_header_weight = 0
else:
self.height = int(x[0]) - 45
self.door_header_height = int(x[5])-int(x[0])-45
self.door_header_weight = int(self.weight) + 30
#计算房门的深度
self.depth = int(x[2])-5
return[self.height,self.weight,self.depth]
login = Login_data()
login_message = []
login_return = 1
n = 0
while login_return:
login_message = f.multenterbox(login.msg,login.title,fields = login.list_enterbox,values = login_message )
login_return = login.getlogin(login_message[0],login_message[1])
choice = Choice_box()
choice_message = f.choicebox(choice.msg,choice.title,choices = choice.choices)
if choice_message == choice.choices[0]:
doorway = Doorway()
doorwaymessage = f.multenterbox(doorway.msg,doorway.title,fields = doorway.list_doorway)
doormessage = doorway.getdoor(doorwaymessage)
print(doormessage)
print(doorway.door_header_height())
if choice_message == choice.choices[1]:
pass
你的代码中完全没有定义 door_header_height 和 door_header_weight 这两个函数
而是对 door_header_height 和 door_header_weight 两个变量 进行了赋值,为确切的数值,肯定无法调用的
举个例子你想想,如果 a = 1 ,此时 a 为 int 整型数据,然后你却想调用这个数据即: a() ,相当于 1() ,肯定会导致报错
|
|