-1
我試圖在tkinter的這個消息框中包含「mye」變量,但它不工作,我不斷得到TypeError:不支持的操作數類型爲+:'type'和'NoneType'。有人可以幫我嗎?在tkMessageBox.showinfo中包含一個變量?
from tkinter import*
from tkinter import messagebox as tkMessageBox
mgui=Tk()
def confirm():
tkMessageBox.showinfo("Info","A confirmation has been sent to" + str(mye))
email=StringVar()
e=str(email.get())
label4=Label(mgui,text="Please enter your email address", fg="black").grid(row=0,column=1,sticky=W)
button3=Button(mgui,text="Confirm",command=confirm).grid(row=1,column=1)
mye=Entry(mgui,textvariable=email).grid(row=6,column=1)
mgui.mainloop()
如果你改成:'(「Info」,「確認已發送到」+ str(mye))'它工作嗎? –
錯誤沒有出現,但顯示的是框中顯示的變量「None」而不是變量。 – vigilantis
這將表明您的變量的值實際上沒有值。作爲一個測試,在確認函數的第一行如「hello world」中指定一些字符串值,並查看該值是否顯示。如果是這樣,你的變量沒有被正確分配 –