我试图从各个线圈养活我的进度条国际价值,但我不断收到它说,我不输入int类型的错误:蟒蛇:进度条不接受INT
TypeError: 'int' object does not support item assignment
我“米做的是:
- 获取阵列
- 划分长度与阵列长度的进度条的总长度(以获得阵列中值/每个项目百分比)
- 每个环路中的值从第二步就丢(INT)获得并添加到总价值VAR
- 总价值VAR铸造(INT)并将其分配给我的进度条
位和代码段目前看像这样:
(in main loop)
....
self.progress = Progressbar(self, orient=HORIZONTAL,length=100, mode='determinate')
global that
that = self
def progress_bar(self, progress):
progress["value"]=int(progress)
....
(in another worker thread)
....
item_count = 0
item_percent = 100/len(my_arr)
for x in my_arr:
item_count += 1
pb_percent = item_count * item_percent
pb_formatted = int(pb_formatted)
Application.progress_bar(that, int(pb_formatted))
一切似乎对我来说,但我不断收到此错误。当我打印pb_formatted
var时,我可以看到它是我需要的进度条,而且我还运行了一些if-else
代码块来检查我试图输入的内容是否确实是int
。
可能是什么问题?
哪一行发生错误? – amrit