1
我正在爲使用Python的當前項目創建一個新的應用程序。這是我第一次使用它,它一直是一種學習體驗......Python - Tkinter - GUI
我的應用程序中有一個按鈕,它調用Python中的askcolor()
函數。一切工作正常,但在此之後,它給了我以下錯誤。
AttributeError: 'str' object has no attribute 'set'
這是我在我的應用程序有工作順序:
上
Select Color
按鈕,用戶點擊:self.bc_bttn=Button(self, text='Select Color', command=lambda: self.callback())
的函數調用
callback
功能和我選擇合適的顏色def callback(self): (triple, hexstr) = askcolor() if triple: triple_string = str(triple) triple_string2 = re.findall('[0-9, ]',triple_string); triple_bkgColor = ''.join(triple_string2) print triple_bkgColor self.overlayColorValue.set(triple_bkgColor)
self.overlayColorValue.set(triple_bkgColor)
更改文本字段項的值,因此用戶將看到應用程序的正確值我按下
Save
按鈕self.overlayColorValue = self.bc_ent.get() body.set('overlay-color', self.overlayColorValue)
我的更改寫入到XML文件
tree.write(CONFIG_XML)
這一次一切正常,但如果我想再次做同樣的事情改變顏色。然後,我有以下錯誤,當我點擊
Select Color
按鈕AttributeError: 'str' object has no attribute 'set'
我試圖修正格式。您應該驗證代碼中的縮進並根據需要進行修復。另外,試着想出一個更具描述性的標題。目前的更像是一個標籤列表,我添加了真正的標籤。按[編輯]改善您的問題。 – 2013-04-25 19:08:14