0

I have a problem here in the code there is a function inside a function inside a class and I can't find a way to run the second function.

class startFunctionButton(npyscreen.ButtonPress):
    def whenPressed(self):
        IPScanForm.returnData ### Here should the function start

class IPScanForm(npyscreen.NPSApp):
        ip=""
        def main(self):
            f = npyscreen.FormWithMenus(name="Main Menu")
            IPselect = f.add(npyscreen.TitleText,name="IP Address: ")
            convertButtn = f.add(startFunctionButton,name="Start Function")

            def returnData(self): ### the second function
                IPScanForm.ip = IPselect.value ### thats just a placeholder could be anything
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
tester
  • 13
  • 2
  • You can't, this function does not need to be indented inside another. – Reblochon Masque Jul 02 '18 at 11:26
  • 1
    Run the second function *from where*? Inside `main`, after the definition you can call it by name like any other function, but it's not an instance method so the `self` parameter won't necessarily make sense. Outside `main` that function is inaccessible unless you explicitly return it. It's not clear what you're actually trying to achieve with it so it's hard to see what the best solution would be. – jonrsharpe Jul 02 '18 at 11:28
  • I went wrong how can i access the IPselect var? – tester Jul 02 '18 at 12:20

0 Answers0