2014-11-09 9 views
1

내가 오류AttributeError : '기능'객체는 '위'에는 속성이 없습니다

Exception in Tkinter callback 
Traceback (most recent call last): 
    File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__ 
    return self.func(*args) 
    File "C:\Users\Matthew\Desktop\Code\Functionised\encoder idea 2 GUI ATTEMPT.py", line 10, in encode 
    m = m.upper() 
AttributeError: 'function' object has no attribute 'upper' 

나는 그것이 라인으로 할 알고 주어진 코드를 얻을 실행 - (m = m.upper를)

NOW 완료 - - 네이 내 제어 평가했다 -

하지만 난 어떻게 사람이 요청하기 전에이

import sys 
import os.path 
from tkinter import * 

def encode(): 
    array = [] 
    temp_array = [] 
    i = 0 
    m = message.get 
    m = m.upper() 
    array.append(m) 
    o = offset.get() 
    array.append(o) 
    length = len(array[0]) 
    while length > i: 
     temp = array[0][i] 
     if temp == " ": 
      temp_array.append(temp) 
      i = i + 1 
     elif temp == ".": 
      temp_array.append(temp) 
      i = i + 1 
     elif (ord(temp) + o) <= 90 and (ord(temp) + o) >= 65: 
      #print("Easy option") 
      temp = ord(temp) 
      temp = temp + o 
      temp = chr(temp) 
      temp_array.append(temp) 
      i = i + 1 
     else: 
      #print("Hard option") 
      temp = ord(temp) 
      temp = temp + o 
      temp = (temp % 90) + 64 
      temp = chr(temp) 
      temp_array.append(temp) 
      i = i + 1 
    i = i - 1 
    temp = temp_array[i] 
    while i > 0: 
     i = i - 1 
     temp = temp_array[i] + temp 
    array.append(temp) 
    word = (array[2]) 
    print(word) 
    my_file = open("messages.txt", "a") #Open the file messages or if it does not exist create it 
    for item in array:    #Get all items in array 
     my_file.write(str(item)) #Write them to file 
     my_file.write("\n")   #New line 
    my_file.close()     #Close the file 


gui = Tk() 

gui.title("Caesar Cypher Encoder") 

Button(gui, text="Encode", command=encode).grid(row = 3, column = 0) 
Label(gui, text = "Message").grid(row = 1, column =0) 
Label(gui, text = "Offset").grid(row = 1, column =1) 
message = Entry(gui) 
message.grid(row=2, column=0) 
offset = Scale(gui, from_=1, to=25, orient=HORIZONTAL) 
offset.grid(row=2, column=1) 

mainloop() 

를 해결하는 아무 생각이 나는 고급 기능을 알아 보려면 코드를 사용하고 있습니다 - 예를 들어, Tkinter를

답변

5

변경

m = message.get 

m = message.get() 

에 그렇지 않으면 기능-m 아닌 반환 값을 할당하고 있습니다.

+0

고맙습니다. –

+0

답변이 도움이 되었다면 '수락'으로 표시 할 수 있습니다. – TidB

+0

나는 8 분 안에 나를 허락 할 것이다. –

관련 문제