I'm currently trying to create a cross platform app with Beeware using Toga. I konw how to update the content in a window (I just empty everything in the box and add new content to it). But now I have the problem that I want to add entry fields which need to be assigned to a variable so I can get the value of them (And my class for the first window is already very big... so I don't want to add new properties and methods too it). So my intention was to create a new class besides my other class which displays my new window and closes the old one (or just replaces my old one)
E. g.:
import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW
class FirstWindow(toga.App):
def startup(self):
main_box = toga.Box(style=Pack(direction=COLUMN))
main_box.add(toga.Button('Open window 2', on_press=self.open_new_window))
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = main_box
self.main_window.show()
def open_new_window(self, widget):
# This should close the current Window and display the other window
# return SecodnWindow() doesn't work
# close() and exit() doesn't work too, cause I can't execute code after this
# statements anymore
class SecondWindow(toga.App):
def startup(self):
main_box = toga.Box(style=Pack(direction=COLUMN))
#adding all the stuff to the window
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = main_box
self.main_window.show()
# Other code
def main():
return FirstWindow()
Thanks ^^