ImportError for kseparator in python file converted from .ui by pyqt ( using qt designer)

Question:

The python file converted from .ui created by qt designer shows
ImportError: No module named kseparator. code is

from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(400, 300)
        self.kseparator = KSeparator(Form)
        self.kseparator.setGeometry(QtCore.QRect(50, 60, 231, 16))
        self.kseparator.setObjectName(_fromUtf8("kseparator"))

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle(_translate("Form", "Form", None))

from kseparator import KSeparator

The ui in qt designer consist only a kseperator and compiling shows:

from kseparator import KSeparator
ImportError: No module named kseparator

How can i add kseperator module. Is it a module to be installed separately like some python library? please help…

Asked By: amg

||

Answers:

UPDATE:

FYI: as of Oct 2022, the PyKDE project appears to be completely dead. There have been no commits for eight years, and the outgoing maintainer has not been replaced (see: PyKDE Future: Seeking a New Maintainer). So it’s no longer possible to use any of the KDE widgets shown in Qt Designer (unless you’re willing to take on the mainentance of the PyKDE project ;-).


The KSeparator class is from KDE, which PyQt does not provide any direct support for.

If you want to use the KDE classes in your code, you will need to use PyKDE.

Answered By: ekhumoro