OrbTk minimal example not working?

Hello,
I am a relatively new rust user, and I am trying to utilize the orbtk crate to make gui applications, however I can't seem to get the minimal example(https://github.com/redox-os/orbtk#minimal-example) to compile. I installed the dependacy on ubuntu with apt as described here, https://github.com/Rust-SDL2/rust-sdl2#linux, and all seemed to be well, and I pasted orbtk = "0.3.1-alpha1" into my toml file, and had this code in main.rs:

use orbtk::prelude::*;

fn main() {
      Application::new()
        .window(|ctx| {
            Window::new()
                .title("OrbTk - minimal example")
                .position((100.0, 100.0))
                .size(420.0, 730.0)
                .child(ctx, TextBlock::new().text("OrbTk").build(ctx))
                .build(ctx)
        })
        .run();
}

However, I tried to compile it, and got this:

error[E0599]: no function or associated item named `new` found for struct `orbtk_widgets::window::Window` in the current scope
 --> src/main.rs:6:21
  |
6 |             Window::new()
  |                     ^^^ function or associated item not found in `orbtk_widgets::window::Window`

error[E0599]: no function or associated item named `new` found for struct `orbtk_widgets::text_block::TextBlock` in the current scope
  --> src/main.rs:10:40
   |
10 |                 .child(ctx, TextBlock::new().text("OrbTk").build(ctx))
   |                                        ^^^ function or associated item not found in `orbtk_widgets::text_block::TextBlock`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0599`.
error: could not compile `orbtk-tester`.

To learn more, run the command again with --verbose.

What am I doing wrong here (or is it possible that the example is out dated)? I could have opened an issue for this on github, but I figured I was just being a Dunce and doing something wrong.

1 Like

The example might be associated with another version of orbtk. I encourage you to open an issue on their GitHub so they can improve the text around the example to help avoid more people being confused by the same thing in the future.

I'm a new Rust user also. I tried it and got the same error as you. But it looks like the minimal example is fixed today. Needs Window::create() and TextBlock::create. (You might also need the dependency to be the latest version.)

1 Like

Yeah thats correct. although in the newer versions create is still a function but it is depreciated. I just use orbtk = { git = "https://github.com/redox-os/orbtk.git", branch= "develop" } in my toml so that the examples work.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.