The Crystal Programming Language Forum

GUI library similar to Ruby's "shoes"

Anyone thought of making a GUI API similar to Ruby’s shoes?

I would love to have access to such a quick and easy UI toolkit.

How doe the others do it? (python, go etc,)

1 Like

Ah, Shoes! Makes me nostalgic. It was a time of lot’s of experimenting happening in Ruby (like in Crystal now), when Ruby wasn’t popular yet and everybody was coming up with some new idea. Why’s Shoes and his other projects was absolutely amazing.

It would be interesting to see something like Shoes for simple apps in Crystal for sure. OTOH Shoes were born when HTML based UI wasn’t common. Electron didn’t existed back then, even Node itself.

Electron apps are memory hogs but there are attempts to make lightweight libraries for building native UIs using HTML. I hope some of such attempts becomes successful and then it’s a matter of creating a bindings for Crystal. The HTML based apps would be an easy way to build UIs with any look you want.

Something like Shoes can work for native apps, where you don’t need lot’s of customization for controls.

There is this promising UI library (currently in alpha) which can be a backend for Crystal version of Shoes-like library with bindings for Crystal https://github.com/andlabs/libui#language-bindings

2 Likes

I’m sorry, but no. I’d rather retrain as a chimney sweeper.

2 Likes

Lol. I get it too, but HTML/CSS is quite good at declaratively building UI and there is just a huge ecosystem and much more people are comfortable with web technologies. Doesn’t mean the runtime should be huge or require the whole Nodejs.

Also this doesn’t mean you should completely go one way or another. There can be an app where you build most of it with native UI and for some parts doing it with Web might make more sense.

Yet, a Qt (or similarly native) binding via a Shoes-like API would actually make Crystal stand out as opposed to just “catching up”.

Compare Signal’s desktop app to Telegram’s desktop app. Telegram is miles above any web-based solution in terms of robustness and reliability.

What is highly ironic is all HTML/CSS development is coming back around full circle to OOP style GUI frameworks.

What is a component other than an object with behavior, style, state, etc? :laughing:

2 Likes

Oh so very much this.
If you want to see a modern innovative way of building UIs have a look at the QML part of QT.

Wouldn’t QML make Shoes-like lib for Crystal unnecessary? It’s already declarative, why bother duplicating it in Crystal?

Well, the main problem with Qt itself is the ridiculous build process for various platforms. Take a look at the install instructions for Telegram’s open-source client code for example. It’s like 45 steps to get a client working.

Ideally, a Crystal GUI lib would make things a bit easier.

That’s why I really hope libui will took of soon enough and it will be even more lightweight solution than QT.

1 Like

Eh? The point of shoes was simplicity.
And that is something we (crystal) don’t have. Or at least I have not found something thats simple to use, and possibly even cross platform(ish).

I do like the idea of a libui wrapper in a shoes-like API

I have something similar - https://gitlab.com/kipar/no-no-gui
But there are several catches.

  1. It’s not exactly “shoes-like” because i’ve never used shoes. It just happens that my ideas about ideal GUI DSL are similar to what is implemented in shoes. I can of course change some names to make it more shoes-like, but internal things are different too - it is basically “immediate-style gui”, so gui procedure is rerun every time something changes. This allows for things like
  flow(scrollable: true) do
    @data.each do |x|
      button do
        text "Change #{x.value}"
        on_click do
          x.change
        end
      end
    end
  end

(that will change count and label of buttons dynamically depending on @data) to work.

  1. It’s not based on qT or libui. In fact, i’ve tried to base it on libui at first, but then discovered the flaw in libui - there are no fixed layouts. So no way to set x and y property for button, label etc… Not even custom margin.This is unacceptable for me. So I’m currently using … (dramatic pause)… LCL as a backend. This is a plus for me but I think a minus for most other people. Maybe I’ll switch to GTK3 later. For now installation instructions are basically “install Lazarus, build project with it, then you can use shard”.
  2. It’s alpha. Many components are supported (see screenshot on project page), but there are many things left to do and there are rough edges (lack of documentation make them even more rough). Also, no HTML-like labels. I’m going to use this library at work (for embedded pults), so development will go on, but i can’t promise it.