C++, GUI, on the Pi...

Community Forums/General Help/C++, GUI, on the Pi...

Dabhand(Posted 2013) [#1]
Basically, I want to create a GUI app on the Pi, though, I've got one problem... I havent got a single clue where to start in terms of references etc

I'm pretty clued up with Win32, in fact, Win32 programming is all I've done in the past when writing native GUI applications in C++.

So, anyone got any idea's on where I should head to to get up to speed with such things on Pi/Linux?

tar

Dabz


AdamRedwoods(Posted 2013) [#2]
fltk?


Captain Wicker (crazy hillbilly)(Posted 2013) [#3]
fltk

Gtk


Dabhand(Posted 2013) [#4]
Right, champion fella's, though, which one would you recommend, I've read over the last few whatsits regarding the MaxIDE editor being a bit fuzzy on one of them. Any reasons why I should choose one over the other on the Pi?

Basically, until I can wangle me whatsits on it, your best talking to me like I'm a child... Funny yes, but, when you go to learn a foreign language, they dont just say "french" to you, and thats it! :)

Seriously though, a bit more info from people that have used each one would be great, your thoughts and what not, more so, has anyone actually attempted to create a nice little GUI whatsit on a Pi?

Dabz


Yasha(Posted 2013) [#5]
<patronising git mode, as requested>

I haven't used the Pi so everything I say should be taken+salt, but-

The Pi is hardware. It runs basically everything that can run on a low-power ARM device. Therefore, the choice of GUI system is largely separate from the fact you're working on the Pi: what matters is which desktop environment and UI system the currently installed OS is running.

Knowing this, you can then go and find out that if you're using stock Debian, your desktop environment is GNOME, which is built on GTK+; if you're using Raspbian, it's LXDE, also built on GTK+; and in fact most of the popular Linux UIs are built on GTK+. etc. You can use a different toolkit, but your software will then require the libraries from the other toolkit to be installed, which you probably don't want to do on a small device like the Pi for space reasons.

Using a specific widget toolkit means tying yourself in to those specific UI elements. This is good, because it gives you a very fine level of control over the look of your app - you know at design-time exactly what it will look like and how it will feel; but it also means (as above) the toolkit must be installed on any system where you want your program to run. If you want it to run on Windows, for instance, it will depend on the user first downloading GTK+ for Windows, which is a sticky business. In practice it therefore really means you'd be specifically developing your app "for GTK+-based desktop systems", which might rule out a number of Pi users.

The other option is to use a GUI framework like FLTK. These normally work by providing a high-level wrapper around system-provided widgets (think MaxIDE). The advantage is that they work across a wide range of systems with minimal dependencies, sine they're designed to work on top of Windows/Cocoa/GTK+ and anything else; and the cross-platforminess is usually small enough to be handled by bundling it into your app. The downside is that you get less fine-grained control over appearance, or to put it bluntly, "it looks equally crap everywhere". You also won't be able to take advantage of any functionality specific to only one target, so you have to be willing to rule some things out.


The difference between these solutions is not really clear cut (yeah they do different things but that's not what you need to worry about right now): it's (partially) an analogue sliding scale between fine-grained control, and portability + ease of use. Same tradeoff you make everywhere.


So to decide where to start, you need to do two things, the same as for any application:

1) Define what your target is. Your target isn't "the Pi", because "the Pi" could be running a completely incompatible OS (the same way we don't normally develop for "the PC"). You need to assume a basic minimum level of compatibility in the installed environment, which for a hacker's toy is actually quite an important question.

2) Define what the loosest level of control is that will still let you actually achieve what you want, and then use a library that lets you code at that level.


...That was a very long-winded way of saying you probably want to get started by just reading up on simple GTK+ apps for a generic Linux environment.


Also, I know I'm well into stuck-record territory by now (especially talking to an experienced user), but... save yourself! It didn't have to be this way! You don't need to continue to use C++! If you look at GTK+, for instance, it would be an excellent opportunity to pick up Vala instead (a lovely high-performance C#-like language designed specifically for it).

Last edited 2013


Dabhand(Posted 2013) [#6]
^ Now that right there... Is exactly what I'm after! :)

Cheers Yasha, clears quite a bit up, and, I've had a look at that Vala language, and as such, yeah, that is up my street:-

using Gtk;
 
int main (string[] args) {
    Gtk.init(ref args);
 
    var window = new Window();
    window.title = "Hello, World!";
    window.border_width = 10;
    window.window_position = WindowPosition.CENTER;
    window.set_default_size(350, 70);
    window.destroy.connect(Gtk.main_quit);
 
    var label = new Label("Hello, World!");
 
    window.add(label);
    window.show_all();
 
    Gtk.main();
    return 0;
}


I can work with that! :)

All I needed was a decent starting point, a little bit of background from someone who knows, and voila... I'm a happy bunny! :)

Thank you! ;)

Dabz


Dabhand(Posted 2013) [#7]
One vala based GUI app up and running, shouting the "Hello World" odds... Granted it's on Linux Mint at the moment, but hey... She's building! :D

Dabz

Last edited 2013


Dabhand(Posted 2013) [#8]
Well, I've had a bit of a nightmare today... Made a little app on linux mint, with a text view and some dialogs... Though, when it was running, all the text was white, white in the textview, white in the dialogs... I was like "Eh?"

Been on alllllllllllllll daaaaaaaayyyyyyyyyyyyyyy trying to figure it out, I was managing to change the color using buffers or whatever they are in the text area, but that depended on inserting text, instead of typing, and obviously no good for the dialogs.

literally mucked on and mucked on, Googled like a possessed pillock, I was ready to give up, make a coffee, pissed about with a few games, then, I thought I'll have a nosey about in Mint.

I then saw the themes section in the appearance bit and an idea popped into my head... I wondered if my theme was breaking it.. So, I went in, low and behold, it was using "Custom Theme", which, didnt seem very good, so, I changed it to one of the preset ones... And guess what... Guess... Go on... Yes, thats right, I ran the sodding application again and it was ruddy fine!!!

ALLLLLLLLLLLLLLLLLLLL DAAAAAAAAAAAAAAAAAAAAAYYYYYYYYYYYYYYYYYYYYYYYYYY

That is all!

Dabz


Dabhand(Posted 2013) [#9]
Awesome... I closed down Mint, did a little bit on Windows, booted it back up, then for some reason ended up with getting "Session only lasted less than 10 seconds", and I cannot log in, and, one cannot seem to fix it!

Tell ya, I'm having a real bad day today!

Dabz


Dabhand(Posted 2013) [#10]
Just a little note, been using that Vala langauge for a while now, and finally, finally, 99.9% completed a editor in it:-



I've been refraining from posting as late, simply because, I think it's now the time I let go off the Blitz reins and move on, nearly all of BambooBasic is Blitz free, a shame, but, there we are, and as such, this will probably be my very last post here.

So, I really want to thank Yasha for pointing me towards Vala, it's an absolutely lovely language to work in, head scratcher at times, but that was down to me not really knowing it, and, I can actually see me using this for more and more stuff. It really is that nice! :)

Good luck on your projects people, I'll still probably lurk while having a brew on a morning before work, but other then that... Tara! ;)

Dabz


GaryV(Posted 2013) [#11]
this will probably be my very last post here.


Take care Dabz. Definitely can't blame you for moving on. Best wishes in all of your future endeavors.


matibee(Posted 2013) [#12]
Take care out there Dabs.. it's a big, bad world :D Yet another in a line of long time users moving on.

Au revoir buddy ;)


Steve Elliott(Posted 2013) [#13]
Take care Dabz, IDE looks good. But even if you don't post about Blitz matters, always handy to ask like-minded computer types here the odd question.