This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Coding a plasmoid in python 2.6 with configuration options?

Tags: None
(comma "," separated)
tjabo
Registered Member
Posts
1
Karma
0
hi,

I am trying to write a kde 4.4 plasmoid and have the problem of integrating a configuration dialog (this is not documented in the plasmoid python tutorials).

The test plasmoid loads in the "plasmoidviewer" but when opening the "settings" my checkbox is on the left side hovering over the "Keyboad shortcut" selector on the left. (The icon of "Keyboard shortcut" is visible through the checkbox label). Screenshot: http://taponet.de/tmp/configTest-Settings.png

(my system is a i386 ubuntu karmic with kde 4.4 from ppa)

This is "contents/code/main.py":
Code: Select all
# -*- coding: utf-8 -*-
# (C)2010 by tjabo -- License: GPL
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript

class ConfigTestApplet(plasmascript.Applet):
    def __init__(self, parent, args=None):
        plasmascript.Applet.__init__(self,parent)
       
    def init(self):
        #config = self.config()
        #self.isChecked = config.readEntry('isChecked', False)
         # self.setHasConfigurationInterface(False)
       
        self.setAspectRatioMode(Plasma.Square)
        self.theme = Plasma.Svg(self)
        self.theme.setImagePath("widgets/background")
        self.setBackgroundHints(Plasma.Applet.DefaultBackground)
       
        self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
        self.mylabel = Plasma.Label(self.applet)
        self.mylabel.setText("Greetings from the cow.")
        self.layout.addItem(self.mylabel)
        self.applet.setLayout(self.layout)
        self.resize(125,125)
   
    def createConfigurationInterface(self, parent):
        self.widget = QWidget(parent)
        self.connect(self.widget, SIGNAL('destroyed(QObject*)'), self.configWidgetDestroyed)
        self.ui = uic.loadUi(self.package().filePath('ui', 'config.ui'), self.widget)
        # ? set checkbox?
        return self.widget
       
    def save(self, config):
        "Save the config"
        config.writeEntry('isChecked', self.isChecked)
   
    def configWidgetDestroyed(self):
        self.widget = None
        self.ui = None
       
def CreateApplet(parent):
    return ConfigTestApplet(parent)


The "contents/ui/config.ui" was created with designer-qt4 and is a QWidget containing a checkbox only:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>configTestConfig</class>
 <widget class="QWidget" name="configTestConfig">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>399</width>
    <height>170</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>Configuration of plasmoid</string>
  </property>
  <widget class="QCheckBox" name="checkBox1">
   <property name="geometry">
    <rect>
     <x>10</x>
     <y>10</y>
     <width>88</width>
     <height>23</height>
    </rect>
   </property>
   <property name="text">
    <string>CheckBox</string>
   </property>
  </widget>
 </widget>
 <resources/>
 <connections/>
</ui>


Please help if you have any idea what may be wrong here.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
See http://api.kde.org/4.x-api/kdelibs-apid ... ialog.html

You need to do the following:
Code: Select all
parent.addPage( self.widget, "My Config Page Name", "My icon" );


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]