Python/Kivy : Call function from one class to another class and show widget in Python

后端 未结 2 1478
一生所求
一生所求 2021-02-06 19:24

I am using Python-2.7 and Kivy. When I run test.py then a show button shows. When I click on the show button then a label and value shows. I am fetching it from

2条回答
  •  北恋
    北恋 (楼主)
    2021-02-06 20:14

    Problem

    You are instanting a second instance of class Invoice by invoking Invoice().abc() at method update in class EditPopup.

    Solution

    1) test.py

    Comment off Invoice().abc() at method update in class EditPopup and add pass.

    def update(self, obj):
        #cur.execute("UPDATE `item` SET itemName=?, itemCode=? WHERE itemId=?",
                #('Item1', 9999, 11))
        #con.commit()
        # Invoice().abc()
        pass
    

    2) test.kv

    Add a call to method abc in class EditPopup after call to method update.

        Button:
            size_hint_x: .5
            text: "Ok"
            on_release:
                root.update(root)
                app.root.abc()
                root.dismiss()
    

    Output

提交回复
热议问题