试着选择颜色然后打印它,打印位的工作只需要让颜色部分工作。如果你需要看到更多的代码,只要问。在
def mColour():
color = colorchooser.askcolor()
color_name = color[1]
mlabel2 = Label(mGui,text=color).pack()
messagebox.showinfo(title = "Colour",message = "This feature has not been fully added yet.")
return
def mhello():
mtext = ment.get()
fg=color_name
mlabel2 = Label(mGui,text=mtext).pack()
return
错误:
^{pr2}$
在你的帮助下我找到了解决办法。在
据我所知,您正试图访问在
mColour
的局部范围内创建的变量(这意味着它不在mhello
的范围内)。您可以通过使mColour
返回color_name
来解决此问题:然后访问
^{pr2}$mhello
中的值,如下所示:另外,我想谈两件事:
1)函数末尾的空
return
不起任何作用。在2)
pack
方法返回None
。您的代码应该如下所示:现在
mlabel2
指向标签。在相关问题 更多 >
编程相关推荐