2016-11-04 29 views
0

我需要從的TextInput發送文本與裝飾的功能我得到<__主要__。Root對象在0x9b61e880>,而不只是字符串或unicode字符串

#MyApp.kv 
TextInput: 
    #some parameters 
    id: TextInp 
Button: 
    #some parameters 
    on_press: root.myfunc(TextInp.text) 

這個文本一切進展順利,直到它得到我的功能:

#main.py 
def myDecorator(REQUEST): 
    def error_checker(*args): 
     try: REQUEST(*args) 
     except: #do something 
    return error_checker 

@myDecorator 
def myfunc(*args): 
    RESPONSE = args 
    #now RESPONSE == <__main__.Root object at 0x9b61e880>, or something like that 

如何正確發送TextInp.text到RESPONSE?

+0

如果你什麼'TextInp.text()'呢? –

+0

root.myfunc(TextInp.text()) 類型錯誤: 'STR' 對象不是可調用 – Fogapod

+0

沒關係,保持它作爲'TextInp.text'。如果你做了'RESPONSE = str(args)'? –

回答

1

看起來myfunc是根的方法。在這種情況下,它會自動接收當前實例作爲其第一個參數,通常稱爲self,這裏是args[0]。我認爲你的錯誤來自對這個參數的操作,而不是你關心的字符串(這是第二個參數)。