3

I recently updated my kvmd to version 0.104.1, it included some breaking changes for dialogs. My program contains a button which when pressed shows a dialog box containing some text and 2 buttons viz OK and CANCEL. The cancel button simply closes the dialog while the ok button changes the screen and has to close.

My problem is with the OK button, it changes the screen flawlessly but it doesn't close after that, even when I have added the dismiss() but it works perfectly fine with Cancel button. So is there a problem in my code or is it a bug?

Code snippet:

    def on_signup(self, *args):
        self.dialog_close
        self.sm.current = 'ninput'

    def show_dialog(self, *args):
        if not self.dialog:
            self.dialog = MDDialog(title='Confirmation',
                                   text='You have been registered.',
                                   size_hint=(0.4, 0.3),
                                   buttons=[
                                   MDFlatButton(text='CANCEL',on_release=self.dialog_close), 
                                   MDFlatButton(text="OK!", on_release=self.on_signup) 
                                   ])

        self.dialog.open()

    def dialog_close(self, *args):
        self.dialog.dismiss(force=True)
  • A [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) would really help here. I have some ideas, but I can't test them. – bitinerant May 06 '20 at 09:59
  • @bitinerant can you be more subjective –  May 06 '20 at 16:02
  • I don't think you mean "subjective". The link I provided gives details, but basically I'm asking for a short program that I can run, see the problem, fix it, and give the fixed version back to you. – bitinerant May 06 '20 at 16:48
  • Oh okay sorry, I wasn't able to catch you. But I have somewhat bypassed the error so thanks anyways –  May 06 '20 at 17:05

1 Answers1

2

You forgot the brackets of your dialog_close() method, which is called in your on_signup() method. It should be like this:

def on_signup(self, *args):
    self.dialog_close()
    self.sm.current = 'ninput'
MisterNox
  • 1,445
  • 2
  • 8
  • 22
  • Well, I tried it and it works for me. What happens if you set the brackets? – MisterNox May 06 '20 at 16:13
  • Actually, I called self.dialog.dismiss() in the on_signup method and it works –  May 06 '20 at 16:21
  • But I don't know the reason why did it work with the direct dismiss() and not the separate method for it –  May 06 '20 at 16:22
  • okay, one more time. Your dialog_close() method is just a wrapper for the self.dialog.dismiss() method. but when you call `self.dialog_close` you are just calling the python object representation of the method and not the method itself, but when you call `self.dialog_close()` the wrapper method is been called and so the self.dialog.dismiss() inside of this method. – MisterNox May 06 '20 at 16:43
  • OK... Thanks alot!! –  May 06 '20 at 17:07