2017-06-15 10 views
1

このコードを実行するtry/exceptブロックを作成しようとしています。このコードは、回答を表示するポップアップからクリックする必要があります。計算ボタンを押して再計算します。Kivy TypeError - Try/Except句でLabelオブジェクトが呼び出せません

class TabSys(TabbedPanel): 
savedfiles_hydraulus = [] 
def calculate_psc_clicked(self, Cp_text, P_text, lhv_text): 
    global psychrometric_constant 
    #when they click the button which is id'd as "calculate_psc," this function 
    #will pull the values and perform the calculations 
    try: 
     psychrometric_constant = (float(Cp_text)*float(P_text))/(float(lhv_text)*float(2.26)) 
     self.psc_answer() 
    except ValueError: 
     """Needs a popup for wrong results""" 


#the popups print out the answers and offer the user an option to save or dismiss the window 
def psc_answer(self): 
    global Flag 
    Flag = False 

    #Layout 
    popupscreen = FloatLayout() 
    self.psc_notes_label = Label(text = "Psychrometric constant: (Cp*P)/(λ*MWr)", pos_hint = {"center_x": 0.5, "center_y": 0.7}) 
    self.psc_answer = Label(text = str(psychrometric_constant), pos_hint = {"center_x": 0.5, "center_y": 0.4}) 
    popupscreen.add_widget(self.psc_notes_label) 
    popupscreen.add_widget(self.psc_answer) 

    #Dismiss Window 
    self.cancel_psc_answer = Button(text = "Cancel", pos_hint = {"center_x": .575, "center_y": .065}, size_hint = (.3, .2)) 
    self.cancel_psc_answer.bind(on_release = self.dismisspsc) 
    popupscreen.add_widget(self.cancel_psc_answer) 

    #Window Setup 
    self.popup = Popup(title="Result", content = popupscreen, size_hint=(.5, .5), size=(400, 400), 
    separator_color = [217/255, 179/255, 255/255., .85]) 
    self.popup.open() 

#Dismiss Function 
def dismisspsc(self, *args): 
    self.popup.dismiss() 

それは残念ながら、非常に多くのですが、私はしました:私は計算ボタンをもう一度押して行くときしかし、それは私が以下のコードを出してあげる私に

TypeError: 'Label' object is not callable 

を与えます私ができるだけ多くを切った。誰かが必要な場合は、私は今すぐ持っているので、私はコードの全体とペーストビンをリンクすることができます。

私はこの問題は、ライン

try: 
    psychrometric_constant = (float(CP_text)*float(P_text))/(float(lhv_text)*float(2.26)) 

はそれがより良いpsc_answerの関数内で果たす可能性があるブロックを除くのtry /にあることかもしれないと思います。

ありがとうございました:)

+0

ここに私のコード全体があります:https://pastebin.com/p2eCdPRX –

答えて

0

回答が見つかりました。もし誰かがこの問題を抱えているのであれば、おそらくあなたが関数のために持っているのと同じ名前を、ある時点で使っているからでしょう。私は関数psc_answerとラベルpsc_answerを命名しました。

関連する問題