Page 1 of 1

Improving python wrappers?

Posted: Fri Aug 05, 2011 23:19
by GrizzLyCRO
I would like to improve python wrappers, for example

Code: Select all

xx.setPosition(PyCEGUI.UVector2(PyCEGUI.UDim(0.5,0), PyCEGUI.UDim(0.5,0)))


vs

Code: Select all

xx.setPosition( (0.5,0), (0.5,0) )


i dont have experience in this kind of stuff, so could you tell me where to start, and also do you agree with this kind of changes?

I am assuming that above method, accepts only stated variable types as arguments.

EDIT1: Proof of concept, how it can be achieved

Code: Select all

from PyCEGUI import *
import PyCEGUI

def set(self, property, val):
   
    if property == "Position":
        self.setPosition(UVector2(UDim(val[0][0], val[0][1]), UDim(val[1][0], val[1][1])))
   
    elif property == "Size":
        self.setSize(UVector2(UDim(val[0][0], val[0][1]), UDim(val[1][0], val[1][1])))
       
    else:
        self.setProperty(property,val)
       

PyCEGUI.GUISheet.set = set

Re: Improving python wrappers?

Posted: Wed Aug 31, 2011 13:14
by Kulik
Oh crap, I completely missed this :-) Sorry.

This is indeed something I had planned, I wanted to make PyCEGUI more pythonic by using monkey patching (altering __init__.py that would just import the CPython module and do some changes on it to make it more pythonic).

If you are still interested in this, join the #cegui freenode IRC channel to discuss this.