Crates.io | slint-viewer |
lib.rs | slint-viewer |
version | 1.8.0 |
source | src |
created_at | 2022-02-10 08:05:33.579429 |
updated_at | 2024-09-23 11:51:37.772897 |
description | The viewer binary for Slint |
homepage | https://slint.dev |
repository | https://github.com/slint-ui/slint |
max_upload_size | |
id | 530125 |
size | 210,486 |
This program is a viewer for .slint
files from the Slint Project.
The viewer can be installed from crates.io:
cargo install slint-viewer
Alternatively, you can download one of our pre-built binaries for Linux or Windows:
slint-viewer-linux.tar.gz
for a Linux x86-64 binary
or slint-viewer-windows.zip
for a Windows x86-64 binary.slint-viewer
/slint-viewer.exe
.You can open .slint files by just passing it as an argument:
slint-viewer path/to/myfile.slint
--auto-reload
: Automatically watch the file system, and reload when it changes--save-data <file>
: When exiting, write the value of public properties to a json file.
Only property whose types can be serialized to json will be written.
This option is incompatible with --auto-reload
--load-data <file>
: Load the values of public properties from a json file.-I <path>
: Add an include path to look for imported .slint files or images.-L <library=path>
: Add a library path to look for @library
imports.--style <style>
: Set the style. Defaults to native
if the Qt backend is compiled, otherwise fluent
--backend <backend>
: Override the Slint rendering backend--on <callback> <handler>
: Set a callback handler, see callback handler--component <name>
: Load the component with the given name. If not specified, load the last exported componentInstead of a path to a file, one can use -
for the standard input or the standard output.
It is possible to tell the viewer to execute some shell commands when a callback is received.
You can use the --on
command line argument, followed by the callback name, followed by the command.
Within the command arguments, $1
, $2
, ... will be replaced by the first, second, ... argument of the
callback. These will be shell escaped.
Example: Imagine we have a myfile.slint looking like this:
export component MyApp inherits Window {
callback open-url(string);
//...
}
It is possible to make the open-url
callback to execute a command by doing
slint-viewer --on open-url 'xdg-open $1' myfile.slint
Be carefull to use single quote or to escape the $
so that the shell don't expand the $1
If the root element of the .slint file is a Dialog
, the different StandardButton might close
the dialog if no callback was set on the button.
ok
, yes
, or close
buttons accepts the dialogcancel
, no
buttons reject the dialogThe program returns with the following error code:
slint-viewer
can be used to display an GUI from a shell script. For examples check out the
examples/bash folder in our repository.