shell
pip install toga
python
import toga
def button_handler(widget):
print("Button clicked!")
def build(app):
box = toga.Box()
button = toga.Button('Click me!', on_press=button_handler)
box.add(button)
return box
app = toga.App('My First Toga App', 'com.example.myfirsttogaapp', startup=build)
app.main_loop()
yaml
name: MyFirstTogaApp
id: com.example.myfirsttogaapp
version: 1.0
widgets:
- type: Button
label: Click me!
on_press: button_handler