On Wed, Jul 13, 2011 at 7:49 PM, Renato Araujo Oliveira Filho < [email protected]> wrote:
> First of all, thanks guys for the feedback. > > On Wed, Jul 13, 2011 at 10:43 AM, Chris Morgan <[email protected]> > wrote: > > You certainly can't insert new syntax structures in Python code. The > "best" > > you can do in that way is doing it all as a string (with triple-quoted > > strings to help) and parse it out of that. But then you don't get any > > syntax highlighting in text editors or things like that. > > I agree with you the point here is not create another language, but > use the power o python to create something simple as QML to describe > scenes. > In my opinion is not productive write programs in 3 different > languages (Python + QML + javasrcript). Would be nice have all the > code write in python. > Definitely. I think a pure-Python implementation would be a very nice thing to have and would certainly make me a *lot* more likely to use it (if it had been in Python, I think I might have used it by now). > Basically, the context manager would be used to create scope (not hard, > just > > doing some munging of f_locals() of the outer frame in __enter__ and > > __exit__ to get the things defined inside correctly). If we're only > dealing > > with a certain set of possible attribute names, this is quite reasonable, > > but if you can put in custom ones then it wouldn't work (if you set a > value > > to the same thing inside the block as outside, it wouldn't be picked up > > unless it's been cleared out of the local "scope" by the context > manager). > > And how about functions - is it only certain function names which are > > allowed? > > About scope stuff, you need have access to another object scope, QML > use this to set the properties for other objects, something like that: > > with Rectangle() as Rectangle3: > anchors = Anchor(center_in=parent) > width = Rectangle2.width /2 > > Then I think scope is very important on QML. > > About functions names, some names are predefined (signals/slots), but > you can create new ones. > In that case, using a context manager to emulate scope won't be suitable: say, for example, you have "foo = 2" outside the with block and "foo = 2" inside, using "class Rectangle3(Rectangle)" you would get the foo = 2, but unless the variable foo is removed from the local scope in the with-block, which can't be done if there are extra variables being set, there would be no way of detecting that it should be inserted into that QML object as the object identity would be the same. > Using the class declaration style, you can use the class name as > object id, and use meta class to do the magical stuff. > What magical stuff do you think would need doing? -- Chris Morgan
_______________________________________________ PySide mailing list [email protected] http://lists.pyside.org/listinfo/pyside
