Articles Hierarchy

Articles Home » RPI » RPI to learn GUI programming

RPI to learn GUI programming

summary:

0: this infolinks
1: intro HOW to learn GUI the hard way
2a: PYTHON 4 ways ( Tkinter, pygame, matplotlib, pygtk )
2b: PYTHON WX
2ca: PYTHON QT4
2cb: QT5 update
2e: PYTHON QT5
2f: PYTHON QT5 QT QUICK (qml)
3: TCL Tk
4a: C# GTK
4b: C C++ GTK
4c: code blocks
4d: perl GTK 2
4e: java JDK 8
4f: Free Pascal / Lazarus
5a: RUBY
5b: ICON
6: Python use gtk together with PYGAME, Tkinter
7: GUI design tools C _ GLADE _ GEANY
more see desktop and menu system
10: get all the code examples

1: intro HOW to learn GUI the hard way
while i play vkeybd i see that it exists as a executable in /usr/bin/ and as a TCL vkeybd.tcl in /usr/share/vkeybd, digging what that TCL means, i learn that it is a command language / programming language.
on RPI TCL with TK rev 8.5 is installed, ( i find >130 .tcl files in the system ), looks like its a common linux language with TK GUI, but there is this thing with the prof. programmers, for them all other languages, except the one they use, is bad.
as a linux beginner i am OPEN, but i ( and i see that question in the forum too ) want learn the full GUI way, means make a program what opens a window on the RPI desktop with keyboard and mouse operation, AND want be able to start it from the System MENU or desktop ICON.
From forum was that bad example that a beginner asked about learning GUI programming and got the tip to install
C# MONOpls see http://logicalgenetics.com/raspberry-pi-and-mono-hello-world/
sudo apt-get update
sudo apt-get upgrade

(sudo apt-get install emacs)
sudo apt-get install mono-complete (160MB)

mkdir HelloWorld
cd HelloWorld
(emacs HelloWorld.cs)
nano HelloWorld.cs

using System;

public class HelloWorld
{
public static void Main()
{
Console.WriteLine("Hello World!");
}
}

gmcs HelloWorld.cs
mono HelloWorld.exe

i was interested and did try it too. it is a terminal / command line thing only, so GUI would be still some way.
but why i say it was a bad tip?
is it that i do not like C#? i love it! most of the day the arduino IDE ( on PC or RPI ) is open, that is a C# cross compile tool for ATMEL AVR 8bit ATmega328 cpu. so:
RPI is designed / promoted as a learning system for programming, so if someone buy it and want learn (GUI) programming, there must be easy tutorial to use any of the already installed languages. if that is not possible, you must question the raspberry pi foundation system concept.

2a: PYTHON 4 ways
until now i used only PYTHON with the 3 flavours / (GUI) libs / ( what not easily can be mixed )
- 2a.aTkinter (example)
- 2a.b Pygame (example)
- 2a.c Matplotlib ( add installed ) (example)
- 2a.d pygtk ( i just test, never used before )
and add i made the .desktop files to use them from RPI desktop; ( example )
here now the python GUI basics, now already included the pygtk version example also in the ZIP file with all examples.


