Instead of doing it in the app, create a function in the screen which has the button, then access the other screen and then add to it.
Kivy modification (Add the method and create a holder/container for the table)
MDRectangleFlatButton:
text: 'Proceed To Next Page'
pos_hint: {'center_x':0.5, 'center_y':0.4}
font_size : 20
on_press:
<AccountScreen>:
name: 'account'
FloatLayout:
MDLabel:
text: 'Accounts Page Test'
halign: 'center'
root.manager.current = 'account'
root.add_table()
BoxLayout:
id: table_holder
Python modification (create the method in the MenuScreen)
class MenuScreen(Screen):
def add_table(self):
account_screen_ref = self.manager.get_screen('account')
account_screen_ref.ids['table_holder'].add_widget(account_screen_ref.table)
class AccountScreen(Screen):
def on_kv_post(self):
rows = []
self.table = MDDataTable(pos_hint={'center_x': .5, 'center_y': .6},
size_hint=(.9, 0.7),
check=True,
rows_num=30,
column_data=[
("Type.", dp(38)),
("Balance", dp(20)),
("Date", dp(20)),
("id", dp(20))
],
row_data=rows
)
self.table.bind(on_check_press=self.check_press)
self.table.bind(on_row_press=self.row_press)
close_button1 = MDFlatButton(text='Close', on_release=self.close_view)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…