2

I need your help on this.

class SwimMenu(Screen):
 
    wDiscard = "discard"
    def falsify1(self):
        global really
        really = False
        self.parent.remove_widget(self)
        #here I need to change text on discard button


reallyButton1 = Button(pos=(0, 0.1), size_hint=(1, 0.9), text="", background_color=(0, 0, 0, 0))
reallyButton1.bind(on_release=falsify1)

There is my .kv file:

<SwimMenu>:
name: "swim"
FloatLayout:
    Button:
        id: discard
        size_hint: 0.2, 0.1
        pos_hint: {"x":0.8, "y":0.9}
        text: root.wDiscard
        on_release:
            root.remove()

Basically what I want to do is to change text on discard button created in .kv file after pressing really button which is defined in python file. I have solved it with falsify1() function where I am also doing some other stuff, but I couldn't find a way to change text on discard button as self instance here is referring to the button itself, which I figured might be the problem. Every solution I have googled required self, which doesn't work for me.

Do you have any idea how to solve this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • `self` in the method referring to the `SwimMenu` instance. You need to get the `button` instance. Since it is a child of your `SwimMenu`, you want to find a way to get the children of your instance – tbrugere Jul 31 '22 at 12:22
  • If the `self` if referencing to the button and you want to get its parent class , I think maybe can try use `self.parent` to get its parent class ; `.children` for getting an object’s children ( if I didn’t remembering wrong ). Is it what you are looking for ? – Paul Lam Aug 02 '22 at 07:34

0 Answers0