python学生类有个计算器属性_【提问】做一个计算器程序,明明有属性,可就是提示no attribute...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

————————以下粘贴出部分代码——————————

from tkinter import

#Basic Settings class

class Calculat

def __init__(self,output_string,point,delete):

#就是这儿的事

self.change_output=getattr(self,'change_output')

#明明有output属性

self.output=Label(self.tk, width=39, height=3, font=('Times', 15), anchor='center')

self.output.grid(row=0,column=0,columnspan=5

for row in range(1,4):

for column in range(0,3):

self.default_butt_set(text='%s'%self.button_number,row=row,column=column,

command=operation.change_output(str(self.button_number)))

self.button_number+=1

class Operation(Calculator):

def __init__(self,output_string,point,delete):

#从这里调用

Calculator.__init__(self,output_string,point,delete)

def change_output(self,button_number):

#这里报错

self.output=getattr(Calculator,'output')

#if the variable output_string has had a point, then I can't add another point

if button_number == '.' and self.point == False:

self.output_string += button_number

self.point = True

elif button_number != '.':

self.output_string += button_numbe

if self.delete==True:

self.operation_output.config(text='')

self.delete=False

if len(self.output_string) <= 42:

if self.output_string != '0':

#原来没有getattr的时候就是这报错

self.output.config(font=('Times', 15), text=self.output_string)

else:

self.output_string = '

#get objects

#最早的源头

operation=Operation(output_string,point,delete)

mainloop()

—————————————代码粘贴完毕——————————————

—————————————以下报错信息——————————————

Traceback (most recent call last):

File "D:/FilesOfWzm/Others/Python/计算器(class).py", line 105, in

operation=Operation(output_string,point,delete)

File "D:/FilesOfWzm/Others/Python/计算器(class).py", line 61, in __init__

Calculator.__init__(self,output_string,point,delete)

File "D:/FilesOfWzm/Others/Python/计算器(class).py", line 33, in __init__

self.default_butt_set(text='+',row=1,column=3,command=self.change_output('+'))

File "D:/FilesOfWzm/Others/Python/计算器(class).py", line 64, in change_output

self.output=getattr(Calculator,'output')

AttributeError: type object 'Calculator' has no attribute 'output'

—————————————报错信息粘贴完毕————————————

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值