dir()
を使用して、どのメソッドとプロパティにオブジェクトがあるかを確認できます。あなたは
print(self.combobox['state'].string == tk.NORMAL)
をチェックすると
print(dir(self.combobox['state']))
結果
['__class__', '__cmp__', '__delattr__', '__doc__', '__format__',
'__getattribute__', '__hash__', '__init__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
'__subclasshook__', '__unicode__', 'string', 'typename']
あなたはあなたが得るstring
(メソッドやプロパティ)
を見ることができますTrue
テストのための最小限の作業例:str()
はあまりにも
print(str(self.combobox['state']) == tk.NORMAL)
EDIT動作します。
try:
# Python 2
import Tkinter as tk
import ttk
except:
# Python 3
import tkinter as tk
import tkinter.ttk as ttk
root = tk.Tk()
c = ttk.Combobox(root)
c.pack()
print(c['state'], c['state'] == tk.NORMAL)
print('normal:', c['state'].string == tk.NORMAL, str(c['state']) == tk.NORMAL)
print('disabled:', c['state'].string == tk.DISABLED, str(c['state']) == tk.DISABLED)
c['state'] = tk.DISABLED
print('normal:', c['state'].string == tk.NORMAL, str(c['state']) == tk.NORMAL)
print('disabled:', c['state'].string == tk.DISABLED, str(c['state']) == tk.DISABLED)
root.mainloop()
'self.combobox [ '状態を']の答えのための – furas