Sunday, 13 August 2017

On GUI's in Python and D…

I recently wrote a forum post regarding my experience with finding a suitable GUI in which to build a small toolkit.  My primary need, was for something I could hit the ground running on (because I already had a partially built application, but was wasting too much time fighting the toolkit), and which I could dump on a friend to just click and run.  Not the best of selection criteria, nor did I do a particularly exhaustive search for options (some very good ones of which were pointed out by other posters on that forum), but these things happen out there in the real world — sometimes your selection is legacy, and/or even just plain comes down to "the devil you know", though I don't think that was the majority case in this instance.  Anyhow, I'm going to re-post that post here, more or less…

Anyhow, here goes:

I've just recently gotten back into building applications with GUI's myself, after a 20 year lull.  Back then, it was Linux with GTK2; GTK3 and Glade were pretty new and a little too flaky to be worth the effort.  Now, just a couple weeks ago, I found myself wanting to throw together a small Modding GUI toolkit for a friend who's, well, not the most technically minded.

So I started with what they already have installed, Python and its Tkinter…  Well, that was a horrendous experience.  The Python→TCL→TK hop-skip-and-jump routine is, frustrating, and at the end of it, TK's not exactly the most capable of GUI's.  Don't get me wrong, I love TCL, it's a fantastic language, which I was very deeply into back in Uni, getting right into the guts of the language.  But TK…  While it kind of works in TCL, it's frustrating as heck in Python.  Take for example, checking to see if a tree item is hidden, and it returns a '0'.  Not a boolean, or even a number, it returns it as a string.  If you forget to explicitly cast it to an int, you get True (in TCL, it's a number with an optional string representation, and it'll do an implicit cast if necessary in any numeric context, but when translating it to Python, you just get the string rep, which is True if not empty).  As for the other Python GUI options, both myself and my friend are presently in Windows and, well, getting many of them to actually install cleanly was… problematic.  And if I had trouble getting those toolkits to install…

So I started looking for better options.  And I came across one I think well worth mentioning.  GtkDD really is a better C/C++ (I remember being rather disappointed when a YouTube'r I follow dismissed D offhand as merely — not a quote, the real quote would be shorter — "D is just a C++ as C plus 1 makes D, pointless naming rubbish", seemingly without actually looking at the language itself); it's an absolutely beautiful under-rated language, IMHO, which pretty much covers the useful parts of C#, without feeling like the proverbial "everything and the kitchen sink" that's all too common with Microsoft frankencreations (don't get me wrong, I use their OS, and some things they do are absolutely brilliant.  It's just that, some, well, go a little overboard, and/or just plain miss the mark entirely).  And paired with GtkD (which has a few minor gaps still, but nothing serious) bringing with it GTK3/Glade, has been a comparative delight to work in.  I did miss GTK, but I didn't miss C (though it was certainly educational in the ways of OOP back in the day), and this combination is just delightful.

Now, I think I'd rather be using Dgui — I'm pretty sure it would be far more effective — rather than GTK through a layer of D wrappers (where all that CTFE goodness has very little to chew on), though it's also a much younger GUI (which might or might not matter), and when I was poking around for options which just work so I could get on with re-implementing that toolkit, it was throwing page fulls of errors with the basic Hello World example, and very little idea what the problem was.  Plus I don't know if it had a GUI builder, though I think there may have been something to do with Visual Studio — which I'm not using mostly on account of it's rather large install size (gvim is my present IDE at the moment).  But, I needed something I could get up and running with now, and more importantly, that just worked for my friend, too.  I'll have a look at Dgui again later, because I'm sticking with D for my personal projects now, but GtkD was the easiest option to get going in again; partly due to my prior familiarity to GTK, and I just had to give my friend the GTK3 runtime installer, along with my compiled binary (a shared Dropbox folder would work wonders, down the line, until I have either reason or inspiration to sort out something better), and they were good to go.

No comments:

Post a Comment