tkinter中text属性_Tkinter标签textvariable不变

I read 4 entry boxes and store them as 4 elements of a matrix (numpy), then when a button is clicked, a function (convert) runs and a matrix is stored in z (z is declared as global in the function (convert)). 4 labels with attribute textvariable assigned a different elemet of z for each label.

When it runs, the labels should be the calculated z but instead they're just zeros. When I type z in the command line after I close the program, it prints the correct z.

Sorry if this sounds novice, I come from a C background and I started using python recently.

def convert():

y[0,0] = float(inA.get()) #previously declared as numpy matrix

y[0,1] = float(inB.get())

y[1,0] = float(inC.get())

y[1,1] = float(inD.get())

inType = intype.get()

outType = outtype.get()

global z

z = convertParam(outType,convertParam(inType,y,0),1)

outparam11 = tkinter.Label(top,width=5,textvariable = z[0,0]) #label

解决方案

You can't use a normal variable as a textvariable. It must be an instance of one of the special tkinter variables (eg: StringVar). To cause the label to update you could then call the set method of that variable.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值