A Simple GUI Library
We will have a number of widgets in our library:
- : has a
title
and contains other widgets. Button
: has alabel
and a callback function which is invoked when the button is pressed.
The widgets will implement a trait, see below.
The output of the above program can be something simple like this:
======== Rust GUI Demo 1.23 ======== This is a small text GUI demo. | Click me! |
fn main() {
println!("centered: |{:/^width$}|", "foo");
println!("right aligned: |{:/>width$}|", "foo");
Using such alignment tricks, you can for example produce output like this:
+--------------------------------+ | Rust GUI Demo 1.23 | +================================+ | This is a small text GUI demo. | | +-----------+ | | | Click me! | | | +-----------+ | +--------------------------------+