diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:16:46 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 18:16:46 +0000 |
commit | a7af74e75730559f7f9661e449eb269e356d9907 (patch) | |
tree | 72026b40b3a513aa21d630fb09ae10edab7f9e18 /app_templates/kcontrol_module/src/kcontrol_module.py | |
download | pytdeextensions-a7af74e75730559f7f9661e449eb269e356d9907.tar.gz pytdeextensions-a7af74e75730559f7f9661e449eb269e356d9907.zip |
Added KDE3 version of pykdeextensions
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/libraries/pykdeextensions@1097589 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'app_templates/kcontrol_module/src/kcontrol_module.py')
-rwxr-xr-x | app_templates/kcontrol_module/src/kcontrol_module.py | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/app_templates/kcontrol_module/src/kcontrol_module.py b/app_templates/kcontrol_module/src/kcontrol_module.py new file mode 100755 index 0000000..b435287 --- /dev/null +++ b/app_templates/kcontrol_module/src/kcontrol_module.py @@ -0,0 +1,166 @@ +#!/usr/bin/python +########################################################################### +# kcontrol_module - description # +# ------------------------------ # +# begin : Mon May 2 2005 # +# copyright : (C) 2005 by AUTHOR # +# email : your@email.com # +# # +########################################################################### +# # +# This program is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +########################################################################### + +import sys +from qt import * +from kdecore import * +from kdeui import * + +import kdedesigner +from KcontrolModuleWidgetUI import * + +description = "A Kcontrol module" +version = "0.1" + +############################################################################ +def AboutData(): + global version,description + + about_data = KAboutData("kcontrol_module", "kcontrol_module", version, \ + description, KAboutData.License_GPL, "(C) 2005 AUTHOR", None, None,\ + "your@email.com") + about_data.addAuthor("AUTHOR", None, "your@email.com") + return about_data + +############################################################################ +class KcontrolModuleWidget(KcontrolModuleWidgetUI): + def __init__(self,parent=None): + KcontrolModuleWidgetUI.__init__(self,parent,"Kcontrol module") + # Add other methods, slots and signals here. + +############################################################################ +# The base class that we use depends on whether this is running inside +# kcontrol or as a standalone application. +# Are we running as a separate standalone application or in KControl? +standalone = __name__=='__main__' + +if standalone: + programbase = KDialogBase +else: + programbase = KCModule + +class KcontrolModuleApp(programbase): + ######################################################################## + def __init__(self,parent=None,name=None): + global standalone + if standalone: + KDialogBase.__init__(self,KJanusWidget.Plain,"Kcontrol module",KDialogBase.User1|KDialogBase.Close, KDialogBase.Close) + self.setButtonText(KDialogBase.User1,"About") + else: + KCModule.__init__(self,parent,name) + # Create a configuration object. + self.config = KConfig("kcontrol_module") + self.setButtons(0) + self.aboutdata = AboutData() + + # The appdir needs to be explicitly otherwise we won't be able to + # load our icons and images. + KGlobal.iconLoader().addAppDir("kcontrol_module") + + if standalone: + toplayout = QVBoxLayout( self.plainPage(), 0, KDialog.spacingHint() ) + mainwidget = KcontrolModuleWidget(self.plainPage()) + else: + toplayout = QVBoxLayout( self, 0, KDialog.spacingHint() ) + mainwidget = KcontrolModuleWidget(self) + + toplayout.addWidget(mainwidget) + + self.aboutus = KAboutApplication(self) + + ######################################################################## + def __del__(self): + pass + + ######################################################################## + # KDialogBase method + def exec_loop(self): + global programbase + + # Load configuration here + self.__loadOptions() + + programbase.exec_loop(self) + + # Save configuration here + self.__saveOptions() + + ######################################################################## + # KDialogBase method + def slotUser1(self): + self.aboutus.show() + + ######################################################################## + def slotCloseButton(self): + self.close() + + ######################################################################## + def __loadOptions(self): + global kapp + config = kapp.config() + config.setGroup("General") + size = config.readSizeEntry("Geometry") + if size.isEmpty()==False: + self.resize(size) + + ####################################################################### + def __saveOptions(self): + global kapp + config = kapp.config() + config.setGroup("General") + config.writeEntry("Geometry", self.size()) + config.sync() + + ####################################################################### + # KControl virtual void methods + def load(self): + pass + def save(self): + pass + def defaults(self): + pass + def sysdefaults(self): + pass + + def aboutData(self): + # Return the KAboutData object which we created during initialisation. + return self.aboutdata + + def buttons(self): + # Only supply a Help button. Other choices are Default and Apply. + return KCModule.Help + +############################################################################ +# This is the entry point used when running this module outside of kcontrol. +def main(): + global kapp + about_data = AboutData() + KCmdLineArgs.init(sys.argv,about_data) + kapp = KApplication() + myapp = KcontrolModuleApp() + myapp.exec_loop() + +############################################################################ +# Factory function for KControl +def create_kcontrol_module(parent,name): + global kapp + kapp = KApplication.kApplication() + return KcontrolModuleApp(parent, name) + +############################################################################ +if standalone: + main() |