Toga Layout
Project description
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.
Install
pip install toga-layout-builder
Use
- Create Toga App in
app.py
import toga
from toga_layout import Layout
import myevents
import mystyles
def main():
layout = Layout()
layout.events = [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__':
main().main_loop()
- Create app layout in
layout.yaml
main_box:
type: Box
style: ["padding_10","column_dir"]
widgets:
- box_row_1:
type: Box
style: padding_bottom_5
widgets:
- 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
myevents.py
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
mystyles.py
from toga.style.pack 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
python app.py
More examples at: https://github.com/ignaciocabeza/toga-layout-builder/tree/master/example.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file toga-layout-builder-0.3.0.tar.gz
.
File metadata
- Download URL: toga-layout-builder-0.3.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1feb16bc3f0511b1f7bfefaced123929b8590ab38e05841d8a340d4285e55ab5 |
|
MD5 | ae02da940d31a67d26daeb17e4191743 |
|
BLAKE2b-256 | bb0a55c70d24ecd9226feb6c6902148e42daec323b5f002e957e9e9e99489ab4 |
File details
Details for the file toga_layout_builder-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: toga_layout_builder-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d3b176366cb461411a007fbec55e4f356c4fa67970354e34a2aeaea755903b7 |
|
MD5 | e2fc3ede102e24b4c511c00d48d80710 |
|
BLAKE2b-256 | aa2319ad9edcc973726fb71b50ccb5a4a293575bbd4517a7470becb37d8bda72 |