Skip to main content

Toga Layout

Project description

PyPI version

Toga Layout Builder

The purpose of this project is to create user interfaces easily with a yaml document. This is an unofficial tool for Toga GUI Toolkit.


pip install toga-layout-builder


  • Create Toga App in
import toga
from toga_layout import Layout

import myevents
import mystyles

def main():
    layout = Layout() = [myevents]
    layout.styles = [mystyles]
    widgets = layout.load('layout.yaml')
    return toga.App('Example Layout App', 'org.ignaciocabeza.example_layout_app', startup=widgets)

if __name__ == '__main__':
  • Create app layout in layout.yaml
    type: Box   
    style: ["padding_10","column_dir"]
        - box_row_1:
            type: Box
            style: padding_bottom_5
                - label_info:
                    type: Label
                    style: ['padding_top_5', 'flex1']
                    args: ['Insert your name here:']
                - text_name:
                    type: TextInput
                    style: 'flex1'
        - btn_greetings:
            type: Button
            style: "padding_bottom_5"
            on_press: handle_greetings
            args: ["Greetings"]
        - response_greetings:
            type: Label
            style: flex1
            args: [""]
  • Create events file in
from toga_layout import Layout, get_widget_by_id

def handle_greetings(Button):
    response_greetings = get_widget_by_id(Button.window, 'response_greetings')
    txt_name = get_widget_by_id(Button.window, 'text_name')
    response_greetings.text = f'Hello {txt_name.value}!'
  • Create styles file in
from import Pack, COLUMN, ROW

padding_10 = Pack(padding=10)
padding_bottom_5 = Pack(padding_bottom=5)
padding_top_5 = Pack(padding_top=5)
column_dir = Pack(direction=COLUMN)
flex1 = Pack(flex=1)
  • Run app

More examples at:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toga-layout-builder-0.3.0.tar.gz (4.3 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page