TypeError: 'kivy.weakproxy.WeakProxy' object is not callable

TypeError: 'kivy.weakproxy.WeakProxy' object is not callable

我是kivy新手,准备写一个游戏app

File "c:\Users\sorus\OneDrive\Desktop\New folder (2)\dear_pygui\update_label.kv", line 24, in <module>
     on_press : root.sang()
 TypeError: 'kivy.weakproxy.WeakProxy' object is not callable

main.py:

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
from kivy.core.window import Window
from kivy.lang import Builder
import random
from kivy.uix.widget import Widget

game_list = ["Sang" , "Kaqaz" , "Qeichi"]
user_score = 0
computer_score = 0
random_choose = random.choice(game_list)


Builder.load_file("update_label.kv")        


class MainPage(Widget):





def sang(self):
    global computer_score
    global user_score
    global random_choose

    random_choose = random.choice(game_list)
    choose = "Sang"
    if random_choose == "Kaqaz" and choose == "Sang":
        computer_score += 1
    elif random_choose == "Qeichi" and choose == "Sang":
        user_score += 1
    else:
        pass

    
    
    
def kaqaz(self):

    global computer_score
    global user_score
    global random_choose
    


    random_choose = random.choice(game_list)
    

    choose = "Kaqaz"
    if random_choose == "Qeichi" and choose == "Kaqaz":
        computer_score += 1
    elif random_choose == "Sang" and choose == "Kaqaz":
        user_score +=1
    else:
        pass


    
def qeichi(self):
    global computer_score
    global user_score
    global random_choose
    random_choose = random.choice(game_list)

    choose = "Qeichi"

    if random_choose == "Kaqaz" and choose == "Qeichi":
        user_score += 1
    elif random_choose == "Sang" and choose == "Qeichi":
        computer_score += 1
    else:
        pass
    
def restart(self):
    global computer_score
    global user_score

    user_score = 0
    computer_score = 0


def update(self):
    global computer_score
    global user_score
    global random_choose
    self.random_choose.text = ("Bot :" + random_choose)
    self.your_label.text = ("Your Score :" + str(user_score))
    self.computer_label.text = ("Computer Score : " + str(computer_score))
    

def on_touch_up(self, touch):
    self.update()





    
class Myapp(App):
    def build(self):
        return MainPage()
    



if __name__ == "__main__":
    Myapp().run()

i 运行 此代码与 .kv 文件并出现此错误:

TypeError: 'kivy.weakproxy.WeakProxy' object is not callable

update_label.kv:

<MainPage>

 sang : sang
 kaqaz : kaqaz
 qeichi : qeichi
 restart : restart
 random_choose : random_choose
 user_score : user_score
 computer_score : computer_score
 GridLayout:
     cols : 1
     size : root.width , root.height

     Label:
         id : random_choose
         text : "Hi"

     GridLayout:
         cols : 1

         Button:
             id : sang
             text : "Sang"
             on_press : root.sang()

         Button:
             id : kaqaz
             text : "Kaqaz"
             on_press : root.kaqaz()

         Button:
             id : qeichi
             text : "Qeichi"
             on_press : root.qeichi()
         



         Label :
             id : user_score
             text : "Your Score :" 
         Label :
             id : computer_score
             text : "Computer Score :"

         Button:
             id : restart
             text : "Restart"
             on_press : root.restart()
 ```

please help me to figure out.
and if you have know about this topic please comment how i should to do
nobody have good solution about this topic

在您的 kv 行中:

sang : sang

root.sang 设置为对 ID 为 sangButton 的引用,而不是 sang 方法。单击 Button.

时会产生错误

解决方法是更改​​ ids 或函数名称。确保您没有为不同的事物使用相同的名称。