for instance,
class ScriptModule(cegui.ScriptModule):
def __init__(self):
cegui.ScriptModule.__init__(self)
self.identifierString= 'CEGUI Python scripting module v0.1'
excepts in AttributeError: can't set attribute on identifierString
when creating a script module, how can I register it within CEGUI?
aparently, all I have to do is call the cegui.ScriptModule constructor
before initialising cegui.system, but the log says:
---- Scripting module is: None ----
still, doesn't explain why I can't set the identifier string :/
anyway, I'll probably finish the code tonight (CEST) and it will make
a nice wiki tutorial :)
for those of you who don't know what can be done with a ScriptModule:
you can assing actual python functions to events in .layout files and
have your class assign proper callback functions. eg:
<Window Type='wusLook/Editbox' Name='wus_console_input'>
<Property Name='Text' Value=''/>
<Event Name='Clicked' Function='on_console_click' />
</Window>
that way, your gui designers (or yourself :) ) can set events in an
easier and more logical manner.
here's the sample code:
class events:
def OnTabsLeft(self,args):
print 'OnTabsLeft'
_events=events()
class ScriptModule(cegui.ScriptModule):
def __init__(self):
cegui.ScriptModule.__init__(self)
# self.identifierString= 'CEGUI Python scripting module by
Cateia games v0.1'
def createBindings(self):
cegui.Logger.getSingleton().logEvent( "---- Creating Python
bindings ----" )
def subscribeEvent(self,target,event_name,subscriber_name):
return target.subscribeEvent(event_name,_events,'OnTabsLeft')
def InitCEGUI(self):
global script_module
self.guiRenderer =
cegui.OgreCEGUIRenderer(self.renderWindow,
ogre.RENDER_QUEUE_OVERLAY, True, 0, self.sceneManager)
script_module=ScriptModule()
self.guiSystem = cegui.System(self.guiRenderer,logFile='logs/
gui.log',scriptModule=script_module)
.......
and put this in a layout file somewhere.
this code has to work,it was copy-translated from a working C++ code.
everything seem to be in order, except when I get a call to
subscribeEvent. I return a connected event, but the following
excoption raises:
TypeError: No registered converter was able to produce a C++ rvalue of
type class CEGUI::RefCounted<class CEGUI::BoundSlot> from this Python
object of type EventConnection
EventConnection and CEGUI::RefCounted<class CEGUI::BoundSlot> are the
same class. just typedefed.
<Event Name='Clicked' Function='some_function' />
I'm using rc2 binary on windows and linux right now.
On Jul 10, 2:26 am, "Andy Miller" <nzmill...@gmail.com> wrote:
>
> Anyway, I'll update the svn and put out a binary version for you to test
> with (you building from source?)
>
> Cheers
> Andy
>
I've modified Demo_GUI with my class: