Julia for GUI app

Will check it out. :wink:

How?

It’s nice not to be alone in this world. :smiley:

Can you provide some concrete option what have you used to do it?

One clunky example can be seen here: https://github.com/amellnik/Julia-Node-stack-demo A back-end Node server provides an API which run calculations in Julia. Here’s it’s just calling a single function from Clustering.jl, but it could easily kick off a more-complex calculation.

Edit: I should note that I rarely do this in practice. Most of the time I’m able to split things up so that I have Julia code that pulls data, does a ton of processing, then updates a database, and then a node-based API that sits on top of that database, and an Angular 1/2 web app that consumes the data from the API. Depending on what level of interactivity you need, this may not work.

I’ve used the HttpServer package to “talk” to the browser through the HTTP protocol, while the rest is custom code:

  • The back-end of the app written in Julia and operating with high-level types (most of the code goes here and can be coded freely to the programmer’s taste).
  • The front-end of the app written in Julia to resolve HTTP requests into high-level calls to the app’s back-end, and then form the app’s return into HTTP responses (this is easier than it sounds, thanks to the HttpServer package, still it’s not trivial).
  • An HTML generator written in Julia to fill an IOBuffer with the app’s return’s high-level types turned into HTML tags (this is plain dumping).
  • A small client-side file written in JS to translate events into AJAX requests and update the proper fields of the HTML DOM with the server’s response (this is easier than it sounds, thanks to modern browsers, still JS :wink: makes it non-trivial).
1 Like

Why not simply give Gtk.jl a try? It is certainly the most mature package for writing GUI applications and in combination with Glade its a pretty modern approach to write UI apps. I have build a pretty large app with Gtk.jl and until now are more than satisfied.

1 Like

FWIW I really appreciate the design of Gtk.jl and would like to use it.

But my problem with Gtk is that it really is very rough on Windows (and also Mac), unless I have missed something. And this is made even worse on very high resolution displays. Qt on the other hand does much better on both platforms. This is not a minor issue, ugly GUIs really do put people off in a slightly irrational way (the functionality might be perfect).

If Qt with its C++ baggage is too much, then maybe https://github.com/andlabs/libui and https://github.com/joa-quim/Libui.jl might be a nice solution; but I haven’t looked into it much yet.

The simplest solution would be that I am just ignorant and have missed the trick to make Gtk useable on windows.

1 Like

I’m glad to hear you’re happy with it. :wink:

I also use GNOME so I like Gtk’s look’n’feel - the only consideration is that I?m repeatedly told that it looks like crap on Mac OS & Windows…I do not run Windows any longer, even under Virtualbox since XP was the last license I had and never had access to the Mac OS…

Same here. ,)

Yeah, I’m told the same.

[quote]And this is made even worse on very high resolution displays.
[/quote]

That I don’t know. Can you elaborate it a bit? I’ve heard only that the Gtk apps long strange, iow. non-native on non-Linux OS-es…

[quote]If Qt with its C++ baggage is too much, then maybe https://github.com/andlabs/libui and https://github.com/joa-quim/Libui.jl might be a nice solution; but I haven’t looked into it much yet.
[/quote]

That’s interesting - I was looking at libui when I was considering to use Go, but it looks that GUI is not the right niche for it.

However, I haven’t thought there might be Julia bindings for it.

Hello colleague,

could you provide a screenshot or similar?

I use Gtk.jl on all three platforms. I can not confirm that there are issues on Windows. It simply works and looks ok.
OS X has in my experience some more glitches but in principle works as well.

Here is a screeshot that I once made:

The point is that it does not make too much sense discussing various UI frameworks in isolation here. The question is how they fit to Julia. In Gtk fits very very well to Julia since it is a C library and @jameson did an awesome job to integrate Gtk with Julia. Most types are automatically handled which makes programming with Gtk.jl a pleasant experience.

This does not mean that everything is perfect: There are missing peaces, the project lacks developers, documentation is not perfect. But nevertheless if someone wants to do serious UI development it is from my perspective the best option.

1 Like

I also use GNOME so I like Gtk’s look’n’feel - the only consideration is that I?m repeatedly told that it looks like crap on Mac OS & Windows…I do not run Windows any longer, even under Virtualbox since XP was the last license I had and never had access to the Mac OS…

Are you concerned about the cross platform capabilities as your project should be usable for other users?
If something looks like crap is pretty subjective and maybe you should form your own opinion on the look and feel. In practice it is much more important that a UI is usable instead that it looks good.

