slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.09k stars 575 forks source link

component is deprecated. moving from zenity to slint for all graphical applications. #5382

Closed ghost closed 3 months ago

ghost commented 3 months ago

if i take this as a code template

import { StandardButton, GridBox, LineEdit } from "std-widgets.slint";
_ := 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 { }
        }
    }
}

then the declarable gives

':=' to declare a component is deprecated. The new syntax declare components with 'component MyComponent {'

any solution for this.

hunger commented 3 months ago

I would opt for a more descriptive name than _ like maybe UserDataDialog:

import { StandardButton, GridBox, LineEdit } from "std-widgets.slint";
component UserDataDialog inherits 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 { }
        }
    }
}

Basically X := Foo { } becomes component X inherits Foo {}, but actually component X { } works now, too.

You might also want to export the components you want to access from your business logic or from other .slint files, which would turn the above into export component UserDataDialog inherits Dialog {.

I hope this helps!

ghost commented 3 months ago

@hunger thank you and would it be possible to export the variable that we are reading in Text to another variable by shadowing the variable or implementing the hostig. Let me know.

I get to learn the SlintUI first through shell and then putting the javascript and rust later on for some of the applications development. Thank you, Gaurav