如何调用类中函数中的函数?

2024-04-27 01:05:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我在代码中遇到了一个问题,类中的函数中有一个函数,我找不到运行第二个函数的方法。你知道吗

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

Tags: the函数代码nameselfipadddef