[Kde-bindings] [Python] KSharedConfig and delete nested KConfigGroup
Alexander Fischer
alexanderfischer at ordnungsdienst.org
Fri Oct 9 20:24:13 UTC 2009
Hello,
i hope, this is the correct list. If not, please tell me.
i'm currently writing a plasmoid in python and have some ugly trouble with
nested groups from a KSharedConfig-Object. I have a top group "fonts" (and
others which are not relevant here) that includes other groups, i call
them profiles. This profiles include font definitions like bold,
italic, size etc.
My problem is now, that I dont know, how to delete such a nested font
profile.
I tried to work with the deleteGroup()-method:
profileGroup = self.__fonts.group(str(profileName))
profileGroup.deleteGroup()
But this does not work as I thought. if i do an self.__fonts.groupList()
after
that, the deleted profile is still present. A simple
del profileGroup
does not work, too.
What i find pretty amazing is, that the profile is still available after i
do
del self.__config, self.__fonts
self.__config = KSharedConfig.openConfig('fontsizerrc')
self.__fonts = KConfigGroup(self.__config, 'fonts')
But if I restart the plasmoid, the profile is gone.
What am i doing wrong here?
I am using Slackware-Linux-13, (Py)KDE-4.2.4, Python 2.6.2, PyQt-4.4.4.
cu alex
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.kdecore import *
from PyKDE4.kdeui import *
class handleProfiles():
def __init__(self):
self.__config = KSharedConfig.openConfig('fontsizerrc')
self.__fonts = KConfigGroup(self.__config, 'fonts')
def delProfile(self, profileName):
"""
Delete the given profile
"""
print profileName
profileGroup = self.__fonts.group(str(profileName))
profileGroup.deleteGroup()
del profileGroup
# group becomes empty but is still present in self.__fonts.groupList()
for s in self.__fonts.groupList():
print s
def applyChanges(self):
self.__fonts.sync()
self.__config.sync()
More information about the Kde-bindings
mailing list