2014-09-27 3 views
-1

그래, 문제가 있습니다. GUI 16 진수 변환기 및 i 계속 동일한 오류가 점점 만들려고. 나는 Tkinter에 경험이 없으므로 누군가 나를 도울 수 있습니까? 여기에 코드입니다 :레이블에 .config()를 사용하는 경우 Python 오류

from Tkinter import * 

def getNum(): 
    hex1 = e1.get() 
    dec1 = int(hex1, 16) 
    ol.configure(text=dec1) 



root = Tk() 

introLabel = Label(root, text='Input Hex Code: ').pack() 

e1 = Entry(root) 
e1.pack() 
e1.focus_set() 

inputButton = Button(root, text='Submit Hex Code', command=getNum).pack() 

ol = Label(root, text='Hex Code will appear here.').pack() 



root.mainloop() 

나는이 오류가 계속 :

Exception in Tkinter callback 
Traceback (most recent call last): 
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1470, in __call__ 
return self.func(*args) 
File "C:/Users/The Lodges/Desktop/Python/test.py", line 6, in getNum 
ol.configure(text=dec1) 
AttributeError: 'NoneType' object has no attribute 'configure' 

답변

3

.pack()의 반환 값은 위젯이 아니라 None. 이에서

변경 코드 : 이것에

ol = Label(root, text='Hex Code will appear here.').pack() 

:

ol = Label(root, text='Hex Code will appear here.') 
ol.pack() 

이 레이블에서 '가리키는'ol을 유지합니다.

관련 문제