Historical eugtk, Revision 94
Overview
EuGTK is a complete and up-to-date* Euphoria 4.1 wrapper for the GTK3 GUI (graphic user interface) for Linux, Windows, and OS-X. Euphoria 4.1 is required, earlier versions 3.x and 4.0 do not work.
- All GTK3 widgets are wrapped, and up-to-date with the latest version of GTK3 - currently 3.22.26, Nov 15, 2017). GTK is also one of the few GUI packages that is under continuous development and updating.
Euphoria/GTK code is much simpler and easier to understand than similar libraries for other programming languages.
EuGTK uses a pseudo object oriented approach, and many difficult or complex GTK3 functions (such as creating and using a ListView) have easier-to-use alternatives implemented in Euphoria. More than 250 test programs are provided as examples, along with ample documentation in html form to help you get up and running.
History
Built on an original concept by Dave Cuny, with help from Mike Sabal, Ron Tarrant, and others. It is currently maintained by Irv Mullins.
Platforms
EuGTK runs on Linux, Windows, and OSX. In most cases, the same source code can run on all three platforms without change.
The latest EuGTK version can be downloaded from http://sites.google.com/site/euphoriagtk/Home
On the Linux platform, EuGTK uses the GTK3 libraries which are installed by default with current Linux distros such as Mint or Ubuntu, etc...
EuGTK on Windows requires the appropriate GTK libraries for Windows. Apparently, only 64-bit versions are now being maintained. A link to the current 3.22 version is included in the pdf which comes with the EuGTK package.
For OSX, you must install the gtk3 package with MacPorts
Raspberry Pi 3 installation instructions are found at the bottom of this page.
Simple program in EuGTK:
Notice how few keywords you need
- create - declares a new, unique instance of a GTK object (a.k.a. 'widget')
- add - puts 'widgets' into container, sharing available space equally
- pack - puts 'widgets' into container, using only as much space as required
- show/show_all - instantiates created widget instances
- main
- enters the GTK main loop,
- waits for user activity (called 'events')
- and calls your Euphoria function(s) which you have connected to that event
- set - set one or more properties of a widget
- get - read the value or status of a widget property
More complex and useful
Above program, called BEAR (for Browse, Edit, and Run), edits and runs EuGTK programs, and is an excellent and productive web page html/css editor/viewer as well. This complex program is just over 900 lines of code, in only one file. The equivalent if written in C would involve dozens of files and thousands of lines of code. (Linux only at this time)
Installing on Raspberry Pi 3 with Raspbian
Follow the links on the Downloads page to download:
- EuGTK
- Arm binary for manual installation
- Wee
Download the latest EuGTK, and click on the tar.gz file, read the important note, then drag the demos folder into your home folder. You'll now have a /home/pi/demos folder.
Download euphoria-4.1.0-ARMv6-hardfloat-5.tar.gz Click on it, and extract to, let's say, your home folder.
Go to your home folder, and open a terminal to copy some files:
cd ~/euphoria-4.1.0-ARMv6-hardfloat/bin sudo cp * /usr/bin cd .. sudo mkdir /usr/share/euphoria sudo chmod 777 /usr/share/euphoria sudo rm /usr/bin/eu.cfg cp -r * /usr/share/euphoriaConfirm that eui is installed:
pi@raspberrypi:~ $ eui Euphoria Interpreter v4.1.0 development 32-bit Linux, Using System Memory Revision Date: 2015-02-02 14:18:53, Id: 5861:57179171dbed ERROR: Must specify the file to be interpreted on the command line(So far, so good!)
Replace /usr/bin/eu.cfg with the following: (will probably have to use sudo nano here)
[all] -eudir /usr/share/euphoria -i /usr/share/euphoria/include [translate] -arch ARM -gcc -con -com /usr/share/euphoria -lib-pic /usr/share/euphoria/bin/euso.a -lib /usr/share/euphoria/bin/eu.a [bind] -eub /usr/share/euphoria/bin/eub
Check that it works
cd ~/demos
eui test0
Should take a few seconds, and then show the window.
Install WEE
Download WEE-master.zip Use archiver to extract to /home/pi (or /home/your_user_name)
Associate .ex files
Use file manager to navigate to ~/demos right-click on test0.ex select Properties from the popup window Select Open With -> Customize Click on Custom Command Line enter eui as Command line to execute: Enter Euphoria as the Application name click OK
Double click on an .ex program to see if it works.
Trouble Shooting
If you get a long warning re: accessibility, add the setenv line to GtkEngine.e as shown below:
export constant version = "4.12.2", release = "Feb 1, 2017", copyright = " © 2017 by Irv Mullins" setenv("NO_AT_BRIDGE","1") -- add this line here
Notes
The Raspberry Pi 3 is a bit slow, so binding your Euphoria programs is helpful. Especially WEE and other programs you will use frequently.
Translating and compiling large EuGTK programs on the Pi is also rather slow, so you may prefer to cross-compile on a full-size PC, and then copy the executable to the Pi.
- Check this forum message: Cross Compile
- Or this wiki page: Cross Compile
In newer 64-bit versions of Linux, the GTK3 libraries are not in /usr/lib, but in /usr/lib/x86_64-linux-gnu/. These should be linked automatically, and found by EuGTK without a problem, but if for some reason they are not, you can make a symbolic link:
ln -s /usr/lib/x86_64-linux-gnu/libgtk-3.so.0 /usr/lib
On Linux/32-bit, the latest eubins fail to work with this library. This is an interpreter problem and not a problem with the library itself. See ticket #933.
If the demos fail with cannot find test1.ex or something, it is because when the documentation says install to the home directory it really means you must install it there.
Temperature monitor for RPi
include GtkEngine.e constant win = create(GtkWindow,"title=°,background=black,size=200x100,border=2,$destroy=Quit"), lbl = create(GtkLabel,"color=green yellow"), tick = create(GTimeout,1000,_("read_temps")) add(win,lbl) show_all(win) main() --------------------- function read_temps() --------------------- system("vcgencmd measure_temp > GPU_TEMP",0) system("cat /sys/class/thermal/thermal_zone0/temp > CPU_TEMP",0) object gpu_t = read_file("GPU_TEMP") gpu_t = to_number(gpu_t[6..9]) object cpu_t = read_file("CPU_TEMP") cpu_t = to_number(cpu_t[1..$-1])/1000 set(lbl,"color","green yellow") if cpu_t > 60 or gpu_t > 60 then set(lbl,"color","yellow") end if if cpu_t > 80 or gpu_t > 80 then set(lbl,"color","red") end if set(lbl,"markup",text:format("CPU temp=[:4.1]°C\nGPU temp=[]°C",{cpu_t,gpu_t})) return 1 end function
- diff to current revision, view current revision history, backlinks
- Last modified Jan 08, 2018 by irv