[PyQt] My first PyQt plasmoid crashes

linuxoidoz at yahoo.com.au linuxoidoz at yahoo.com.au
Thu Apr 1 11:19:03 BST 2010


Hello,

I am trying to write my first plasmoid in PyQt but when I try to view it in plasmaviewer it crashes with segmentation fault "Executable: plasmoidviewer PID: 23063 Signal: 11 (Segmentation fault)", here's the log:

"~/Develop/Python/plasmoids> plasmoidviewer qt-converter.plasmoid
plasmoidviewer(23614)/plasma main: setting FormFactor to "planar"
plasmoidviewer(23614)/plasma main: setting Location to "floating"
plasmoidviewer(23614)/plasma main: setting containment to "null"
plasmoidviewer(23614)/plasma main: setting auth policy
plasmoidviewer(23614)/plasma main: just load applet
plasmoidviewer(23614)/plasma FullView::addApplet: adding applet "qt-converter.plasmoid" in "null"
plasmoidviewer(23614)/libplasma Plasma::CoronaPrivate::addContainment: loading of containment "null" failed.
plasmoidviewer(23614)/kdecore (KSycoca): Trying to open ksycoca from  "/var/tmp/kdecache-linuxoid/ksycoca4"
plasmoidviewer(23614)/libplasma Plasma::AppletPrivate::init: Check your constructor!  You probably want to be passing in a Service::Ptr  or a QVariantList with a valid storageid as arg[0].
plasmoidviewer(23614)/python (plugin) KPythonPluginFactory::KPythonPluginFactory: KPythonPluginFactory::KPythonPluginFactory()
plasmoidviewer(23614)/python (plugin) KPythonPluginFactory::initialize: Initializing Python interpreter.
plasmoidviewer(23614)/python (plugin) KPythonPluginFactory::initialize: Succesfully initialized Python interpreter.
plasmoidviewer(23614)/python (plugin) KPythonPluginFactory::create: KPythonPluginFactory::create iface:  Plasma::AppletScript
plasmoidviewer(23614)/python (plugin) KPythonPluginFactory::create: keyword to be used for finding the plugin code:  "plasma_scriptengine_python/pyappletscript.py"
plasmoidviewer(23614)/python (plugin) KPythonPluginFactory::create: Path to plugin code is:  "/usr/share/kde4/apps/plasma_scriptengine_python/pyappletscript.py"
plasmoidviewer(23614)/python (plugin) KPythonPluginFactory::create: Returning result qobject
plasmoidviewer(23614)/libplasma Plasma::AppletPrivate::setupScriptSupport: setting up script support, package is in "/home/linuxoid/Develop/Python/plasmoids/qt-converter.plasmoid/" which is a "Plasmoid" package , main script is "/home/linuxoid/Develop/Python/plasmoids/qt-converter.plasmoid/contents/code/main.py"
plasmoidviewer(23614)/libplasma Plasma::Package::filePath: "/home/linuxoid/Develop/Python/plasmoids/qt-converter.plasmoid/contents/locale" does not exist
plasmoidviewer(23614)/libplasma Plasma::Package::filePath: "/home/linuxoid/Develop/Python/plasmoids/qt-converter.plasmoid/contents/config/main.xml" does not exist
plasmoidviewer(23614)/libplasma Plasma::Package::filePath: "/home/linuxoid/Develop/Python/plasmoids/qt-converter.plasmoid/contents/ui/config.ui" does not exist
KCrash: Application 'plasmoidviewer' crashing...
sock_file=/home/linuxoid/.kde4/socket-linuxoid/kdeinit4__0

[1]+  Stopped                 plasmoidviewer qt-converter.plasmoid"

Here's my main.py file below. I have a stand alone application and it works fine. It must be something to do with plasma. What am I doing wrong? Will greatly appreciate your help. Thank you.

# -*- coding: utf-8 -*-

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
 
class PyQtConverter(plasmascript.Applet):
    def __init__(self,parent,args=None):
        plasmascript.Applet.__init__(self,parent)
 
    def init(self):
        self.setHasConfigurationInterface(False)
        self.setAspectRatioMode(Plasma.Square)
 
        self.theme = Plasma.Svg(self)
        self.theme.setImagePath("widgets/background")
        self.setBackgroundHints(Plasma.Applet.DefaultBackground)

        self.mainWidget = QWidget()
        self.scene = QGraphicsScene()
        self.mainGraphicsWidget = self.scene.addWidget(self.mainWidget)

        self.btnSize = QSize(50, 50)
        self.iconSize = QSize(40, 40)
        
        self.iconFind = QIcon(":/myresources/icons/search.svg")
        self.iconCheck = QIcon(":/myresources/icons/check.svg")
        self.iconAbout = QIcon(":/myresources/icons/about.svg")

        sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        
        self.btnCheck = QPushButton(self.iconCheck, "", self.mainWidget)
        self.btnCheck.setIconSize(self.iconSize)
        sizePolicy.setHeightForWidth(self.btnCheck.sizePolicy().hasHeightForWidth())
        self.btnCheck.setSizePolicy(sizePolicy)
        self.btnCheck.setMinimumSize(self.btnSize)
        self.btnFind = QPushButton(self.iconFind, "", self.mainWidget)
        self.btnFind.setIconSize(self.iconSize)
        sizePolicy.setHeightForWidth(self.btnFind.sizePolicy().hasHeightForWidth())
        self.btnFind.setSizePolicy(sizePolicy)
        self.btnFind.setMinimumSize(self.btnSize)
        self.btnAbout = QPushButton(self.iconAbout, "", self.mainWidget)
        self.btnAbout.setIconSize(self.iconSize)
        sizePolicy.setHeightForWidth(self.btnAbout.sizePolicy().hasHeightForWidth())
        self.btnAbout.setSizePolicy(sizePolicy)
        self.btnAbout.setMinimumSize(self.btnSize)
        
        self.hbToolbar = QHBoxLayout()
        self.hbToolbar.sizeConstraint = QLayout.SetDefaultConstraint
        self.hbToolbar.addWidget(self.btnCheck)
        self.hbToolbar.addWidget(self.btnFind)
        self.hbToolbar.addWidget(self.btnAbout)
        
        self.mainLayout = QVBoxLayout(self.mainWidget)
        self.mainLayout.sizeConstraint = QLayout.SetDefaultConstraint
        self.mainLayout.addLayout(self.hbToolbar)

        self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
        self.layout.addItem(self.mainGraphicsWidget)
        
        self.applet.setLayout(self.layout)
        self.resize(125,125)

 
def CreateApplet(parent):
    return PyQtConverter(parent)


More information about the PyQt mailing list