wxerlang workups

.. samples to learn from

  • Increase font size
  • Default font size
  • Decrease font size
wxerlang workups

What's this about?

E-mail Print PDF
 
 
This tutorial demonstrates how to build a graphical front end for Erlang code, using the wxErlang interface. There are three groups in the tutorial.  The first group (wxcdXX)  builds a window with text entry and buttons, using a loop model to maintain state.  Start there if you are new to wx.   Try the code for yourself, at each step. Make little changes to see what happens.
 

For Registered Users:
 
The second group shows how to build some non-widget graphics using 'device contexts'. The last example in that group draws an angle (in degrees) in a circle, based on the number entered by the user in the text box. 
 
The third group demonstrates using the wx_object 'behaviour' model to connect to the wx server.  I've isolated the radio buttons module from wx:demo() as a stand alone module and documented the key aspects of that approach. 
 
Registration is free.  The only reason for asking for registration info, is so that if there are changes to the site, I can let you know about them.  

 
Can't get wx to work on your OS?  Read this section, and if you still have problems, sign up for the erlang-questions mailing list (sign up info on the Erlang site) and post your problem there.
 
First: Find out if if wx is working on your system, type wx:demo() in the shell.
 
If you receive an error message like this: 
 
WX ERROR: SMP emulator required{error,{not_smp,[{wxe_server,start,0},
                 {wx,new,1},
                 {demo,init,1},
                 {wx_object,init_it,6},
                 {proc_lib,init_p_do_apply,3}]}}
 
you need to turn smp on.  One way to turn on smp is to start erl / werl with the switch  -smp (In windows, create a shortcut for "werl -smp"). Another way is to set an environmental variable ERL_FLAGS=-smp, through system settings.
 
Running on Ubuntu Linux (Linux Mint): 
 
1) get the source code tar.gz file from erlang.org:
 
2) Read the install.md file
 
3) try sudo ./install
if it works with no error messages, then make, make install
 
4)  if there are issues, look at this site:
http://boris.muehmer.de/2011/05/07/installing-erlangotp-r14b02-on-ubuntu-11-04-from-source-tarball/
 
5)  run this code to add missing pieces:
sudo apt-get -y install \
        build-essential m4 libncurses-dev \
        libssh-dev unixodbc-dev libgmp3-dev \
        libwxgtk2.8-dev libglu-dev \
        fop xsltproc default-jdk
6) Get coffee because this next part takes a while:
 
sudo ./install
sudo make
sudo make install
 
7) looking good, now run erl in a terminal

(your_shell_id)>> erl

Erlang R15B (erts-5.9) [source] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9  (abort with ^G)
1> wx:demo().

It works for me!!

(May  or may still be valid) The Erlang rpm packages available for Fedora include the files needed for wx. I suggest you contact the erlang-questions mailing list if you have a problem getting wx to work with your installation.  

 
 

 
To contact me by email at this address:  Start with the site name
"wxerlang.dougedmunds.com", take off the wxerlang. , then take off the .com, then add @gmail.com after what's left.  (If that triggers spam, I give up).
 
-- Doug Edmunds
 
You may distribute this tutorial  for learning purposes, but may not include it in a commercial publication unless permission has been granted. If you copy this, please give credit where credit's due.