mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Add an example using bash and jq
This commit is contained in:
parent
d0f953f0e5
commit
672c95db42
2 changed files with 50 additions and 0 deletions
14
examples/bash/README.md
Normal file
14
examples/bash/README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# SixtyFPS Bash example
|
||||
|
||||
This shows how to use `sixtyfps-viewer` to display dialog from a bash script.
|
||||
|
||||
This assume that the `sixtyfps-viewer` tool is in patch. This can be achieved with cargo install.
|
||||
(use the `--path tools/viewer` option to install it from the current repository.)
|
||||
|
||||
```bash
|
||||
cargo install sixtyfps-viewer
|
||||
```
|
||||
|
||||
The examples also assume that [`jq`](https://stedolan.github.io/jq/) is in the path
|
||||
|
||||
* `simple_input.sh`: shows how to query a few parameter with bash
|
36
examples/bash/simple_input.sh
Executable file
36
examples/bash/simple_input.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash -e
|
||||
# LICENSE BEGIN
|
||||
# This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
||||
# Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
||||
# Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
# This file is also available under commercial licensing terms.
|
||||
# Please contact info@sixtyfps.io for more information.
|
||||
# LICENSE END
|
||||
|
||||
OUTPUT=$(sixtyfps-viewer - --save-data - << EOF
|
||||
import { StandardButton, GridBox, LineEdit } from "sixtyfps_widgets.60";
|
||||
_ := Dialog {
|
||||
property name <=> name-le.text;
|
||||
property address <=> address-le.text;
|
||||
StandardButton { kind: ok; }
|
||||
StandardButton { kind: cancel; }
|
||||
preferred-width: 300px;
|
||||
GridBox {
|
||||
Row {
|
||||
Text { text: "Enter Your name"; }
|
||||
name-le := LineEdit { }
|
||||
}
|
||||
Row {
|
||||
Text { text: "Address"; }
|
||||
address-le := LineEdit { }
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
)
|
||||
NAME=$(jq -r ".name" <<< "$OUTPUT")
|
||||
ADDRESS=$(jq -r ".address" <<< "$OUTPUT")
|
||||
|
||||
echo "Your name is $NAME and you live in $ADDRESS!"
|
Loading…
Add table
Add a link
Reference in a new issue