GUI library similar to Ruby's "shoes"

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

3 Likes

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.

4 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:

4 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.

2 Likes

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.

1 Like

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

2 Likes

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.
4 Likes

LCL is a nice and powerful library but, there is that dependency to FPC. Something like Shoes could be implemented on SDL2. Why not SDL2 as a base for UI framework? It works everywhere. There are also working bindings: https://github.com/ysbaddaden/sdl.cr

It’s not easy to create native-looking UI from something lowlevel like SDL.
For example - how to implement ClearType\similar technologies, so text labels would look same as in other applications?
Another example - input box. It should support pretty much features, RTL languages, copypasting of strange Unicode symbols and so on. And then if you want something like RichEdit\WebView to display markup\tables\pictures?
Of cource it is possible, but why waste time it when GTK\qT\other UI libraries exists.

Or one can create library with adapter pattern that will implement all common denominator features for native libraries (canvas, mouse handling, keyboard handling, video playback if possible, custom events handling) so the rest can be implemented if needed on top of it.

1 Like

I just found out (thanks to GitHub trends section) about an interesting project that allow you to build cross platform GUI. It’s written in Go: https://github.com/fyne-io/fyne/blob/master/README.md

1 Like

Dang looks like xulrunner is defunct, so can’t easily go that route (embed HTML into your app LOL).

I like this https://pypi.org/project/PySimpleGUI/ which is a wrapper for Qt etc.

It also optionally wraps “remi” which itself looks interesting. Basically you run a local web server then use as a local server with the browser as the front end UI. Easy to understand and cross platform anyway LOL. Oddly remi itself has a “wrapper” for the end result HTML layout. But PySimpleGUI itself wraps remi? LOL.

libui is only “mid alpha”?

Does fyne actually do all the rendering itself using OpenGL for the backend? It seems to do its own font rendering etc. That’s an option…maybe…sounds tricky LOL. It would be nice if crystal supported iOS and android etc. it could make for some fun cross platform stuff…

Friend of mine built Sciter ( https://sciter.com/ ) 15 years ago (he is still actively supporting it)
It used by most of anti-viruses and other well known applications.
Is has smallest and one of the fastest HTML renderers on the market.
So you may be interested to look at it.

3 Likes

Here’s another option, you can call out to “yad” and have it do small UI’s for you, ex: https://askubuntu.com/a/1142671/20972

Not Windows or OS X friendly that I know of [yet], but available for Linux in a pinch…are there other command line tools to display a simple GUI, I wonder? Cross platform?

I also find interesting the idea of “bundling” the UI as a server into the executable then just spawning a browser to view it LOL.