diff options
Diffstat (limited to 'templates/basic')
-rw-r--r-- | templates/basic/basicapp.py | 58 | ||||
-rw-r--r-- | templates/basic/menuapp1.py | 194 | ||||
-rw-r--r-- | templates/basic/menuapp2.py | 200 | ||||
-rw-r--r-- | templates/basic/menuapp3.py | 162 | ||||
-rw-r--r-- | templates/basic/menuapp3ui.rc | 24 | ||||
-rw-r--r-- | templates/basic/minimal.py | 48 | ||||
-rw-r--r-- | templates/basic/panelapplet.py | 49 | ||||
-rw-r--r-- | templates/basic/systray.py | 61 | ||||
-rw-r--r-- | templates/basic/systray1.py | 67 |
9 files changed, 863 insertions, 0 deletions
diff --git a/templates/basic/basicapp.py b/templates/basic/basicapp.py new file mode 100644 index 0000000..2146f63 --- /dev/null +++ b/templates/basic/basicapp.py @@ -0,0 +1,58 @@ +""" +Copyright 2003 Jim Bublitz + +Terms and Conditions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Except as contained in this notice, the name of the copyright holder shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from the +copyright holder. +""" + +import sys + +from qt import SIGNAL +from kdecore import KApplication, KCmdLineArgs, KAboutData +from kdeui import KMainWindow + +class MainWin (KMainWindow): + def __init__ (self, *args): + KMainWindow.__init__ (self) + + +#-------------------- main ------------------------------------------------ + +description = "A basic application template" +version = "1.0" +aboutData = KAboutData ("", "",\ + version, description, KAboutData.License_GPL,\ + "(C) 2003 whoever the author is") + +aboutData.addAuthor ("author1", "whatever they did", "email@somedomain") +aboutData.addAuthor ("author2", "they did something else", "[email protected]") + +KCmdLineArgs.init (sys.argv, aboutData) + +app = KApplication () +mainWindow = MainWin (None, "main window") +mainWindow.show() +app.connect (app, SIGNAL ("lastWindowClosed ()"), app.quit) +app.exec_loop() diff --git a/templates/basic/menuapp1.py b/templates/basic/menuapp1.py new file mode 100644 index 0000000..a482c2a --- /dev/null +++ b/templates/basic/menuapp1.py @@ -0,0 +1,194 @@ +""" +This template constructs an application with menus, toolbar and statusbar, +HOWEVER it is not recommended this template actually be used. It presents +the "KDE 1.0" method for constructing menus and toolbars - later versions +of KDE have introduced better (easier and more powerful) methods for +doing this job - see other menuapp*.py templates for these methods +""" + +""" +Copyright 2003 Jim Bublitz + +Terms and Conditions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Except as contained in this notice, the name of the copyright holder shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from the +copyright holder. +""" + + +False = 0 +True = not False + + +import sys + +from qt import QPopupMenu, SIGNAL + +from kdecore import KApplication, KCmdLineArgs, KAboutData, i18n, KStdAccel, KIcon, KIconLoader +from kdeui import KMainWindow, KMessageBox + +TOOLBAR_NEW = 1 +TOOLBAR_OPEN = 2 +TOOLBAR_SAVE = 3 +TOOLBAR_CUT = 4 +TOOLBAR_COPY = 5 +TOOLBAR_PASTE = 6 + +STATUSBAR_LEFT = 1 +STATUSBAR_MIDDLE = 2 +STATUSBAR_RIGHT = 3 + +class MainWin (KMainWindow): + def __init__ (self, *args): + apply (KMainWindow.__init__, (self,) + args) + + self.initMenus () + self.initToolBar () + self.initStatusBar () + + def initMenus (self): + fileMenu = QPopupMenu (self) + + # "File" menu items + fileMenu.insertItem (i18n ("New"), self.slotNew, KStdAccel.openNew ().keyCodeQt ()) + fileMenu.insertItem (i18n ("Open"), self.slotOpen, KStdAccel.open ().keyCodeQt ()) + fileMenu.insertSeparator (); + fileMenu.insertItem (i18n ("Save"), self.slotSave, KStdAccel.save ().keyCodeQt ()) + fileMenu.insertItem (i18n ("SaveAs"), self.slotSaveAs) + fileMenu.insertSeparator (); + fileMenu.insertItem (i18n ("Print"), self.slotPrint, KStdAccel.print_ ().keyCodeQt ()) + fileMenu.insertSeparator (); + fileMenu.insertItem (i18n ("&Quit"), self.slotQuit, KStdAccel.quit ().keyCodeQt ()); + + self.menuBar ().insertItem (i18n ("&File"), fileMenu) + + editMenu = QPopupMenu (self) + + # "Edit" menu items + editMenu.insertItem (i18n ("Undo"), self.slotUndo, KStdAccel.undo ().keyCodeQt ()) + editMenu.insertItem (i18n ("Redo"), self.slotRedo, KStdAccel.redo ().keyCodeQt ()) + editMenu.insertSeparator (); + editMenu.insertItem (i18n ("Cut"), self.slotCut, KStdAccel.cut ().keyCodeQt ()) + editMenu.insertItem (i18n ("Copy"), self.slotCopy, KStdAccel.copy ().keyCodeQt ()) + editMenu.insertItem (i18n ("Paste"), self.slotPaste, KStdAccel.paste ().keyCodeQt ()) + editMenu.insertSeparator (); + editMenu.insertItem (i18n ("Find"), self.slotFind, KStdAccel.find ().keyCodeQt ()) + editMenu.insertItem (i18n ("Find Next"), self.slotFindNext, KStdAccel.findNext ().keyCodeQt ()) + editMenu.insertItem (i18n ("Replace"), self.slotReplace, KStdAccel.replace ().keyCodeQt ()) + + self.menuBar ().insertItem (i18n ("&Edit"), editMenu) + + helpMenu = self.helpMenu ("") + self.menuBar ().insertItem (i18n ("&Help"), helpMenu) + + def initToolBar (self): + icons = KIconLoader () + + self.toolBar ().insertButton (icons.loadIcon ("filenew", KIcon.Toolbar), TOOLBAR_NEW, SIGNAL ("clicked (int)"), self.slotNew,\ + True, "New") + self.toolBar ().insertButton (icons.loadIcon ("fileopen", KIcon.Toolbar), TOOLBAR_OPEN, SIGNAL ("clicked (int)"), self.slotOpen,\ + True, "Open") + self.toolBar ().insertButton (icons.loadIcon ("filesave", KIcon.Toolbar), TOOLBAR_SAVE, SIGNAL ("clicked (int)"), self.slotSave,\ + True, "Save") + self.toolBar ().insertButton (icons.loadIcon ("editcut", KIcon.Toolbar), TOOLBAR_CUT, SIGNAL ("clicked (int)"), self.slotCut,\ + True, "Cut") + self.toolBar ().insertButton (icons.loadIcon ("editcopy", KIcon.Toolbar), TOOLBAR_COPY, SIGNAL ("clicked (int)"), self.slotCopy,\ + True, "Copy") + self.toolBar ().insertButton (icons.loadIcon ("editpaste", KIcon.Toolbar), TOOLBAR_PASTE, SIGNAL ("clicked (int)"), self.slotPaste,\ + True, "Paste") + + def initStatusBar (self): + self.statusBar ().insertItem ("", STATUSBAR_LEFT, 1000, True) + self.statusBar ().insertItem ("", STATUSBAR_MIDDLE, 1000, True) + self.statusBar ().insertItem ("", STATUSBAR_RIGHT, 1000, True) + + +#-------------------- slots ----------------------------------------------- + + def slotNew (self, id = -1): + self.notImpl ("New") + + def slotOpen(self, id = -1): + self.notImpl ("Open") + + def slotSave (self, id = -1): + self.notImpl ("Save") + + def slotSaveAs (self): + self.notImpl ("Save As") + + def slotPrint (self): + self.notImpl ("Print") + + def slotQuit (self): + self.notImpl ("Quit") + + def slotUndo (self): + self.notImpl ("Undo") + + def slotRedo (self): + self.notImpl ("Redo") + + def slotCut (self, id = -1): + self.notImpl ("Cut") + + def slotCopy (self, id = -1): + self.notImpl ("Copy") + + def slotPaste (self, id = -1): + self.notImpl ("Paste") + + def slotFind (self): + self.notImpl ("Find") + + def slotFindNext (self): + self.notImpl ("Find Next") + + def slotReplace (self): + self.notImpl ("Replace") + + def notImpl (self, item = "Feature"): + self.statusBar ().changeItem ("%s not implemented" % item, STATUSBAR_LEFT) + KMessageBox.error (self, "%s not implemented" % item, "Not Implemented") + self.statusBar ().changeItem ("", STATUSBAR_LEFT) + + +#-------------------- main ------------------------------------------------ + +description = "A basic application template" +version = "1.0" +aboutData = KAboutData ("", "",\ + version, description, KAboutData.License_GPL,\ + "(C) 2003 whoever the author is") + +aboutData.addAuthor ("author1", "whatever they did", "email@somedomain") +aboutData.addAuthor ("author2", "they did something else", "[email protected]") + +KCmdLineArgs.init (sys.argv, aboutData) + +KCmdLineArgs.addCmdLineOptions ([("+files", "File to open")]) + +app = KApplication () +mainWindow = MainWin (None, "main window") +mainWindow.show() +app.exec_loop() diff --git a/templates/basic/menuapp2.py b/templates/basic/menuapp2.py new file mode 100644 index 0000000..394eca8 --- /dev/null +++ b/templates/basic/menuapp2.py @@ -0,0 +1,200 @@ +""" +This template constructs an application with menus, toolbar and statusbar. +It uses KDE classes and methods that simplify the task of building and +operating a GUI. It is recommended that this approach be used, rather +than the primitive approach in menuapp1.py +""" + +""" +Copyright 2003 Jim Bublitz + +Terms and Conditions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Except as contained in this notice, the name of the copyright holder shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from the +copyright holder. +""" + + +False = 0 +True = not False + + +import sys + +from qt import QPopupMenu, SIGNAL + +from kdecore import KApplication, KCmdLineArgs, KAboutData, i18n, KShortcut +from kdeui import KMainWindow, KMessageBox, KStdAction, KAction + +STATUSBAR_LEFT = 1 +STATUSBAR_MIDDLE = 2 +STATUSBAR_RIGHT = 3 + +class MainWin (KMainWindow): + def __init__ (self, *args): + apply (KMainWindow.__init__, (self,) + args) + + self.initActions () + self.initMenus () + self.initToolBar () + self.initStatusBar () + + self.saveAction.setEnabled (False) + self.saveAsAction.setEnabled (False) + + def initActions (self): + # "File" menu items + self.newAction = KStdAction.openNew (self.slotNew, self.actionCollection ()) + self.openAction = KStdAction.open (self.slotOpen, self.actionCollection ()) + self.saveAction = KStdAction.save (self.slotSave, self.actionCollection ()) + self.saveAsAction = KStdAction.saveAs (self.slotSaveAs, self.actionCollection ()) + self.printAction = KStdAction.print_ (self.slotPrint, self.actionCollection ()) + self.quitAction = KStdAction.quit (self.slotQuit, self.actionCollection ()) + + # "Edit" menu items + self.undoAction = KStdAction.undo (self.slotUndo, self.actionCollection ()) + self.redoAction = KStdAction.redo (self.slotRedo, self.actionCollection ()) + self.cutAction = KStdAction.cut (self.slotCut, self.actionCollection ()) + self.copyAction = KStdAction.copy (self.slotCopy, self.actionCollection ()) + self.pasteAction = KStdAction.paste (self.slotPaste, self.actionCollection ()) + self.findAction = KStdAction.find (self.slotFind, self.actionCollection ()) + self.findNextAction = KStdAction.findNext (self.slotFindNext, self.actionCollection ()) + self.replaceAction = KStdAction.replace (self.slotReplace, self.actionCollection ()) + self.specialAction = KAction (i18n ("Special"), KShortcut.null (), self.slotSpecial, self.actionCollection (), None) + + def initMenus (self): + fileMenu = QPopupMenu (self) + self.newAction.plug (fileMenu) + self.openAction.plug (fileMenu) + fileMenu.insertSeparator () + self.saveAction.plug (fileMenu) + self.saveAsAction.plug (fileMenu) + fileMenu.insertSeparator () + self.printAction.plug (fileMenu) + fileMenu.insertSeparator () + self.quitAction.plug (fileMenu) + self.menuBar ().insertItem (i18n ("&File"), fileMenu) + + editMenu = QPopupMenu (self) + self.undoAction.plug (editMenu) + self.redoAction.plug (editMenu) + editMenu.insertSeparator () + self.cutAction.plug (editMenu) + self.copyAction.plug (editMenu) + self.pasteAction.plug (editMenu) + editMenu.insertSeparator () + self.findAction.plug (editMenu) + self.findNextAction.plug (editMenu) + self.replaceAction.plug (editMenu) + editMenu.insertSeparator () + self.specialAction.plug (editMenu) + self.menuBar ().insertItem (i18n ("&Edit"), editMenu) + + helpMenu = self.helpMenu ("") + self.menuBar ().insertItem (i18n ("&Help"), helpMenu) + + def initToolBar (self): + self.newAction.plug (self.toolBar ()) + self.openAction.plug (self.toolBar ()) + self.saveAction.plug (self.toolBar ()) + self.cutAction.plug (self.toolBar ()) + self.copyAction.plug (self.toolBar ()) + self.pasteAction.plug (self.toolBar ()) + + def initStatusBar (self): + self.statusBar ().insertItem ("", STATUSBAR_LEFT, 1000, True) + self.statusBar ().insertItem ("", STATUSBAR_MIDDLE, 1000, True) + self.statusBar ().insertItem ("", STATUSBAR_RIGHT, 1000, True) + +#-------------------- slots ----------------------------------------------- + + def slotNew (self, id = -1): + self.notImpl ("New") + + def slotOpen(self, id = -1): + self.notImpl ("Open") + + def slotSave (self, id = -1): + self.notImpl ("Save") + + def slotSaveAs (self): + self.notImpl ("Save As") + + def slotPrint (self): + self.notImpl ("Print") + + def slotQuit (self): + self.notImpl ("Quit") + + def slotUndo (self): + self.notImpl ("Undo") + + def slotRedo (self): + self.notImpl ("Redo") + + def slotCut (self, id = -1): + self.notImpl ("Cut") + + def slotCopy (self, id = -1): + self.notImpl ("Copy") + + def slotPaste (self, id = -1): + self.notImpl ("Paste") + + def slotFind (self): + self.notImpl ("Find") + + def slotFindNext (self): + self.notImpl ("Find Next") + + def slotReplace (self): + self.notImpl ("Replace") + + def slotSpecial (self): + self.notImpl ("Special") + + def notImpl (self, item = "Feature"): + self.statusBar ().changeItem ("%s not implemented" % item, STATUSBAR_LEFT) + KMessageBox.error (self, "%s not implemented" % item, "Not Implemented") + self.statusBar ().changeItem ("", STATUSBAR_LEFT) + + +#-------------------- main ------------------------------------------------ + +description = "A basic application template" +version = "1.0" +aboutData = KAboutData ("", "",\ + version, description, KAboutData.License_GPL,\ + "(C) 2003 whoever the author is") + +aboutData.addAuthor ("author1", "whatever they did", "email@somedomain") +aboutData.addAuthor ("author2", "they did something else", "[email protected]") + +KCmdLineArgs.init (sys.argv, aboutData) + +KCmdLineArgs.addCmdLineOptions ([("+files", "File to open")]) + +app = KApplication () +mainWindow = MainWin (None, "main window") +mainWindow.show() +app.exec_loop() diff --git a/templates/basic/menuapp3.py b/templates/basic/menuapp3.py new file mode 100644 index 0000000..e729d6d --- /dev/null +++ b/templates/basic/menuapp3.py @@ -0,0 +1,162 @@ +""" +This template constructs an application with menus, toolbar and statusbar. +It uses an XML file (menuapp3ui.rc) to specify the menu layout; all menu +items have a corresponding action defined, but no menus are created +explicitly in code. This app has the same menu layout as menuapp2.py +""" + +""" +Copyright 2003 Jim Bublitz + +Terms and Conditions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Except as contained in this notice, the name of the copyright holder shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from the +copyright holder. +""" + + +False = 0 +True = not False + + +import sys + +from qt import QPopupMenu, SIGNAL + +from kdecore import KApplication, KCmdLineArgs, KAboutData, i18n, KShortcut +from kdeui import KMainWindow, KMessageBox, KStdAction, KAction, KActionCollection + +STATUSBAR_LEFT = 1 +STATUSBAR_MIDDLE = 2 +STATUSBAR_RIGHT = 3 + +class MainWin (KMainWindow): + def __init__ (self, *args): + apply (KMainWindow.__init__, (self,) + args) + + self.initActions () + self.createGUI () + self.initStatusBar () + + self.saveAction.setEnabled (False) + self.saveAsAction.setEnabled (False) + + def initActions (self): + # "File" menu items + self.newAction = KStdAction.openNew (self.slotNew, self.actionCollection ()) + self.openAction = KStdAction.open (self.slotOpen, self.actionCollection ()) + self.saveAction = KStdAction.save (self.slotSave, self.actionCollection ()) + self.saveAsAction = KStdAction.saveAs (self.slotSaveAs, self.actionCollection ()) + self.printAction = KStdAction.print_ (self.slotPrint, self.actionCollection ()) + self.quitAction = KStdAction.quit (self.slotQuit, self.actionCollection ()) + + + # "Edit" menu items + self.undoAction = KStdAction.undo (self.slotUndo, self.actionCollection ()) + self.redoAction = KStdAction.redo (self.slotRedo, self.actionCollection ()) + self.cutAction = KStdAction.cut (self.slotCut, self.actionCollection ()) + self.copyAction = KStdAction.copy (self.slotCopy, self.actionCollection ()) + self.pasteAction = KStdAction.paste (self.slotPaste, self.actionCollection ()) + self.findAction = KStdAction.find (self.slotFind, self.actionCollection ()) + self.findNextAction = KStdAction.findNext (self.slotFindNext, self.actionCollection ()) + self.replaceAction = KStdAction.replace (self.slotReplace, self.actionCollection ()) + self.specialAction = KAction (i18n ("Special"), KShortcut.null (), self.slotSpecial, self.actionCollection (), "specialActionName") + + def initStatusBar (self): + self.statusBar ().insertItem ("", STATUSBAR_LEFT, 1000, True) + self.statusBar ().insertItem ("", STATUSBAR_MIDDLE, 1000, True) + self.statusBar ().insertItem ("", STATUSBAR_RIGHT, 1000, True) + +#-------------------- slots ----------------------------------------------- + + def slotNew (self, id = -1): + self.notImpl ("New") + + def slotOpen(self, id = -1): + self.notImpl ("Open") + + def slotSave (self, id = -1): + self.notImpl ("Save") + + def slotSaveAs (self): + self.notImpl ("Save As") + + def slotPrint (self): + self.notImpl ("Print") + + def slotQuit (self): + self.notImpl ("Quit") + + def slotUndo (self): + self.notImpl ("Undo") + + def slotRedo (self): + self.notImpl ("Redo") + + def slotCut (self, id = -1): + self.notImpl ("Cut") + + def slotCopy (self, id = -1): + self.notImpl ("Copy") + + def slotPaste (self, id = -1): + self.notImpl ("Paste") + + def slotFind (self): + self.notImpl ("Find") + + def slotFindNext (self): + self.notImpl ("Find Next") + + def slotReplace (self): + self.notImpl ("Replace") + + def slotSpecial (self): + self.notImpl ("Special") + + def notImpl (self, item = "Feature"): + self.statusBar ().changeItem ("%s not implemented" % item, STATUSBAR_LEFT) + KMessageBox.error (self, "%s not implemented" % item, "Not Implemented") + self.statusBar ().changeItem ("", STATUSBAR_LEFT) + + +#-------------------- main ------------------------------------------------ + +description = "A basic application template" +version = "1.0" +aboutData = KAboutData ("menuapp3", "",\ + version, description, KAboutData.License_GPL,\ + "(C) 2003 whoever the author is") + +aboutData.addAuthor ("author1", "whatever they did", "email@somedomain") +aboutData.addAuthor ("author2", "they did something else", "[email protected]") + +KCmdLineArgs.init (sys.argv, aboutData) + +KCmdLineArgs.addCmdLineOptions ([("+files", "File to open")]) + +app = KApplication () +mainWindow = MainWin (None, "main window") +mainWindow.show() +app.exec_loop() + diff --git a/templates/basic/menuapp3ui.rc b/templates/basic/menuapp3ui.rc new file mode 100644 index 0000000..60120e2 --- /dev/null +++ b/templates/basic/menuapp3ui.rc @@ -0,0 +1,24 @@ +<!DOCTYPE kpartgui> +<kpartgui name = "menuapp3"> +<MenuBar> + <Menu name="file"><text>&File</text> + <Action name ="newAction"/> + <Action name ="openAction"/> + <Action name ="saveAction"/> + <Action name ="saveAsAction"/> + <Action name ="printAction"/> + <Action name ="quitAction"/> + </Menu> + <Menu name = "edit"><text>&Edit</text> + <Action name ="undoAction"/> + <Action name ="redoAction"/> + <Action name ="cutAction"/> + <Action name ="copyAction"/> + <Action name ="pasteAction"/> + <Action name ="findAction"/> + <Action name ="findNextAction"/> + <Action name ="replaceAction"/> + <Action name ="specialActionName"/> + </Menu> +</MenuBar> +</kpartgui>
\ No newline at end of file diff --git a/templates/basic/minimal.py b/templates/basic/minimal.py new file mode 100644 index 0000000..72ff3be --- /dev/null +++ b/templates/basic/minimal.py @@ -0,0 +1,48 @@ +""" +Copyright 2003 Jim Bublitz + +Terms and Conditions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Except as contained in this notice, the name of the copyright holder shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from the +copyright holder. +""" + +import sys + +from kdecore import KApplication +from kdeui import KMainWindow + +class MainWin (KMainWindow): + def __init__ (self, *args): + apply (KMainWindow.__init__, (self,) + args) + + +#-------------------- main ------------------------------------------------ + +appName = "template" +app = KApplication (sys.argv, appName) +mainWindow = MainWin (None, "main window") +mainWindow.show() +app.exec_loop() + + diff --git a/templates/basic/panelapplet.py b/templates/basic/panelapplet.py new file mode 100644 index 0000000..4ac8016 --- /dev/null +++ b/templates/basic/panelapplet.py @@ -0,0 +1,49 @@ +""" +A basic panel applet template - working examples are in the +pykpanelapplet/ directory +""" +""" +Copyright 2003 Jim Bublitz + +Terms and Conditions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Except as contained in this notice, the name of the copyright holder shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from the +copyright holder. +""" + +from kdeui import PyKPanelApplet, KPanelApplet + + +def createApplet (parent, configFile): + return PanelAppletName (configFile, KPanelApplet.Normal, 0, parent, "nameMe") + + +class PanelAppletName (PyKPanelApplet): + def __init__ (self, configFile, t, actions, parent, name, f = 0): + PyKPanelApplet.__init__ (self, configFile, t, actions, parent, name, f) + + def widthForHeight (self, h): + return h + + def heightForWidth (self, w ): + return w diff --git a/templates/basic/systray.py b/templates/basic/systray.py new file mode 100644 index 0000000..1363dac --- /dev/null +++ b/templates/basic/systray.py @@ -0,0 +1,61 @@ +""" +Copyright 2003 Jim Bublitz + +Terms and Conditions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Except as contained in this notice, the name of the copyright holder shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from the +copyright holder. +""" + +import sys + +from qt import QWidget, SIGNAL +from kdecore import KApplication, KIcon, KIconLoader +from kdeui import KSystemTray + + +class MainWin (QWidget): + def __init__ (self, *args): + apply (QWidget.__init__, (self,) + args) + +#-------------------- main ------------------------------------------------ + +def slotQuitSelected (): + KApplication.kApplication ().quit () + +appName = "template" +app = KApplication (sys.argv, appName) +mainWindow = MainWin (None, "main window") + +icons = KIconLoader () + +systray = KSystemTray (mainWindow) + +systray.setPixmap (icons.loadIcon("stop", KIcon.Desktop)) +systray.connect (systray, SIGNAL ("quitSelected ()"), slotQuitSelected) +systray.show () + +mainWindow.show() +app.exec_loop() + + diff --git a/templates/basic/systray1.py b/templates/basic/systray1.py new file mode 100644 index 0000000..bd5da9d --- /dev/null +++ b/templates/basic/systray1.py @@ -0,0 +1,67 @@ +""" +Copyright 2003 Jim Bublitz + +Terms and Conditions + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Except as contained in this notice, the name of the copyright holder shall +not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from the +copyright holder. +""" + +import sys + +from qt import QLabel, QWidget, SIGNAL +from kdecore import KApplication, KIcon, KIconLoader +from kdeui import KMainWindow, KSystemTray + +class MainWin (KMainWindow): + def __init__ (self, *args): + apply (KMainWindow.__init__, (self,) + args) + + self.exitFlag = False + + icons = KIconLoader () + + self.systray = KSystemTray (self) + self.systray.setPixmap (icons.loadIcon("stop", KIcon.Desktop)) + self.systray.connect (self.systray, SIGNAL ("quitSelected ()"), self.slotQuitSelected) + self.systray.show () + + def queryClose (self): + self.hide () + return self.exitFlag + + def slotQuitSelected (self): + self.exitFlag = True + KApplication.kApplication ().quit () + +#-------------------- main ------------------------------------------------ + + +appName = "template" +app = KApplication (sys.argv, appName) +mainWindow = MainWin (None, "main window") + +mainWindow.show() +app.exec_loop() + + |