I didn't say it was a good idea, just that it was one way to do it. ;)

But your points are excellent. I agree that it's probably not a wonderful idea 
to try to shoehorn other languages into Python syntax in that way. It would be 
convenient, I suspect, to be able to programatically manipulate a QML 
structure, but that would probably be best done in a similar manner as XML 
structure is handled in Python.

Embedding Python in QML would be nice, but I suspect for anything even 
semi-complicated you'd run into a lot of the same problems as you bring up 
below.


dan


On Jul 14, 2011, at 12:21a, ext Thomas Perl wrote:

> Hi,
> 
> 2011/7/14  <[email protected]>:
>> Here's a way to do it with a Python dict structure. Given the QML:
>> [...]
>> you can translate to Python like so:
>> 
>>  from QtQuick import Rectangle, parent
>> [...]
> 
> How would you "import" user-defined (and/or plugin) QML components?
> 
> Also, I still can't really see the advantage of using Python syntax to
> define QML. Even the dict-based approach doesn't look "natural" to a
> Python developer, so a Python developer who would like to "learn" QML
> would then have to resort to looking at the documentation for this
> custom approach as opposed to the more widely-used (which means more
> examples) "real" QML format. You wouldn't want to write a Python
> structure that resembles HTML documents, or would you? Think of QML as
> a "document format" to declare UIs, which just happens to use
> JavaScript for code blocks and expressions. And I think that's the
> only block where it would make sense to have Python in QML: Directly
> in code blocks and expressions.
> 
> Trying to come up with a replacement syntax of QML in Python makes it
> harder to learn (less examples), harder to decide (do I want to have
> "pure" QML or Python QML?), less stable (Python QML definitely will
> take some time to be in a stable, debugged state). Also, who
> guarantees that the Python-flavored QML will be supported the same way
> that the "original" QML will be? We won't be able to convince people
> using C++ now to "try Python" - they would either have to choose to
> reuse their existing QML knowledge and assets and ignore PyQML anyway
> or learn a new syntax for something they already know to do with a
> different syntax (and then the question "What's the point in learning
> a new syntax that doesn't give any additional benefits?" comes up
> again).
> 
> If you have multiple children, your dict-based approach doesn't
> guarantee that they appear in the same order as defined (something
> that's important for children of the QML Row { } element). You can use
> OrderedDict as a workaround, but then again this blows up the syntax
> at definition time. Apart from that, the dict-based approach also has
> more "syntax noise" (brackets, quotes and colons for the dicts)
> compared to the QML version.
> 
> How do you pass the implicit "mouse" parameter to your callback of
> "onClicked", for accessing the "x" and "y" properties?
> 
> In addition to that, QML's expressions are saved as-such and are used
> for property bindings. The expression "Rectangle('Rect1').width / 2"
> in your code above gets evaluated immediately and the result stored.
> Sure, you could try to override some operators, but it won't be
> Pythonic and would not be the result one would expect as Python
> developer.
> 
> Again, I don't say you shouldn't think about such things, I just want
> to make it clear that in my opinion, trying to shoehorn the Python
> Syntax into QML "just because" might not be a good idea, and anybody's
> time could be (in my opinion) better spent improving other parts of
> PySide. With that said, I'd like to see an easy way to use/reuse
> Python syntax and code in code blocks of QML - which doesn't try to
> change the syntax of the markup, but tries to give some value addition
> to "normal" QML.
> 
> HTH.
> Thomas

_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside

Reply via email to