but let's start easy:
you can use CLI ( even via putty nano xxx.py ) but as we anyhow want to do a python program
what opens a window on desktop ( i call it a GUI program ) we should also work there!
Menu/Programming/Python 2 opens the IDLE 2 ( python 2.7.3 )
could use also Python 3. Later, after understand the differences, you can learn how to write a program what runs in both environments ...
in that window see the >>> prompt / interactive mode / rarely used, but very good for special checks.
as this can not be a python course ( google for "python courses online" ) or start here
but what we need is to start with editing code files. so you should make a sub dirctory for your python play files first and
use from IDLE the file / new / save as / 'go new sub directory' / filename : myfirstpythonprogram.py
but, what the hell, you could just save it at /home/pi/Desktop/..
you want see some examples first? look /home/pi/python_games/*.py
if you are in the edit window use menu run / run module / ( or F5 ) must ok save first!
you test your program!
only when all problems solved you can skip the IDLE environment and just open a terminal and type
python /home/pi/Desktop/myfirstpythonprogram.py what will use default python 2.
for python 3 type
python3 /home/pi/Desktop/myfirstpythonprogram.py
you can select in context menu if you want open a *.py file per default at double click with leafpad editor or with IDLE

there is a special thing if you want to use some RPI hardware like the GPIO pins from programming, you need root priv.
so you must start with
sudo python myfirst_GPIO_program.py in terminal
and yes, still can use IDLE by
sudo idle from a terminal in desktop, and the python shell window comes up in admin mode.


2a.a from python to GUI with python Tkinter
if you loaded my examples you pls find
/home/pi/GUI_test/python_test/python_tkinter_GUI.py
i started also with python tkinter because i searched for a python what can give me a slider for operation
see above example snap from a PID control...process control system i made.

2a.b later i see that actually with some easy code in pygame i could make my own ( and with that more flexible ) slider.
pygame GUI
/home/pi/GUI_test/python_test/python_pygame_GUI.py
some, who anyway are interested in game programming will start there, others say "i never will do games"
well, you don't need to, i used it for a easy button slider audio system tool and later for a test about synth and midi and keyboard

2a.c but when i catched some data from my arduino via the USB port ( by a python service program )
i needed a nice plot, that's what matplotlib is for ( and it comes with its own GUI window )
/home/pi/GUI_test/python_test/python_matplotlib_GUI.py
now that will not start until you install something
sudo apt-get install -y python-matplotlib
i did the current trending for the ARDUINO µPCS and the PoorManScope

2a.d other than the Tkinter also can use the GTK, see
/home/pi/GUI_test/python_test/python_pygtk_GUI.py
the other python files in that python_test dir are explained later


2b: PYTHON WX
additionally i want to test on one more python GUI,
while i do
installsudo apt-det update
sudo apt-get upgrade
sudo apt-get install python-wxgtk2.8


i see while installing
suggested packages:
wx2.8-doc wx2.8-examples editra
and in RPI forum
sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n libwxgtk2.8-dev
sudo apt-get install python-wxgtk2.8 python-wxtools wx2.8-i18n libwxgtk2.8-dev libgtk2.0-dev
but it worked anyhow for the small hello world example window.



2c: PYTHON QT4
on a new setup wheezy 05.05.2015 SD system ( using RPI1B hardware)
i want test more GUI programming tools.
start for PYQT

from here find i would need this:
sudo apt-get install libqt4-assistant libqt4-core \
libqt4-dbg libqt4-dbus libqt4-designer libqt4-dev \
libqt4-gui libqt4-help libqt4-network libqt4-opengl \
libqt4-opengl-dev libqt4-qt3support libqt4-script \
libqt4-sql libqt4-sql-ibase libqt4-sql-mysql libqt4-sql-odbc \
libqt4-sql-psql libqt4-sql-sqlite libqt4-sql-sqlite2 \
libqt4-svg libqt4-test libqt4-webkit libqt4-webkit-dbg \
libqt4-xml libqt4-xmlpatterns libqt4-xmlpatterns-dbg \
libqtcore4 libqtgui4 qt4-demos qt4-designer qt4-dev-tools \
qt4-doc qt4-doc-html qt4-qtconfig qtcreator

i do only

sudo apt-get install python-qt4 libqt4-dev python-qt4-dbg qt4-dev-tools 434 MB
and now see in desktop menu / programming /
QT4 assistant ( a help system ) designer ( widget form tool (like GLADE) ) linguist ( no idea whats that for )

but first:
start only the IDLE python2 shell and type
import PyQt4 looks ok

first hello world example get from here
other info here

#!/usr/bin/env python

import sys
from PyQt4 import Qt

# We instantiate a QApplication passing the arguments of the script to it:
a = Qt.QApplication(sys.argv)

# Add a basic widget to this application:
# The first argument is the text we want this QWidget to show, the second
# one is the parent widget. Since Our "hello" is the only thing we use (the
# so-called "MainWidget", it does not have a parent.
hello = Qt.QLabel("Hello, World")

# ... and that it should be shown.
hello.show()

# Now we can start it.
a.exec_()




when i try same file from IDLE3 error: no module named PyQt4
in raspberry forum see:
by DougieLawson » Fri Feb 27, 2015 4:04 pm
sudo apt-get install python-qt4 python-qt4-dbus python-qt4-dev python-qt4-doc python-qt4-gl python-qt4-phonon python-qt4-sql python-qtmobility python-qwt3d-qt4 python-qwt5-qt4 python3-dbus.mainloop.qt python3-pyqt4 python3-pyqt4.phononpython3-pyqt4.qsci python3-pyqt4.qtopengl python3-pyqt4.qtsql


other sources:
sudo apt-get install python3-pyqt4
first i do
sudo apt-get install python3-pyqt4 python3-pyqt4-dbg python3-sip
ok, now python3 runs this example too.


away from python check on QT what with QT creator a C++ IDE for desktop applications
sudo apt-get install qtcreator ( 103 MB more ) see icon QT creator ( not QT4 )
so, that should be the IDE, but how to use it for python i have to find out,
also how to combine it with the QT4 designer?
without that there could be not much reason to use it instead of IDLE2 or IDLE3
more info forum and here and here


sudo apt-get install python3-pyside ( 90MB more ) and see no new desktop menu entry??
here i not see what it is for,
but to combine it with QTCreator see here and here


2cb: QT5 update
12/2016 i just updated my RPI3 ( remote on WIFI ) using new pixel desktop...
when i happen to read about QT5
see also again a general intro at Wiki
so i decided to give it an other try.
first i check on my system ( mc / command / find file / *Qt*.* ) and find 77 files, most libQt5...
in forum... i got the idea that Qt5 is in repository so i ignore all the old info pages about building it on RPI, one info say it needs 2 days.
here i find the easy procedure
sudo apt-get install qt5-default ( 45MB more ) (ver: 5.3.2 )
sudo apt-get install qtcreator ( 209MB more )
qtcreator (from terminal or desktop menu ) remotely from XRDP ( windows remote desktop ) not start

qtcreator -noload Welcome gives despite error msgs a IDE window.

and from HDMI / Desktop:



but a new setup with the 2017-01-11-raspbian-jessie.img and not install XRDP
i now try about VNC, what now is installed by default,
-a- vncserver :1
does not ask for password any more
-b- in sudo raspi-config / interfacing options / VNC enable /
still not work after reboot, need via putty vncserver :1 again
i check at file
/usr/bin/raspi-config and find that VNC enable means
systemctl enable vncserver-x11-serviced.service &&
systemctl start vncserver-x11-serviced.service &&
STATUS=enabled

that does not the vncserver :1
check: usr/bin/vncserver is link to vncserver-virtual
so possibly still need the old autostart:
i make a file
sudo nano /etc/init.d/vncserver#!/bin/sh
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
# Description: Start VNC Server at boot time.
### END INIT INFO

# KLL
# /etc/init.d/vncserver
# Set the VNCUSER variable to the name of the user to start vncserver
VNCUSER='pi'
case "$1" in
start)
su $VNCUSER -c '/usr/bin/vncserver :1'
echo "vncserver started"
;;
stop)
/usr/bin/vncserver -kill :1
echo "vncserver stopped"
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac
exit 0

sudo chmod 755 /etc/init.d/vncserver
sudo update-rc.d vncserver defaults
( now there is no answer on this anymore )
sudo reboot to check if VNC starts


i install
sudo apt-get install qt5-default
sudo apt-get install qtcreator
but the help system not work good, local doc missing ( like examples ) and also links to QT homepage ( like tutorials ) end at 404 error.
( and operation slow, even i use RPI3 )
installing additionally
+ Qt5base private development files
+ debugging symbols
not work, need also
sudo apt-get install qt5-doc qtbase5-examples qtbase5-doc-html
to run example files / or start your own first program qt creator misses compiler!
tools / options
build and run / tab compiler
ADD GCC
path usr/bin/gcc
OK


just see a nice / but fast / tutorial video Introducing Qt Quick Controls in Qt 5.1


2e: PYTHON QT5
update 01/2017
now also experiment with PYTHON and QT5
nano PYQT5_test.py
#!/usr/bin/env python3
# IDLE2 IDLE3
#installs required for python2 python3
# sudo apt-get install python-pyqt5
# sudo apt-get install python3-pyqt5

# info http://pyqt.sourceforge.net/Docs/PyQt5/introduction.html

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

app = QApplication(sys.argv)


win = QWidget()
win.setGeometry(5,70,500,300)
win.setWindowTitle("Py Qt5 test")

line1 = QLabel()
line1.setText("Hallo World")
line1.setAlignment(Qt.AlignCenter)

vbox = QVBoxLayout()
vbox.addWidget(line1)

win.setLayout(vbox)

win.show()

sys.exit(app.exec_())

i know, that is old style code, now can find lots of examples in internet
using the self..... anyhow it runs,

2f: PYTHON QT5 QT QUICK (qml)
sudo apt-get install python-pyqt5.qtquick
sudo apt-get install python3-pyqt5.qtquick

play with my first QML file



3: TCL Tk
in a other forum info i read that RPI has installed minimum 12 languages ( also TCL mentioned )
lets get started to dig how to use it.
in /usr/bin/ find wish ( wish8.5) and tclsh ( tclsh8.5)
while wish already lets start you with a ready window frame, ( example )
tclsh is the tool to start your own GUI program
so in a pi subdir i write a small file
/home/pi/TCL_test/TCL_GUI.tcl #! /bin/env tclsh
package require Tk
# Create the main message window
message .m -text {Hello World} -background white
pack .m -expand true -fill both -ipadx 100 -ipady 40
# Configure the main window
wm title . { TCL_GUI.tcl }
and start it with
tclsh TCL_GUI.tcl

pls go
cd /usr/share/tcltk/tk8.5/demos/ and start
tclsh widget and try some, you will see how powerful it is and what good examples are prepared
like filemenu... , what i needed but not wanted to code by python pygame

update 01/2017
TCLTk 8.5 is out,
TCLTk 8.6 is installed for some tools only, the program i can not find anymore
also the demos are gone.
but after
sudo apt-get install tcl tk
tclsh works again:

play more with install and got the demo files too (sudo apt-get install tk8.6-doc),
but must change in widget file two times 8.5 to 8.6 ( or delete )
and all works again.
( working in XRDP window remote desktop terminal)

sudo apt-get install tk8.6-doc
cd /usr/share/tcltk/tk8.6/demos/
sudo nano widget
tclsh widget


for introduction to the language can start here


4a: C# GTK
now, as i already do the install of C# and MONO i wanted to give it a try about GTK...
oh, that was a long way for me!! but i not give up:

-- add installation
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mono-complete
sudo apt-get install gtk-sharp2

-- how to start a C# GUI program
using System;
using Gtk;

-- how to compile the exe
mcs C_sharp_GUI.cs -pkg:gtk-sharp-2.0
-- how to start the exe
mono C_sharp_GUI.exe
this GUI start also by the included .desktop file.
-+- so from the documentation that .EXE file should run on a windows PC, but when i try it did NOT.
but my desktop PC is very old.
-- GTK info / examples
/usr/bin/monodoc
go gnom libraries / Gtk
-- design tool // not recommendable on small RPI
sudo apt-get install monodevelop docu


4b: C C++ GTK
i can not repeat it often enough, this is a beginner blog, a log of my learning work on RPI
and i did not find a comprehensive GUI introduction on any of that languages, just check on many sites, fly over and read the commands they are using / i worry i am dead b4 i can read all that long text manuals /
and also C++, i never learned / used it, in a downloaded project for the RPI camera i remember i did a "make" one time ( and it worked ), without knowing what i am doing.
so today we want learn C++ in 3 easy steps:
- 1 - type code, compile, run
step 1 basics
1.1. create a source file:
nano C_++_NOGUI.cpp
content:
// C_++_NOGUI.cpp
#include <"iostream"> // do not use the "
using namespace std;

int main()
{
string hi = "Hello World";

cout << hi << endl;
return 0;
}

1.2. compile and make a executable C_++_NOGUI file
g++ -std=c++0x C_++_NOGUI.cpp -oC_++_NOGUI

1.3. start
./C_++_NOGUI

that works well!

- 2 - make a makefile and use make
2.1 create Makefile
nano Makefile , we use for start a project called mymain

#__________________________________
# KLL adapt default makefile for small example project
#This sample makefile has been setup for a project which contains the following files:
# main.h, ap-main.c, ap-main.h, ap-gen.c, ap-gen.h Edit as necessary for your project
#Change output_file_name.a below to your desired executible filename
#Set all your object files (the object files of all the .c files in your project, e.g.
# main.o my_sub_functions.o )
#OBJ = ap-main.o ap-gen.o
OBJ = mymain.o
#Set any dependant header files so that if they are edited they cause a complete re-compile (e.g.
# main.h some_subfunctions.h some_definitions_file.h ), or leave blank
#DEPS = main.h ap-main.h ap-gen.h
DEPS = mymain.cpp
#Any special libraries you are using in your project (e.g.
# -lbcm2835 -lrt `pkg-config --libs gtk+-3.0` ), or leave blank
#LIBS = -lbcm2835 -lrt
LIBS =
#Set any compiler flags you want to use (e.g.
# -I/usr/include/somefolder `pkg-config --cflags gtk+-3.0` ), or leave blank
#CFLAGS = -lrt
CFLAGS = -std=c++0x
#Set the compiler you are using ( gcc for C or g++ for C++ )
CC = g++
#Set the filename extensiton of your C files (e.g. .c or .cpp )
EXTENSION = .cpp
#define a rule that applies to all files ending in the .o suffix, which says that the
# .o file depends upon the .c version of the file and all the .h files included
# in the DEPS macro. Compile each object file
%.o: %$(EXTENSION) $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
#Combine them into the output file
#Set your desired exe output file name here
mymain.a: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
#Cleanup
.PHONY: clean
clean:
rm -f *.o *~ core *~
#__________________________________

pls note the rule for makefiles: there must be a TAB in front of commands:
this applies here for the 3 lines
$(CC) -c -o $@ $< $(CFLAGS)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
rm -f *.o *~ core *~
only. without the TAB ( even with spaces ) it should not work!
but here ( in HTML ) it not work even the TAB is in the blog source


2.2. we compile same source renamed to mymain.cpp by
make
2.3. and start with
./mymain.a

why in that example the extension .a was used for the resulting executable i not know,
but i don't like it as in desktop / filemanager its associated as "AR archive" i think will use ".app"

- 3 - try on GTK
now starts the real thing: and i see good info here
i could check with newly installed synaptic package manager and search libgtk
that a libgtk-3-0 , libgtk-3-0-bin, libgtk-3-0-common already is installed,
libgtk-3-0-dev and libgtk-3-0-doc not, so i follow that manual.
sudo apt-get install libgtk-3-dev
and with a example from here it runs, this one here not.

i hope this log text and the examples to download help anybody, just a short remark on today learning:
i actually do not know if i did a C program or a C++
and i wasted some hours to try to make the two texts ( program name and message text ) as string variables, like i did in the other examples.

- 4 - there is a step 4, as option i want test a recommended IDE
sudo apt-get install geany geany, geany-common suggested doc-base

i open a project, copy in the above makefile and .cpp source and [Build] [Make]
what i got is same as to type make in the terminal..
Ahmm, by the way, that IDE supports some languages..


4c: Code Blocks
update 23.8.2015, i see a other question how to use codeblocks
i found it is a IDE for C++, pls see here and here
i install with
sudo apt-get install codeblocks 25MB
comes up in Desktop menu/programming

i opened a new project type console project, got a ready code "hello world" build and run it ( easy with [F9] )


for some next steps with coding C++ see this C Tutorial: Learn C in 20 Minutes.
next i will do a GUI test too:
code::blocks / File / new / project / Projects ( from templates ) GTK+project
title: GTK_GUI_test /next / finish
under Sources / main.c have a lots of code already
build run [F9] : error with # include gtk/gtk.h fatal error file missing.
because i used a new system for that test i need to run again
sudo apt-get install libgtk-3-dev 61MB
but same error / reboot /
well, use the mc and search and find it /usr/include/gtk-3.0/gtk/gtk.h. under
/project / build options / Compiler Settings / Other option / i see 'pkg-config gtk+-2.0 --cflags'
what i think is part of the "make" file. So i change that option to 3.0
ok, now i get 45 error and 5 warnings ( should that be a progress? ) all about undefined reference, starting with the dialog line.
i check again at the / project / build options / compiler settings / other options / OK
but / project / build options / linker settings / other linker options / change 2.0 to 3.0 again



when i tried to open a QT4 project directly run into a error, so what i need? i try:
sudo apt-get install libqt4-dev qt4-dev-tools libqt4-declarative-fol
derlistmodel libqt4-declarative-gestures libqt4-declarative-particles libqt4-dec
larative-shaders qt4-qmlviewer firebird-dev libmysqlclient-dev libpq-dev libsqli
te0-dev libsqlite3-dev unixodbc-dev qt4-doc-html
400MB ( 100MB doc alone )
and when i now start code::blocks QT4 project i can point to
/usr/share/qt4 but still get error "can't locate library directory / this wizard can not continue"
well yes, there is no library folder there?? what is the QT SDK??
/usr/include/qt4 also not work.
see here but here
sudo apt-get install qtcreator 86MB more also
sudo apt-get install cmake kdelibs5-data subversion 27MB more, entry tutorial
no, still looks like code:blocks with QT4 is a little bit more difficult.


4d: perl GTK2
when i read that some pros. argue how bad python and how good perl is in RPI forum, i wanted to take a look on that too.
i have the problem that i work on a PLAY system what has seen many installs already,
so its difficult to say, but it looks like perl is installed with GTK2 already, so i start here.
ok, i was wrong, using a old SD card it "can't locate Gtk2.pm"
so you need to install it:
sudo apt-get install libgtk2-perl then it works



4e: java JDK 8
even i also never learned java, as i read about JDK 8 is installed in the new system? i check in terminal:
java -version 1.8.0 ...??
javac -version 1.8.0 ...??
in case you have a older system / or anyway / do:
sudo apt-get install oracle-java8-jdk
a path info get here
update-alternatives --list java shows me
/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/bin/java

i start to dig about easy "Hello World" beginner examples.
starting with the usual NOGUI version:
nano java_NOGUI.java
// The classic Hello World program!
class HelloWorld_NOGUI {
public static void main(String[] args) {
//Write Hello World to the terminal window
System.out.println("Hello World!");
}
}

compile it with
javac java_NOGUI.java
ls
and execute that made class
java HelloWorld_NOGUI
____________________________________________________
now we try GUI version, we will see if we need to install something...
nano java_GUI.java
import javax.swing.JOptionPane;
class HelloWorld_GUI {
public static void main(String[] args) {
JOptionPane.showMessageDialog( null, "Hello World!" );
}
}

javac java_GUI.java
ls
and execute that new made class
java HelloWorld_GUI

____________________________________________________
now as we have from a prior example ( C++ GTK ) already installed GEANY,
i try to use it for a step further into java.
i open a new project in GEANY: java180
and make a | file | new ( with template ) | main.java | file | save as | java_GUI.java



4f: Free Pascal / Lazarus
but i see something else what got my interest: LAZARUS

Link, Link, Link, Link, Link, Link, Link, Link, Link,

first try the old version as the update procedure is above my head:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fpc
here already BAD LUCK



i think i am lucky the install was refused. i will try again, on a new or older system.
sudo apt-get install lazarus not used.


update 7/2015 looks like LAZARUS still got some friends out there
on a new setup i try ( on a RPI1B ): ( for RPI2 see here )
to install free pascal and lazarus:
sudo nano /etc/apt/sources.list add line
deb http://plugwash.raspbian.org/wsf wheezy-wsf main
sudo apt-get install fpc ( 170MB more / 15min)
sudo apt-get install lazarus (512MB more / 18min)

and my Hello World with lazuras from here
when i open lazarus in Desktop i get 5 windows. i do
project / new project / application / OK and all 5 window freeze ... must reboot
i had many problems to edit the label and window caption and change position and size by number input, ( resizing by graphic / mouse worked fine ) ( working headless problem?)


for understanding, there was actually no coding required, i selected and positioned the label object,
typed a label text /caption "hello world", typed the window caption (=filename), saved project as hello_world
the executable is 15MB! what a mess, i deleted it from the zip, so also icon.... will not work
more info possibly here


5.a RUBY
in a terminal i type:
ruby -v
and see ruby 1.9.3.. so its installed already
rails -v error
or apt-cache search ruby | grep rails show packages
i try: sudo apt-get install rails and now
rails -v rails 2.3.14
i do according this, not sure i need it.
sudo gem install execjs give execjs 2.5.2 and documentation
sudo apt-get install nodejs actually a java runtime is available?
and the test described there i also try:
rails new peopledb get long list of creates
cd peopledb that not work, but there is a new subdir "new" now
cd new
rails g scaffold people name:string group:string again get that create list??
rake db:migrate error aborted can not load such file sqlite3
rails s get the list again Grrrr!

use browser
http://0.0.0.0:3000/people
well: that could not work now anyhow
today not so lucky

from rpi mama
no info at all what it is and how to use it??
sudo apt-get install rubygems
sudo gem install jekyll
after some search i found: Jekyll is a simple, blog aware, static site generator.
RPI1 hangs at cpu 100% and i wait
after ? half hour.. error installing jekyll failed to build gem native extension
so again not lucky to day
but do not think i give up so easy: follow this here
and this time go the long way
sudo apt-get install -y git curl zlib1g-dev subversion
sudo apt-get install -y openssl libreadline6-dev git-core zlib1g libssl-dev
sudo apt-get install -y libyaml-dev libsqlite3-dev sqlite3
sudo apt-get install -y libxml2-dev libxslt-dev
sudo apt-get install -y autoconf automake libtool bison
curl -L get.rvm.io | bash -s stable --rails
stop here at step 4 , problem with keyring....
source ~/.rvm/scripts/rvm not try

another one
sudo gem install rails --include-dependencies
error unable to resolve deendencies
and at test again complain sqlite3??

after get key for rails
sudo gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
and do sudo su
follow this:
curl -L get.rvm.io | bash -s stable --rails seems to run and get
rvm 1.26.11
ruby 2.2.1 extract config compile install executable...
ruby-gems 2.4.8 error fechting gems
this was after about 2 hours, start again
possibly need rvm reinstall ruby-2.2.1 but looks like he goes on with fetching some gem files
building native extensions ....
installing lots of documentation and i notice i not know how i call up documentation in linux? is there a general help system, or is it only the command line thing "command --help" and "man command" ? one of the many black holes in my not linux brain. but, as the online documentation is not that easy to access by RPI's slow browser, ( i only use the PC for this ) it would be good to know.
RPI already hangs half hour at a rails 4.2.3 documentation, next morning ( min 4 hours more ) OK
source /usr/local/rvm/scripts/rvm
ruby -v 2.2.1
rails -v 4.2.3
gem install execjs ( 1 gem installed )
apt-get install nodejs ( ok )
exit ( of sudo su ) now do the test:
rails new tutorials ( i deleted the old one first, test with sudo su and without
but i get again a subdir new! delete,
after close terminal ( putty ) and open again, ( no sudo su )
rails new tutorials i see now a: run bundle install ( 5 min )
bundle complete, bin/rake, bin/rails
cd tutorials
rails g scaffold Steps name:string form:string get create invoke list
rake db:migrate create Steps...
rails server (info run server -h shows options / stop with CTRL C...
HTTP server start pid=xxxx port=3000/ there it hangs ( without prompt ))
i start desktop, start browser
http://localhost:3000 ( i did not test from outside http:192.168.1.101:3000 )

close browser, [ctrl][c] in terminal

long long way,but today is a better day!

just to verify i try that thing from Raspberry Pi website again
sudo gem install jekyll
and again look at the dead black screen
25min later, same error


for ruby GUI i want test Shoes, take a glimpse here
but the installation? he use a RPI2 on ruby 1.9.3
the download page give me a 13.6MB shoes-3.2.23-gtk2-armhf.install , no idea what to do with it!
for building it Link
here they say :
On Linux, you'll download a file ending with .run. Double-click this file and Shoes will start up. (You can also run this file from a prompt as if it was a shell script. In fact, it is a shell script!)
so i make a
mkdir /home/pi/Shoes/ and copy that install file from PC, just a try!
in a desktop try double click but only the editor opens. so use a terminal
cd Shoes
ls
chmod +x shoes-3.2.23-gtk2-armhf.install
./shoes-3.2.23-gtk2-armhf.install uncompressing

says if Shoes not in menu must logout login ( i do a reboot anyhow)
i make a
nano /home/pi/GUI_test/ruby_shoes/shoes_GUI_test.rb start the shoes program / open APP / find my file / OK


you might think that after last night i value that SD card with the ruby n rails installation
well the shoes thing was fun, the ruby rails version thing not, i zip my GUI_test pack and upload to here so its available to you.
i format SD and burn a raspbian ( still 2015.05.05 is the "newest" )
the SD was anyhow nearly full??
i do now always ( from PC) the cmdline.txt MOD [blank]ip=192.168.1.101
and boot headless.
and why i write about that here? i try
ruby -v 1.9.3
i copy the Shoes install again ... download the GUI_test again

Ha!


5.b ICON
a new friend from a german RPI forum thinks that a GUI programming introduction ( or overview type tutorial ) is worthless ( and i know my BLOG is even far from a tutorial ), because for each package and language need deep tutorials, and for searching about RPI languages he give me the LMGTFY, means everyone has to search and end up at the old dead links like it always happens to me. but, as he writes a 500 pages tutorial about a language called ICON
he recommends that i included it here and link to his manuals.
at first i had some bad time exactly about googling, you try and find ICON in google, very funny.
what i have until now: german international forum intro, first 6 pages of that 500 manual, update from a forum thread and the official ICON homepage and wiki books and the Introduction.
for a first start i fly over the Language reference and from there directly to the GUI book page 83.
on the first look it seems that its a language what is very forgiving, like can use ";" or not,
can write WAttrib("fg=white","bg=black") or Fg("white") Bg("black")
but i also see array pointer start with 1, not with 0, [0] is the last member of a array, even -1, -2, is possible as last but one...
that has its logic but if you are used to think in [0] .. length(array) UMPF.
and my arduino #define here is $define ...

now i try to setup it up on my old RPI1B ( how about RPI2? )
from the above manual i find in Tab. 1-1
( i try 2 different pdf viewer ( on my win7 PC ) and both give me a hard time about COPY PASTE ( to putty ) ? i need to type that? )
mkdir /home/pi/Downloads
cd /home/pi/Downloads
wget www.cs.arizona.edu/icon/ftp/packages/unix/icon­-v951src.tgz
tar ­-x ­-v ­-f icon­-v951src.tgz
mkdir /home/pi/icon9_51
mv ­-v -r icon­v951src/* /home/pi/icon9_51
sudo apt-­get install build­essential libx11­dev libxt­dev libxaw7­dev
cd /home/pi/icon9_51
dir
( DOS lover? )
i try:

sudo apt-get update
sudo apt-­get install build­-essential libx11­-dev libxt­-dev libxaw7-­dev (21 MB more)

wget www.cs.arizona.edu/icon/ftp/packages/unix/icon­-v951src.tgz ( 3MB 13sec)
tar ­-xvf icon­-v951src.tgz get a subdir icon­-v951src
rm icon­-v951src.tgz delete the zip agian
mv icon­-v951src icon­9_51 rename that dir

cd /home/pi/icon9_51/config/
cp ­-v ­-r linux RaspberryPi
cd RaspberryPi

nano define.h and add line after UNIX
#define RaspberryPi 1
( no need ) nano Makedefs
( no need ) nano status

cd /home/pi/icon9_51/
make X-­Configure name=RaspberryPi
make X-­Configure=RaspberryPi ( 9 min ) nice line by line progress report
make status=RaspberryPi
make Icont
make Samples
make Test
make Benchmark

cd
nano /home/pi/.bashrcecho "add PATH to Icon"
PATH=$PATH:/home/pi/icon9_51/bin
echo $PATH
export PATH
echo "set IPATH"
IPATH="/home/pi/icon9_51/lib/home/pi/icon9_51/ipl/cfuncs/home/pi/icon9_51/ipl/packs/loadfunc/home/pi/icon9_51/ipl/packs/loadfuncpp"
echo $IPATH
export IPATH
echo "set LPATH"
LPATH="/home/pi/icon9_51/ipl/gincl/home/pi/icon9_51/ipl/gprocs/home/pi/icon9_51/ipl/incl/home/pi/icon9_51/ipl/procs"
echo $LPATH
export LPATH
echo "set FPATH"
FPATH="/home/pi/icon9_51/ipl/packs/loadfunc/home/pi/icon9_51/ipl/packs/cfuncs/home/pi/icon9_51/ipl/packs/loadfuncpp"
echo $FPATH
export FPATH

sudo reboot
error in LPATH,IPATH,FPATH again about too many " " from the copy. ok again
as there is no IDE included ( can use Geany )
there are no new desktop menu icons..., its just a compiler.

first test direct:
cd /home/pi/icon9_51/bin
nano hello.icn
procedure main()
write(“Hello World“)
end
icont hello compile ok
iconx hello run ok ( use also just hello )
nano hello_window.icn
link graphics
procedure main()
WOpen("label=hello_window.icn")
WWrite("Hello World")
WDelay(10000)
WClose()
end ( that's missing in the manual )
icont hello_window compile ok
now for the start we need a desktop window ( i use headless RDP )

first i # all the echo from the ICON path thing in the above /home/pi/.bashrc
then i move the hello* out of /bin/ to my home/pi/GUI_test/icon_test/ and icont, iconx runs here well too.
thanks @andreas
p.s. put the SD in a RPI2 and icont and iconx run ok ,
but that not say that the build would run same, but not tested.


6: Python use gtk together with PYGAME, Tkinter
somehow we get used to that a file open dialog can look different on every computer / operating system / program...
but its not only a question of HMI, easy learning,
also we don't want to take the developers freedom to build something new and better,
but operation AND coding operation should be easy!
but lets face it, modular thinking and object oriented programming was last millennium , now we do APPs.
i had the question for a easy file open dialog when using python pygame
( due to the fact that my MIDI server from Arduino USB and the keyboard already works from pygame, i think i am stuck with pygame / i never say i liked it )
now for Tkinter ( good tip from Forum ) AND for gtk there is a ready dialog, i tested both and see
the Tkinter one looks like the python IDLE file open, the gtk looks like the PCManFM file explorer.
For pygame there are also projects ( also tip from forum ) working on GUI things,
here but that might be a longer way ( how to install.. )
so i started with the existing libs, the gtk dialog works from gtk window,
but the gtk call from inside pygame i got opened ( and file selected) but could not close it.
some command / or program structure missing.
frustrated i was thinking of a way, where i not have to combine 2 GUI versions and came up
with the idea to do 2 separate programs, what can communicate by a RAM DISK File.
so any program ( not only python pygame or python Tkinter ) can spawn ( subprocess )
"python fileopenwindow.py" a stand alone program, and after finished ( by window closed, cancel button, or any file select double click or open button ) the info can be fetched from the RAM DISK file.
and for that i made a example for pygame and tkinter with a button [search] what does the spawn
( gtk file dialog pop up window ) and writes the result ( !open / you should never see because with subprocess main waits/, !error, !close, !cancel, /path/filename ).
later a user will not know the difference / what GUI was used / and as we have a manual / mouse interaction there can not be any time delay questions for using a intermediate file.


as the result also is available in the terminal with sysexit(filename) the file thing is not really needed,
but catching it from that 50 lines of warnings is bad stuff.
for me the add Tkinter example was only a hour, just to show you are free to choose the ready dialog.


Actually as for the first GUI test i used also C# mono ( but that has gtk lib ) and TCL ( possibly use Tk ) more testing is possible.


7: GUI design tools
i started with saying, raspberry pi is a programming learning tool and
it is ready to start right away using python ( Tkinter, GTK, PyGame ) for learning GUI programming.

there is always a next step:
from working CLI nano making program code
using desktop texteditor leafpad
or already a IDE GEANY what is good regarding "projects" and is a good language editor
but for making GUI programs there is a "upper" level, a GUI design tool.
C _ GLADE _ GEANY example
what i hear at the forum the logical step would be to install GLADE see here and here
its all about windows, actions, widgets and their attributes, for the GTK ONLY.
sudo apt-get install glade



i try my window with a label "Hello World" and saved as *.glade ???

now what? here i see a easy "second" step.
and i copy his example code in a GEANY project / there i store the .glade too and a copy of Makefile changed to the filename / switches
but a compile give a error about #include No such file or directory
hmm, in Cpp it worked ( on this SD / system /), but well, its my first C program ever
sudo apt-get install libgtk-3-dev NO, that was installed already
i did not get the (Makefile) make running, but at CLI it worked
gcc -Wall -g -o C_GLADE.app C_GLADE.c $(pkg-config --cflags gtk+-3.0) $(pkg-config --libs gtk+-3.0)
start with
./C_GLADE.app



more see desktop and menu system


10: get all the code examples
code from the download area

rev 0.1 incl 2a python Tkinter, pygame, matplotlib, gtk
rev 0.2 incl 2a test PY GTK and 3 TCL TK
rev 0.3 incl 4a C# GTK example
rev 0.4 incl 6 GTK fileopenwindow.py and pygame and Tkinter usage example
rev 0.5 incl 4b C++ GTK example
rev 0.6 incl 2b python WX example
rev 0.7 incl 4c perl GTK2 example
rev 0.8 incl 4d java example
rev 0.9 incl 7 C, GLADE, GEANY example
rev 1.0 update and check from new system ( download or mget )
rev 1.2 update to a tar.xz pack what is more easy on RPI
and keeps all file settings. also recheck all desktop files regarding subdir.
rev 1.3 incl Lazarus, free pascal test ( no exe )
( and the raspi-config icon from forum and the sulxterminal in /KLL)
rev 1.4 now the service_GUI is included in the same pack
rev 1.5 menu tree
rev 1.6 code blocks
rev 1.7 QT5 / pyQt5 / pyQT5_Quick

the *.desktop files i copy again to subdir /home/pi/GUI_test/KLL/, what could be moved / or symlinked to /home/pi/Desktop/...