However, when installing from source, several packages need to be installed manually. The build would complete, but running gladevcp programs or editing glade files might fail otherwise. To pull in these packages, execute the following:
$ apt-get install python-gnome2 python-glade2 python-numpy python-numpy python-imaging python-xlib python-gtkglext1 python-configobj gtksourceview2
Download, build and install emc2 master as per instructions at Installing EMC2 on Ubuntu 10.04 from source.
You have either to fetch current development version using git or install packages from
[buildbot]
To create new UI components, you will need at least version 3.6.7 of glade (stock on Ubuntu 10.04):
sudo apt-get install glade
To determine wether your gladevcp is up to date, run it as 'gladevcp -h'. if the usage message says it supports a '-H halfile' option, you're good to go.
On older systems, Gladevcp files that have been made with Glade 3.6.7 can be displayed on systems with older versions of Glade (eg Ubuntu 8.04)
But you can't edit and won't see the HAL objects using Glade.
If anyone wishes to donate more or needs help building new HAL widgets lets us know on the EMC Maillist.
$ cd emc2-dev/lib/python/gladevcp $ gladevcp gladevcp-test.uiIf you have no EMC user interface like Axis or Touchy running, you might have to start the realtime extension beforehand so gladevcp may create a hal component :
$ sudo /etc/init.d/realtime restartThis might also be needed if your gladevcp application terminated abnormally and left an active HAL component 'lying around' in which case you'll get a 'HAL comonent already exists' error on the next run. This command should not be needed when running in simulator mode.
A new window with several leds and buttons should come up like so:
Note also that a HAL component gladevcp-test with several pins has been created.
Either modify an existing UI component, or start a new one with running glade. In the left tab, expand the 'HAL Python' components. Create a Window as top level window from the 'Toplevels' section (first icon), which by default will be named window1. Leave that name as is - gladevcp assumes the top level window has this name. Add a HAL_Box or a HAL_Table from 'HAL Python' to the frame, and pick and place some elements like LED, button etc in its box.
This will look like so:
Select File->Save as, give it a name like 'myui.ui' and make sure it's saved as 'GtkBuilder' file (radio button left bottom corner in Save dialog). The convention for GtkBuilder file extension is '.ui'. You can now run it with:
$ gladevcp myui.ui
The recommended way of starting a gladevcp embedded tab is as follows: Edit your .ini file and add two variables to the DISPLAY section of ini file:
EMBED_TAB_NAME = GladeVCP EMBED_TAB_COMMAND=halcmd loadusr -Wn gladevcp-test gladevcp -c gladevcp-test -x {XID} gladevcp-test.glade
Note the 'halcmd loadusr' way of starting the tab command - this assures that POSTGUI_HALFILE will only be run after the HAL component (in this case gladevcp-test) is ready. In rare cases you might run a a command here which uses a tab but does not have an associated HAL component. Such a command can be started without 'halcmd loadusr', and this signifies to Axis it doesnt have to wait for a HAL component since there is none.
Try it out by running Axis - there should be a new tab called 'GladeVCP' near the DRO tab. Select that tab, you should see the example panel nicely fit within Axis like so:
(Note that my setup still runs a PyVCP panel on the right which is a bit of an overkill but I havent migrated yet).
You can achieve this by simply specifying the following in the DISPLAY section:
GLADEVCP=myapp.ui
An application started through the GLADEVCP option is slighty different from an EMBED_TAB_COMMAND:
This means you can add arbitrary gladevcp options here, as long as they dont collide with the above command line, so it could also read:
GLADEVCP= -d -u myhandlerfile.py myapp.ui
Touchy also understands EMBED_TAB_NAME/EMBED_TAB_COMMAND variables from INI file so instructions for it are equal to Axis. Touchy currently does not have an equivalent to GLADEVCP in Axis.
Provided you start you EMBED_TAB_COMMAND as outlined above, or use the GLADEVCP option, you can execute all HAL commands in POSTGUI_HALFILE.
For the above EMBED_TAB_NAME and GLADEVCP examples, add the HAL statements from lib/python/gladevcp/gladevcp-test.hal to your POSTGUI_HALFILE. Note that in the GLADEVCP case, the component will be forced to the name 'gladevcp' so you will have to rename the component part in ths HAL file from gladevcp-test to gladevcp .
gladevcp cannot only manipulate or display HAL pins, you can also write regular event handlers in Python. This could be used, among others, to execute MDI commands. Here's how you do it:
Write a Python module like so and save as e.g. handlers.py:
nhits = 0
def on_button_press(gtkobj,data=None): global nhits nhits += 1 gtkobj.set_label("hits: %d" % nhits)
In glade, define a button or HAL button, select the 'Signals' tab, and in the GtkButton properties select the 'pressed' line. Enter 'on_button_press' there, and save the glade file.
Then add the option '-u handlers.py' to the gladevcp command line. If your event handlers are spread over several files, just add multiple '-u <pyfilename>' options.
Now, pressing the button should change its label since it's set in the callback function.
What the -u flag does is: all Python functions in this file are collected and setup as potential callback handlers for your Gtk widgets - they can be referenced from glade 'Signals' tabs. The callback handlers are called with the particular object instance as parameter, like the GtkButton instance above, so you can apply any GtkButton method from there.
Or do some more useful stuff, like calling an MDI command!.
Usage: gladevcp [options] myfile.ui
Options: -h, --help show this help message and exit -c NAME Set component name to NAME. Default is basename of UI file -d Enable debug output -g GEOMETRY Set geometry WIDTHxHEIGHT?+XOFFSET+YOFFSET. Values are in pixel units, XOFFSET/YOFFSET is referenced from top left of screen use -g WIDTHxHEIGHT? for just setting size or -g +XOFFSET+YOFFSET for just position -H FILE execute hal statements from FILE with halcmd after the component is set up and ready -m MAXIMUM Force panel window to maximize -t THEME Set gtk theme. Default is system theme -x XID Reparent gladevcp into an existing window XID instead of creating a new top level window -u FILE Use FILEs as additional user defined modules with handlers -U USEROPT pass USEROPTs to Python modules
This page is current per December 2010. Authors Michael Haberler and Pavel Shramov .