I'm very new to coding, about 2 weeks in. But, for a school project, I'm trying to create an app. To make my Python run on android, I'm using the Beeware suite. So, what I want to do is, on Android, when I click a button, I want it to open a new window. Like when you're on instagram and you click on someone's profile. Here's the code I've done til now.
import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW
def about(button, formal_name='a'):
main_box = toga.Box(style=Pack(direction=COLUMN, background_color='#7ed6c6'))
hello = toga.Label('Hello there!')
main_window = toga.MainWindow(title=formal_name)
main_window.content = main_box
main_window.show()
main_box.add(hello)
class Casa_musica(toga.App):
def startup(self):
main_box = toga.Box(style=Pack(direction=COLUMN, background_color='#7ed6c6', padding=20))
button = toga.Button(
'Click me', on_press=about)
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = main_box
self.main_window.show()
main_box.add(button)
def main():
return Casa_musica()
Did you figure this out? I'm working on it too. I've tried this so far:
Then define a function we called out on the "on_press" for the button above:
The new nav_button does render on the main screen, but pressing it does nothing. I'm wondering if it just kicks back to the main loop.