Python を使用して、現在のプロジェクト用の新しいアプリケーションを作成しています。初めて利用しましたが、勉強になりました…
askcolor()アプリケーションに、Python から関数を呼び出すボタンがあります。最初はすべて正常に動作しますが、その後、次のエラーが表示されます。
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'