As a general observation on this issue, I think it’s pretty frustrating that we don’t have a good answer to this, but I think we’re not alone – the GUI toolkit space seems to be long on options and short on satisfaction. It seems that you can have two of the following three:

  1. Cross-platform.
  2. Really good native look.
  3. General: can build any kind of GUI.

Single-platform are often very good and provided by the platform vendor – these are 2 & 3. Most other toolkits are cross-platform but leave much to be desired in aesthetics – i.e. 1 & 3. Many people have tried, but it seems almost impossible to write generic cross-platform GUI code and have it look really good on all platforms. But I have to wonder if there isn’t a space for 1 & 2 – i.e. a limited-purpose cross-platform toolkit with very nice, largely automatic, native aesthetics. A lot of scientific applications have pretty limited, simple GUI requirements, and it would be nice if they were cross-platform and looked really good, as compared to the notoriously bad looks of some common open source GUI toolkits. Part of the problem seems to be automatic widget layout, which is a notoriously hard problem, but one which Julia is well-positioned to address since we’ve got JuMP :sunglasses:

3 Likes

Not sure if I fully agree. In my experience scientific apps are actually pushing UIs to the limit and therefore need the flexibility to do customization. And at that point you are lost if your toolkit is just a large wrapper that does not give you a handle to the low level part.

Just as an example why I am so excited about Gtk.jl: If you render an image with Gtk, you actually just draw on a native Cairo canvas. And with Cairo.jl being a very mature package this is really just fun to do. You can for instance natively embed Winston into any Gtk app without any issue.

I have considered other alternatives but the power that I get from Gtk + Cairo + Winston is pretty sophisticated.

One other thing is that nowadays one actually does not want to code the layout of an application. Layout is done in a declarative way using e.g. xml in combination with an UI designer. Thus, when considering UI toolkits it essential that this is provided.

1 Like

Having a canvas is actually pretty simple – it’s just an area where the program is totally in charge of the pixels. The stuff that’s hard for the GUI toolkit is the layout of text and buttons around it, which is where I think that scientific apps have relatively limited requirements, compared to, e.g. a word processor or spreadsheet app.

1 Like

Frankly speaking I’m mostly concerned to make the project to work on my native (Linux) platform and having cross-platform app is just a convenient add-on. I’m thinking about open-source app, but aware that it’s not that everyone is using Linux on the desktop.

However, I am simply not attracted to pursue web-technology in order to make it cross-platform.

Finally, PyQt is a valid proof that it’s possible to have great GUI by not using C(++)…

I fully agree. :wink:

1 Like

I’m just exploring Python vs Julia and not being aware of JuMP, can you explain a bit connection with GUIs?

a few random thoughts:

Current Gtk is rendering everything via Cairo + Pango. Their future plans is to drop Cairo and use a new toolbox with GL/EGL rendering (see https://www.bassi.io/tag/gsk-demystified/).

Yes, layout is hard. But the hard part isn’t solving the constraints, it’s formulating the problem.

Keep in mind, that both Qt and PyQt are commercial products with some ‘free’ licensing.

PyQt is doing all the heavy lifting between python and a C++ library, it’s not like the effort isn’t spend, it’s just hidden.

A drawing canvas is a rather simple thing, for any interactive UI, jou need a responsive canvas or a scene toolkit.

Hardest thing (speaking about hard problems): Find people to work on this. The ratio of users to developers is close to inf.

2 Likes

It solves optimization problems, so he’s saying you can use it to optimize widget locations according to some cost function to have it all be done automatically. That would be an interesting idea. If not interesting, at least fun to explore and pretty boss if you get it right, boss enough that you have to put on some shades to mask others from your awesomeness. So I totally agree:

1 Like

Hardest thing (speaking about hard problems): Find people to work on this. The ratio of users to developers is close to inf.

well said.

Thats why I really suggest people wanting to write UI try Gtk.jl which is in a pretty usable state. Several members of the Julia community have put quite some effort in ensuring that installing Gtk.jl is as easy as Pkg.add(“Gtk.jl”). There are people using Gtk.jl in larger projects and there have not been that much complaints.

The most serious issue currently is that Gtk.jl lacks developer manpower.

1 Like

I’ve used Gtk.jl quite a bit, and looked at alternative and I think it’s the best option right now. There’s is plenty of issues with it but you can still work around them for the most part (it’s somewhat broken on 0.5 though at the moment).

But my problem with Gtk is that it really is very rough on Windows (and also Mac), unless I have missed something. And this is made even worse on very high resolution displays.

I don’t know if that’s your issue, but I think anti-aliasing is not enabled by default on windows (there’s no settings.ini file) and fonts looks horrendous as a result.