Использование функции одного класса в теле другого (Kivy, Python)
Всем доброго! Мне нужно использовать функцию из класса DepartureScreen в теле класса Date_Label Можете подсказать, как это сделать?
class Date_Label(Label):
def __init__(self, **kwargs):
super(Date_Label, self).__init__(**kwargs)
self.cur_touch_pos = 0
def on_touch_down(self, touch):
if self.collide_point(*touch.pos):
self.cur_touch_pos = touch.x
return super().on_touch_down(touch)
def on_touch_up(self, touch):
if self.collide_point(*touch.pos):
global cur_date
if touch.x < self.cur_touch_pos:
one_day = timedelta(1)
cur_date = cur_date - one_day
self.parent.ids.date_lbl.text = cur_date.strftime('%d.%m.%Y')
#self.text = cur_date.strftime('%d.%m.%Y')
elif touch.x > self.cur_touch_pos:
one_day = timedelta(1)
cur_date = cur_date + one_day
self.text = cur_date.strftime('%d.%m.%Y')
else:
print('Просто нажал!')
return super().on_touch_up(touch)
class Departure_Table(MDDataTable):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.size_hint_x = None
self.size_hint_y = None
self.pos_hint = {'center_x': 0.5, 'top': 1}
self.height = 500
self.width = 900
#self.shadow_color = (1, 1, 1, 1)
class DepartureScreen(Screen):
def __init__(self, **kw):
super().__init__(**kw)
global cur_date
self.dep_table = Departure_Table()
#cur_date = date.today().strftime('%d.%m.%Y')
self.ids.date_lbl.text = str(cur_date.strftime('%d.%m.%Y'))
self.load_dep_trains_data()
def load_dep_trains_data(self):
self.ids.dep_table_rl.clear_widgets()
self.ids.dep_table_rl.add_widget(Departure_Table(column_data = [('№ Поезда', 50), ('Прибытие', 50), ('Отправление', 50)]))
class MainApp(MDApp):
def build(self):
sm = ScreenManager()
sm.add_widget(MainScreen(name = 'main_screen'))
sm.add_widget(DepartureScreen(name = 'departure_screen'))
Builder.load_file('main.kv')
return sm
if __name__ == '__main__':
MainApp().run()
Заранее спасибо!