Difference between revisions of "CEGUIPython"

From CEGUI Wiki - Crazy Eddie's GUI System (Open Source)
Jump to: navigation, search
 
(Downloading)
Line 11: Line 11:
 
  cvs -z3 -d:pserver:anonymous@crayzedsgui.cvs.sourceforge.net:/cvsroot/crayzedsgui/ co -P ceguiaddons/PythonScriptModule/ScriptingModules/CEGUIPython
 
  cvs -z3 -d:pserver:anonymous@crayzedsgui.cvs.sourceforge.net:/cvsroot/crayzedsgui/ co -P ceguiaddons/PythonScriptModule/ScriptingModules/CEGUIPython
  
 +
Then to install you would go to the CEGUIPython folder, and do the following commands:
 +
 +
bash bootstrap (only needed the first time to generate some files)
 +
./configure
 +
make
 +
make install (you'll need root/admin privileges for this)
  
 
= Using =
 
= Using =

Revision as of 05:07, 19 September 2006

Introduction

Cegui has a 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 and reist.

Downloading

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

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

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

bash bootstrap (only needed the first time to generate some files)
./configure
make
make install (you'll need root/admin privileges for this)

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