Python and QML

Eric Mesa ericsbinaryworld at gmail.com
Thu May 10 17:49:47 UTC 2012


On Wed, May 9, 2012 at 10:54 PM, Eric Mesa <ericsbinaryworld at gmail.com>wrote:

> Alright, here's my python code:
>
> import sys
>
> from PyQt4.QtCore import QObject, QUrl, pyqtSignal
> from PyQt4.QtGui import QApplication
> from PyQt4.QtDeclarative import QDeclarativeView
> from PyKDE4.plasma import Plasma
> from PyKDE4 import plasmascript
>
> app = QApplication(sys.argv)
>
> # Create the QML user interface.
> view = QDeclarativeView()
> view.setSource(QUrl('flickrviews.qml'))
> view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
>
>
> #the meat and potatoes
> # Get the root object of the user interface.  It defines a
> # signal and any JavaScript functions.  Both
> # can be accessed transparently from Python.
> rootObject = view.rootObject()
>
> #make it visible
> view.setGeometry(100, 100, 400, 240)
> view.show()
>
> app.exec_()
>
>
> this gives me the error: module "org.kde.plasma.core" is not installed
>      import org.kde.plasma.core 0.1 as PlasmaCore
>
> this is similar to the error I got when I was trying to develop my
> plasmoid in qtcreator.  It means I won't be able to connect to my data
> engine.  Is there no way around that?  It seems weird that only plasmoids
> can use the power of data engines.
>
>
> I've been thinking about this a lot today and I was wondering if I might
fix the issue by connecting to the dataengine from within the python code
rather than the QML?  Perhaps the conflict is coming from the fact that if
the python is the logic and QML is the code, then I can't be accessing the
data engine from within the QML.  If that's the case, how would I pass the
data from python into the QML so that the QML can take care of layouts.  OR
would I just do the data engine connection as javascript to bypass the
import of org.kde.plasma.core?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20120510/277a24f6/attachment.html>


More information about the Plasma-devel mailing list