How to call a top class method from the bottom? For example, inside the main class there is a class based on a modal window. In this modal window, I enter the name of the file being created and click on "OK", the file is created and the task in the main class is to update the list of files (run the update method of the main class)
from kivy.app import App from kivy.uix.screenmanager import ScreenManager, Screen from kivy.uix.modalview import ModalView from kivy.lang.builder import Builder Builder.load_string(''' <SomeScreen1>: Button: text:'Please, push me!' on_release:root.view() <Win>: auto_dismiss:False size_hint:(.8,.8) BoxLayout: orientation:'vertical' Label: text:'some text' Button: text:'leave win!' on_release:root.leave() ''') class SomeScreen1(Screen): def __init__(self,**kwargs): super().__init__(**kwargs) self.win=Win() def view(self): self.win.open() def print_func1(self): print('OK1!') class Win(ModalView): def __init__(self,**kwargs): super().__init__(**kwargs) def leave(self): self.dismiss() #Вызвать print_func с этого места #Вызвать print_func1 тоже с этого места class TestApp(App): def build(self): sm=ScreenManager() sm.add_widget(SomeScreen1(name='screen one')) return sm def print_func(self): print('OK!') TestApp().run()
some_screen1parameter to theWinsome_screen1, and initiate the field:self.some_screen1 = some_screen1. In the constructorSomeScreen1change the stringself.win=Win()->self.win = Win(self). Inleaveuse that link to another window:self.some_screen1.print_func1()- gil9red 5:24 pm