Difference between revisions of "CEGUIPython"

From CEGUI Wiki - Crazy Eddie's GUI System (Open Source)
Jump to: navigation, search
m (make CEGUI's name consistent across the wiki)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{VersionBadge|0.5}} {{VersionBadge|0.6}}
 +
 +
{{notice|message=For CEGUI 0.7 and above, you are recommended to use [[PyCEGUI]]}}
 +
 
= Introduction =
 
= Introduction =
  
Cegui has a really nice set of python bindings that can be used to script your interfaces using this nice language. The python bindings where originally created for project [http://www.projectxenocide.com/ Xenocide], and its main authors are guyver6 (main developer) and reist (build system and adapting for new cegui versions).
+
CEGUI has a really nice set of python bindings that can be used to script your interfaces using this nice language. The python bindings where originally created for project [http://www.projectxenocide.com/ Xenocide], and its main authors are guyver6 (main developer) and reist (build system and adapting for new cegui versions). Latest releases and small tweaks for compiling against cegui 0.6+ by caedes.
  
 
= Downloading =
 
= Downloading =
Line 7: Line 11:
 
== Release ==
 
== Release ==
  
You can get the released package for cegui 0.5:
+
You can get the released package for cegui...:
[http://b2cs.delcorp.org/files/CEGUIPython-0.5.0.tar.gz CEGUIPython-0.5.0.tar.gz]
+
 
 +
0.5: [http://b2cs.delcorp.org/files/CEGUIPython-0.5.0.tar.gz CEGUIPython-0.5.0.tar.gz]
 +
 
 +
0.6.1: [http://b2cs.delcorp.org/files/CEGUIPython-0.6.1.tar.gz CEGUIPython-0.6.1.tar.gz]
 +
 
 +
0.6.2: [http://b2cs.delcorp.org/files/CEGUIPython-0.6.2.tar.gz CEGUIPython-0.6.2.tar.gz]
  
 
== SVN/CVS ==
 
== SVN/CVS ==
 +
 +
'''THIS SOURCES ARE NO LONGER AUTHORITATIVE, GET THE CODE FROM THE RELEASES DIRECTLY'''
  
 
The cegui python script module can be downloaded from cegui cvs using the following commands:
 
The cegui python script module can be downloaded from cegui cvs using the following commands:
Line 78: Line 89:
 
= Documentation =
 
= Documentation =
  
There is not yet proper documentation for the cegui python bindings, but there is an api reference at http://delcorp.org/caedes/pyceguidoc (without the method descriptions yet, but can help to find out what a method name could be). Other than this for now you have to refer to the main cegui documentation.
+
There is not yet proper documentation for the cegui python bindings, but there is an api reference at http://delcorp.org/~caedes/pyceguidoc (without the method descriptions yet, but can help to find out what a method name could be). Other than this for now you have to refer to the main cegui documentation.
 +
 
 +
[[Category:Manuals]]

Latest revision as of 23:05, 3 March 2011

Written for CEGUI 0.5


Works with versions 0.5.x (obsolete)

Written for CEGUI 0.6


Works with versions 0.6.x (obsolete)


For CEGUI 0.7 and above, you are recommended to use PyCEGUI


Introduction

CEGUI has a really nice set of python bindings that can be used to script your interfaces using this nice language. The python bindings where originally created for project Xenocide, and its main authors are guyver6 (main developer) and reist (build system and adapting for new cegui versions). Latest releases and small tweaks for compiling against cegui 0.6+ by caedes.

Downloading

Release

You can get the released package for cegui...:

0.5: CEGUIPython-0.5.0.tar.gz

0.6.1: CEGUIPython-0.6.1.tar.gz

0.6.2: CEGUIPython-0.6.2.tar.gz

SVN/CVS

THIS SOURCES ARE NO LONGER AUTHORITATIVE, GET THE CODE FROM THE RELEASES DIRECTLY

The cegui python script module can be downloaded from cegui cvs using the following commands:

cvs -d:pserver:anonymous@crayzedsgui.cvs.sourceforge.net:/cvsroot/crayzedsgui login
cvs -z3 -d:pserver:anonymous@crayzedsgui.cvs.sourceforge.net:/cvsroot/crayzedsgui/ co -P ceguiaddons/PythonScriptModule/ScriptingModules/CEGUIPython

Note if you have some problem there is the Xenocide svn where ceguipython is usually first fixed, you can get it also from there by using svn tools:

svn co http://svn.projectxenocide.com/xenocide/trunk/cegui/ScriptingModules/CEGUIPython CEGUIPython

Then to build and install you would go to the CEGUIPython folder, and do the following commands:

Installing

bash bootstrap (only needed the first time if you got the package from cvs/svn, to generate some files)
./configure
make
make install (you'll need root/admin privileges for this)

Also note you might need to regenerate the bindings using swig if you need to link with a 3d party library python bindings (as all swig generated modules must be generated using the same version of swig so they can work together).

The build system does not yet detect a different swig version, so you need to trick it to think the main interface file has changed so it will be rebuilt:

touch package/cegui.i
make
make install

Using

The bindings are pretty extensive and allow to access most of cegui functionality.

Syntax

In general the api is the same as cegui's, but all get/set methods are translated into python attributes, as illustrated in the following (simple) example:

c++

float max = slider->getMaxValue();
slider->setMaxValue(max+1);

python

max = slider.MaxValue;
slider.MaxValue = max+1;

Creating Windows

As usual in cegui you create windows by using the cegui window manager:

slider = winMgr.createWindow("ice/Slider","Demo7/Window/Slider9")

Subscribing to events

You can set python functions to respond to different interface events

slider.subscribeEvent(cegui.Slider.EventValueChanged,onSlider)

Then, at the event callback you get an args parameter, that will be of a different type depending on the kind of event, you can check the type by printing the object if you're not sure.

def onSlider(args):
       print args # shows in this case this is a cegui.WindowEventArgs
       w = args.Window
       val = w.CurrentValue
       print w.Name,"received",val

Documentation

There is not yet proper documentation for the cegui python bindings, but there is an api reference at http://delcorp.org/~caedes/pyceguidoc (without the method descriptions yet, but can help to find out what a method name could be). Other than this for now you have to refer to the main cegui documentation.