pub trait TkLabelOptions: TkWidget {
    // Provided methods
    fn compound(&self, value: Compound) { ... }
    fn font(&self, definition: &TkFont) { ... }
    fn foreground(&self, colour: &str) { ... }
    fn image(&self, image: &TkImage) { ... }
    fn padding(&self, values: &[u64]) { ... }
    fn text(&self, value: &str) { ... }
    fn underline(&self, index: u64) { ... }
    fn width(&self, value: i64) { ... }
}
Expand description

A set of common functions used in all label, button and similar widgets.

Colours are specified as strings, by either:

  • name - using one of the values in the tk colours list
  • rgb - as a 6-digit hexadecimal value in form “#RRGGBB”

Provided Methods§

source

fn compound(&self, value: Compound)

Sets how to arrange the image relative to the text.

source

fn font(&self, definition: &TkFont)

Sets the font to use for text.

source

fn foreground(&self, colour: &str)

Sets the foreground (text) colour.

source

fn image(&self, image: &TkImage)

Sets an image to display on the widget.

source

fn padding(&self, values: &[u64])

Sets space around the widget. Takes an array of up to four values, specifying the number of pixels on the different sides:

  • [all]
  • [left-right top-bottom]
  • [left top-bottom right]
  • [left top right bottom]
source

fn text(&self, value: &str)

Sets the text label for the widget.

Examples found in repository?
examples/hello-world-2.rs (line 5)
3
4
5
6
7
8
fn setup(root: &impl rstk::TkWidget) {
    let hello = rstk::make_label(root);
    hello.text("Hello from Rust/Tk");

    hello.grid().layout();
}
More examples
Hide additional examples
examples/hello-world.rs (line 7)
3
4
5
6
7
8
9
10
11
12
13
14
15
fn main() {
    if let Ok(root) = rstk::start_wish() {

        let hello = rstk::make_label(&root);
        hello.text("Hello from Rust/Tk");

        hello.grid().row(0).column(0).layout();

        rstk::mainloop();
    } else {
        println!("Failed to start wish program");
    }
}
source

fn underline(&self, index: u64)

Underlines the character at the given index position.

source

fn width(&self, value: i64)

Sets the width of the widget, in characters

Object Safety§

This trait is not object safe.

Implementors§