summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-16 09:06:37 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-08-16 09:06:37 +0000
commit39d98386f72c65826e162e3e8fd36752ec469252 (patch)
tree5cec746207c4c892d064beafca1de94568a3aeb9 /examples
downloadpytde-39d98386f72c65826e162e3e8fd36752ec469252.tar.gz
pytde-39d98386f72c65826e162e3e8fd36752ec469252.zip
Move python-kde3 to the more correct python-trinity
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/libraries/python-trinity@1247483 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'examples')
-rw-r--r--examples/README17
-rw-r--r--examples/aboutkde.pngbin0 -> 33856 bytes
-rw-r--r--examples/astron.pngbin0 -> 32329 bytes
-rw-r--r--examples/example_dcopexport.py136
-rw-r--r--examples/example_dcopext.py135
-rw-r--r--examples/kdeform1.ui335
-rw-r--r--examples/kdeform1.ui.h13
-rw-r--r--examples/kpartgui.dtd122
-rw-r--r--examples/kurldemo.py98
-rw-r--r--examples/menudemo.py291
-rw-r--r--examples/mimetype.py269
-rw-r--r--examples/pyKHTMLPart.py214
-rw-r--r--examples/pykde-sampler/HOWTO.samples60
-rw-r--r--examples/pykde-sampler/TODO12
-rw-r--r--examples/pykde-sampler/__init__.py1
-rw-r--r--examples/pykde-sampler/about.py57
-rw-r--r--examples/pykde-sampler/aboutkde.pngbin0 -> 36986 bytes
-rw-r--r--examples/pykde-sampler/basic_widgets/__init__.py17
-rw-r--r--examples/pykde-sampler/basic_widgets/datepicker.py42
-rw-r--r--examples/pykde-sampler/basic_widgets/historycombo.py53
-rw-r--r--examples/pykde-sampler/contributors.txt4
-rw-r--r--examples/pykde-sampler/dialogs/__init__.py18
-rw-r--r--examples/pykde-sampler/dialogs/about/__init__.py16
-rw-r--r--examples/pykde-sampler/dialogs/about/aboutapp.py29
-rw-r--r--examples/pykde-sampler/dialogs/about/aboutkde.py28
-rw-r--r--examples/pykde-sampler/dialogs/bugreport.py34
-rw-r--r--examples/pykde-sampler/dialogs/color.py42
-rw-r--r--examples/pykde-sampler/dialogs/config.py59
-rw-r--r--examples/pykde-sampler/dialogs/edfind.py52
-rw-r--r--examples/pykde-sampler/dialogs/edreplace.py52
-rw-r--r--examples/pykde-sampler/dialogs/font.py53
-rw-r--r--examples/pykde-sampler/dialogs/input.py87
-rw-r--r--examples/pykde-sampler/dialogs/key.py29
-rw-r--r--examples/pykde-sampler/dialogs/msgbox.py141
-rw-r--r--examples/pykde-sampler/dialogs/passwd.py34
-rw-r--r--examples/pykde-sampler/dialogs/progress.py39
-rw-r--r--examples/pykde-sampler/dialogs/tip.py31
-rw-r--r--examples/pykde-sampler/dialogs/tips24
-rw-r--r--examples/pykde-sampler/gen_todo.py19
-rw-r--r--examples/pykde-sampler/icon_handling/__init__.py18
-rw-r--r--examples/pykde-sampler/icon_handling/misc.py31
-rw-r--r--examples/pykde-sampler/icon_handling/sizes.py30
-rw-r--r--examples/pykde-sampler/lib.py105
-rw-r--r--examples/pykde-sampler/misc/__init__.py16
-rw-r--r--examples/pykde-sampler/misc/gradientselect.py51
-rw-r--r--examples/pykde-sampler/misc/passivepop.py43
-rw-r--r--examples/pykde-sampler/misc/window_info.py35
-rw-r--r--examples/pykde-sampler/qt_widgets/CONTRIB537
-rw-r--r--examples/pykde-sampler/qt_widgets/__init__.py17
-rw-r--r--examples/pykde-sampler/qt_widgets/table.py42
-rwxr-xr-xexamples/pykde-sampler/runner.py58
-rwxr-xr-xexamples/pykde-sampler/sampler.py423
-rw-r--r--examples/pykde-sampler/sampler.rc13
-rw-r--r--examples/pykde-sampler/wizards/__init__.py2
-rw-r--r--examples/pykde-sampler/wizards/wiz.py2
-rw-r--r--examples/pykde-sampler/xwin/__init__.py18
-rw-r--r--examples/pytestimage.pngbin0 -> 36986 bytes
-rw-r--r--examples/qxembed_example.pngbin0 -> 22146 bytes
-rw-r--r--examples/qxembedexample.py79
-rw-r--r--examples/qxembedexample.ui150
-rw-r--r--examples/systray.py54
-rw-r--r--examples/uikmdi.py203
-rw-r--r--examples/uikmdi.rc11
-rw-r--r--examples/uimodules/uidialogs.py232
-rw-r--r--examples/uimodules/uimenus.py108
-rw-r--r--examples/uimodules/uimisc.py239
-rw-r--r--examples/uimodules/uiwidgets.py754
-rw-r--r--examples/uimodules/uixml.py45
-rw-r--r--examples/uiqxembed.py119
-rw-r--r--examples/uisampler.py227
-rw-r--r--examples/xmlmenudemo.py291
-rw-r--r--examples/xmlmenudemoui.rc49
72 files changed, 6665 insertions, 0 deletions
diff --git a/examples/README b/examples/README
new file mode 100644
index 0000000..24a7ac3
--- /dev/null
+++ b/examples/README
@@ -0,0 +1,17 @@
+This subdirectory contains a few executable Python
+programs that demonstrate or test some features of
+PyKDE:
+
+uisampler.py - demos of most of the kdeui widgets,
+ including dialogs, menus (KAction, KStdAction, etc)
+ widgets, and xml ui definition
+
+mimetest.py - tests KSharedPtr related classes/methods
+ such as KMimetype, KService, etc
+
+menudemo.py
+xmlmenudemo.py - demostrate the construction of a
+ menu based app (also run as part of uisampler.py)
+
+More demo programs are planned - contributions are
+welcome.
diff --git a/examples/aboutkde.png b/examples/aboutkde.png
new file mode 100644
index 0000000..2b4681c
--- /dev/null
+++ b/examples/aboutkde.png
Binary files differ
diff --git a/examples/astron.png b/examples/astron.png
new file mode 100644
index 0000000..d2797ec
--- /dev/null
+++ b/examples/astron.png
Binary files differ
diff --git a/examples/example_dcopexport.py b/examples/example_dcopexport.py
new file mode 100644
index 0000000..66aff6a
--- /dev/null
+++ b/examples/example_dcopexport.py
@@ -0,0 +1,136 @@
+#!/usr/bin/env python
+
+"""
+Copyright 2004 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.
+"""
+
+# This is an example of a DCOP enabled application written in Python, using
+# PyKDE and the dcopexport module. Taken from server.py example in kde-bindings
+# which was written by Torben Weis and Julian Rockey
+
+import sys
+from kdecore import KApplication, KCmdLineArgs, KAboutData
+from dcopexport import DCOPExObj
+from qt import QString, QStringList
+
+"""
+DCOPExObj provides all of the necessary machinery to DCOP-enable
+an application: the 'process' method, marshalling/demarshalling,
+and the 'features' method
+
+To DCOP-enable an app,
+
+ 1. Add a class which subclasses DCOPExObj (ParrotObject in
+ this case). Call the DCOPExObj.__init__ method with 'id'.
+ If 'id' isn't specified, DCOP will assing a numerical id.
+ 'id' is the name of the object (eg, how it will be listed
+ in kdcop, or returned with a dcopClient.remoteObjects call)
+
+ 2. Identify the methods/functions that will be exposed via
+ DCOP - they don't have to be methods of the DCOPExObj
+ class, as long as the DCOPExObj class can call them. Make
+ sure they take/return types that DCOPExObj supports.
+
+ 3. For each method, call self.addMethod with the complete
+ method signature (return type, name, list of argument
+ types, but no argument names) as a string and the
+ Python method/function that corresponds.
+
+ 4. That's it.
+"""
+
+# the class which will expose methods to DCOP - the methods do NOT
+# need to be a member of this class.
+class DeadParrotObject (DCOPExObj):
+ def __init__ (self, id = 'dead parrot'):
+ DCOPExObj.__init__ (self, id)
+
+ # the methods available from this app via DCOP
+ # addMethod (<signature>, <Python method>)
+ self.addMethod ('QString getParrotType()', self.get_type)
+ self.addMethod ('void setParrotType (QString)', self.set_type)
+ self.addMethod ('QString squawk()', self.squawk)
+ self.addMethod ('QStringList adjectives()', self.adjectives)
+
+ # set up object variables
+ self.parrot_type = QString ("Norwegian Blue")
+
+ def get_type (self):
+ return self.parrot_type
+
+ def set_type (self, parrot_type):
+ self.parrot_type = parrot_type
+
+ def squawk (self):
+ return "This parrot, a %s, is pining for the fjords" % (self.parrot_type)
+
+ def adjectives (self):
+ adjList = ["passed on", "is no more", "ceased to be", "expired", "gone to meet his maker",
+ "a stiff", "bereft of life", "rests in peace", "metabolic processes are now history",
+ "off the twig", "kicked the bucket", "shuffled off his mortal coil",
+ "run down his curtain", "joined the bleedin' choir invisible", "THIS IS AN EX-PARROT"]
+ qadjList = QStringList ()
+ for adj in adjList:
+ qadjList.append (adj)
+
+ return qadjList
+
+description = "A basic application template"
+version = "1.0"
+aboutData = KAboutData ("testdcopexport", "petshop",\
+ 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", "another@email.address")
+
+KCmdLineArgs.init (sys.argv, aboutData)
+
+KCmdLineArgs.addCmdLineOptions ([("+files", "File to open")])
+
+app = KApplication ()
+dcop = app.dcopClient ()
+appid = dcop.registerAs('petshop')
+print "DCOP Application: %s starting" % appid
+
+parrot = DeadParrotObject()
+another_parrot = DeadParrotObject('polly')
+
+print """
+Run kdcop and look for the 'petshop' application instance.
+
+This program exports the 'deadParrot' and 'polly' objects.
+Double-clicking those object's methods will allow you to get or set data.
+
+To end the application, in kdcop choose the MainApplication-Interface
+object and double-click the quit() method.
+"""
+
+app.exec_loop()
+
+
diff --git a/examples/example_dcopext.py b/examples/example_dcopext.py
new file mode 100644
index 0000000..8f3801a
--- /dev/null
+++ b/examples/example_dcopext.py
@@ -0,0 +1,135 @@
+"""
+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, time
+import dcop
+import dcopext
+from kdecore import KApplication, KCmdLineArgs, KAboutData
+from qt import QString, QCString
+
+
+
+def getAnyApplication (client, appName):
+ for qcstring_app in client.registeredApplications ():
+ app = str (qcstring_app)
+ if app == appName or app.startswith (appName + "-"):
+ print app
+ print
+ objList, ok = client.remoteObjects (app)
+ for obj in objList:
+ print " ", obj
+ funcs, ok = client.remoteFunctions (app, obj)
+ for f in funcs:
+ print " ", " ", f
+ break
+
+
+#-------------------- main ------------------------------------------------
+
+description = "A basic application template"
+version = "1.0"
+aboutData = KAboutData ("testdcopext", "testdcopext",\
+ 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", "another@email.address")
+
+KCmdLineArgs.init (sys.argv, aboutData)
+
+KCmdLineArgs.addCmdLineOptions ([("+files", "File to open")])
+
+app = KApplication ()
+dcop = app.dcopClient ()
+
+#getAnyApplication (dcop, "konqueror")
+print "--------------------------"
+print "The DCOPObjects for kicker:"
+d = dcopext.DCOPApp ("kicker", dcop)
+objs = d.objects
+if objs:
+ for obj in objs:
+ print obj
+o = d.object ("Panel")
+methods = o.methods
+for method in methods:
+ print method
+m = o.method ("addNonKDEAppButton")
+
+print "--------------------------"
+print "The method"
+print o.method
+print "--------------------------"
+print "Find the method:"
+print m.findMethod ()
+print "--------------------------"
+print "The return type:"
+print m.rtype
+print "--------------------------"
+print "The argument types:"
+print m.argtypes
+print "--------------------------"
+print "The argument names:"
+print m.argnames
+print "--------------------------"
+
+print
+print "get kicker panel size via DCOP"
+res = d.Panel.panelSize()
+print res, d.Panel.panelSize.valid
+print "--------------------------"
+
+print "Call a method that doesn't exist"
+res = d.Panel.junk ()
+print res
+print "--------------------------"
+
+print "See if a non-existent method is valid"
+print d.Panel.junk.valid
+print
+print "--------------------------"
+
+print
+print
+print "Start a kwrite instance"
+errcode, error, dcopService, pid = KApplication.startServiceByDesktopName ("kwrite", "")
+dcopService = "kwrite-" + str (pid)
+print "errcode: %i error: %s dcopService: %s pid: %i" % (errcode, error, dcopService, pid)
+print "--------------------------"
+time.sleep (2)
+
+o1 = dcopext.DCOPObj (dcopService, dcop, "EditInterface#1")
+print "Check if insertLine is a valid function"
+print "valid", o1.insertLine.valid
+print "--------------------------"
+print "insertLine's arg types and names"
+print o1.insertLine.argtypes, o1.insertLine.argnames
+print "--------------------------"
+print "Insert a line into the kwrite instance we launched"
+print "call returns:", o1.insertLine (0, "Now is the time for all good men to come to the aid of their party")
diff --git a/examples/kdeform1.ui b/examples/kdeform1.ui
new file mode 100644
index 0000000..3d7a36e
--- /dev/null
+++ b/examples/kdeform1.ui
@@ -0,0 +1,335 @@
+<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
+<class>Form1</class>
+<comment>Python:#import all necessary widgets
+Python:from kfile import KURLRequester</comment>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>497</width>
+ <height>485</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Form1</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>6</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KLed" row="0" column="0">
+ <property name="name">
+ <cstring>KLed1</cstring>
+ </property>
+ </widget>
+ <widget class="KLed" row="0" column="1">
+ <property name="name">
+ <cstring>KLed2</cstring>
+ </property>
+ <property name="color">
+ <color>
+ <red>255</red>
+ <green>255</green>
+ <blue>0</blue>
+ </color>
+ </property>
+ </widget>
+ <widget class="KLed" row="0" column="2">
+ <property name="name">
+ <cstring>KLed3</cstring>
+ </property>
+ <property name="color">
+ <color>
+ <red>255</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </property>
+ </widget>
+ <widget class="KSqueezedTextLabel" row="0" column="3">
+ <property name="name">
+ <cstring>KSqueezedTextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>KSqueezedTextLa...h a lot of text</string>
+ </property>
+ </widget>
+ <spacer row="0" column="4" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>231</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QFrame" row="1" column="0" rowspan="1" colspan="6">
+ <property name="name">
+ <cstring>Frame3</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Raised</enum>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KURLLabel" row="0" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>KURLLabel1</cstring>
+ </property>
+ <property name="url" stdset="0">
+ <string>http://KURLLabel.org</string>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>KURLRequester1</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>KLineEdit1</cstring>
+ </property>
+ <property name="text">
+ <string>KLineEdit1</string>
+ </property>
+ </widget>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>Spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KProgress" row="3" column="1">
+ <property name="name">
+ <cstring>KProgress1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <spacer row="3" column="2">
+ <property name="name">
+ <cstring>Spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>80</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="2" column="0" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>GroupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>GroupBox1</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KHistoryCombo" row="0" column="0">
+ <property name="name">
+ <cstring>KHistoryCombo1</cstring>
+ </property>
+ <property name="historyItems">
+ <stringlist>
+ <string>first, second, last</string>
+ </stringlist>
+ </property>
+ </widget>
+ <widget class="KDatePicker" row="1" column="0">
+ <property name="name">
+ <cstring>KDatePicker1</cstring>
+ </property>
+ <property name="date">
+ <date>
+ <year>2003</year>
+ <month>4</month>
+ <day>22</day>
+ </date>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="3" column="0" rowspan="1" colspan="6">
+ <property name="name">
+ <cstring>GroupBox3</cstring>
+ </property>
+ <property name="title">
+ <string>GroupBox3</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KComboBox" row="0" column="0">
+ <property name="name">
+ <cstring>KComboBox1</cstring>
+ </property>
+ <property name="contextMenuEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="urlDropsEnabled" stdset="0">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox" row="0" column="1">
+ <property name="name">
+ <cstring>KIntSpinBox1</cstring>
+ </property>
+ <property name="value">
+ <number>7</number>
+ </property>
+ </widget>
+ <widget class="KFontCombo" row="0" column="2">
+ <property name="name">
+ <cstring>KFontCombo2</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="2" column="4" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>GroupBox4</cstring>
+ </property>
+ <property name="title">
+ <string>GroupBox4</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="KListView" row="0" column="0">
+ <property name="name">
+ <cstring>KListView1</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QPushButton" row="5" column="5">
+ <property name="name">
+ <cstring>PushButton1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ <property name="on">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <spacer row="5" column="0" rowspan="1" colspan="5">
+ <property name="name">
+ <cstring>Spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>372</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>PushButton1</sender>
+ <signal>clicked()</signal>
+ <receiver>Form1</receiver>
+ <slot>PushButton1_clicked()</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">kdeform1.ui.h</include>
+</includes>
+<slots>
+ <slot>PushButton1_clicked()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="6"/>
+</UI>
diff --git a/examples/kdeform1.ui.h b/examples/kdeform1.ui.h
new file mode 100644
index 0000000..96bc326
--- /dev/null
+++ b/examples/kdeform1.ui.h
@@ -0,0 +1,13 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename slots use Qt Designer which will
+** update this file, preserving your code. Create an init() slot in place of
+** a constructor, and a destroy() slot in place of a destructor.
+*****************************************************************************/
+
+
+void Form1::PushButton1_clicked()
+{
+qApp.exit(0)
+}
diff --git a/examples/kpartgui.dtd b/examples/kpartgui.dtd
new file mode 100644
index 0000000..b338964
--- /dev/null
+++ b/examples/kpartgui.dtd
@@ -0,0 +1,122 @@
+<!-- Originally Copyright (c) 2000 Federico David Sacerdoti <tech@slinuxmachines.com>
+ Modifications/Extensions by Simon Hausmann <hausmann@kde.org>
+
+ This DTD module is identified by the PUBLIC and SYSTEM
+ identifiers:
+ PUBLIC "-//KDE Project//KPartGUI DTD//EN"
+ SYSTEM "kpartgui.dtd"
+
+ This DTD should be included at the head of an xmlguibuilder XML file like this:
+ <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+-->
+
+<!--The root element that must enclose all other tags in the document. -->
+<!ELEMENT kpartgui ((ActionProperties | MenuBar | ToolBar | Merge | DefineGroup | MainWindow | StatusBar | Menu)*)>
+<!ATTLIST kpartgui
+ name CDATA #REQUIRED
+ version CDATA #REQUIRED
+ library CDATA #IMPLIED
+>
+
+<!-- Allows standard actions to be customized -->
+<!ELEMENT ActionProperties (Action+)>
+
+<!-- A menu bar -->
+<!ELEMENT MenuBar ((Menu | Separator | Action | ActionList | Merge | DefineGroup )*)>
+<!ATTLIST MenuBar
+ name CDATA #IMPLIED
+ group CDATA #IMPLIED
+>
+
+<!-- A tool bar
+ -- Attributes: name: a unique name for the toolbar, use mainToolBar for the main one
+ -- fullWidth: if true (default), the toolbar extends to the full width of the window
+ -- position: the position of the toolbar in the window
+ -- iconText: whether to show icon or text or both
+ -- iconSize: the size of the icons (0 for default, or usually 22 or 32)
+ -- index: the index in the toolbar dock (see QMainWindow::moveToolBar)
+ -- offset: the X offset in the toolbar dock (see QMainWindow::moveToolBar)
+ -- newline: if true, this toolbar will start a new line (i.e. under the ones before it).
+ -- group: optional group name, for named merging (?)
+ -- hidden: if true, the toolbar is initially hidden. There should be a menu entry for showing it.
+ -- noEdit: if true, the toolbar won't appear in the toolbar editor
+ -->
+<!ELEMENT ToolBar ((Action | Separator | ActionList | Merge | DefineGroup)*)>
+<!ATTLIST ToolBar
+ name CDATA #REQUIRED
+ fullWidth (true|false) "true"
+ position (top|bottom|left|right) "top"
+ iconText (icononly|textonly|icontextright|icontextbottom) #IMPLIED
+ iconSize CDATA #IMPLIED
+ index CDATA #IMPLIED
+ offset CDATA #IMPLIED
+ newline (true|false) "false"
+ group CDATA #IMPLIED
+ hidden (true|false) "false"
+ noEdit (true|false) "false"
+>
+
+<!-- A Menu such as the "File" or "Edit" menu. Can be used to define popup menus as well. -->
+<!ELEMENT Menu (text?, (Action | ActionList | Separator | TearOffHandle | Merge | DefineGroup | Menu )*)>
+<!ATTLIST Menu
+ name CDATA #REQUIRED
+ group CDATA #IMPLIED
+ icon CDATA #IMPLIED
+>
+
+<!-- Defines both Standard and app-specific actions. An action can appear in a menu, a toolbar or in a
+ menubar . -->
+<!ELEMENT Action EMPTY>
+<!-- We defined only a few standard KAction properties here. Theoritically we can have
+ any property here -->
+<!ATTLIST Action
+ name CDATA #REQUIRED
+ group CDATA #IMPLIED
+ text CDATA #IMPLIED
+ whatsThis CDATA #IMPLIED
+ toolTip CDATA #IMPLIED
+ shortText CDATA #IMPLIED
+ icon CDATA #IMPLIED
+>
+
+<!-- Inserts a separator item into a menubar or toolbar -->
+<!ELEMENT Separator EMPTY>
+<!ATTLIST Separator
+ lineSeparator (true|false) "false"
+ group CDATA #IMPLIED
+>
+
+<!-- Inserts a tear-off handle into a menu -->
+<!ELEMENT TearOffHandle EMPTY>
+<!ATTLIST TearOffHandle
+ group CDATA #IMPLIED
+>
+
+<!-- Used to name a menu, the first letter in is generally preceded by an '&' to specify
+ the menu's shortcut key -->
+<!ELEMENT text (#PCDATA)>
+
+<!-- Specifies a dynamic list of actions, each of which can be changed by plugging/unplugging it -->
+<!ELEMENT ActionList EMPTY>
+<!ATTLIST ActionList
+ name CDATA #REQUIRED
+>
+
+<!-- Not explicitly defined or in widely used yet. -->
+<!ELEMENT MainWindow (ANY)>
+
+<!-- Not explicitly defined or in widely used yet. -->
+<!ELEMENT StatusBar (ANY)>
+
+<!-- Specifies the entry index for merging in a gui client -->
+<!ELEMENT Merge EMPTY>
+<!ATTLIST Merge
+ name CDATA #IMPLIED
+>
+
+<!-- Specifies a entry index for merging, similar to the Merge tag, but with a global scope and
+ accessible via the group attribute of other tags -->
+<!ELEMENT DefineGroup EMPTY>
+<!ATTLIST DefineGroup
+ name CDATA #REQUIRED
+>
diff --git a/examples/kurldemo.py b/examples/kurldemo.py
new file mode 100644
index 0000000..d224b34
--- /dev/null
+++ b/examples/kurldemo.py
@@ -0,0 +1,98 @@
+"""
+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.
+"""
+
+urls = ["http://slashdot.org", "http://www.kde.org", "http://www.riverbankcomputing.co.uk", "http://yahoo.com"]
+
+import sys
+
+from kdecore import KApplication, KCmdLineArgs, KAboutData, KURL
+from kdeui import KMainWindow, KEdit
+
+class MainWin (KMainWindow):
+ def __init__ (self, *args):
+ apply (KMainWindow.__init__, (self,) + args)
+
+ self.setGeometry (0, 0, 400, 600)
+
+ self.edit = KEdit (self)
+ self.setCentralWidget (self.edit)
+
+ self.edit.insertLine ("KURL Demo\n")
+ self.edit.insertLine ("Adding these urls:\n")
+ for url in urls:
+ self.edit.insertLine (" %s" % url)
+
+ self.edit.insertLine ("\nCreating KURLs (iterating to print):\n")
+ urlList = KURL.List ()
+ for url in urls:
+ urlList.append (KURL (url))
+
+ for url in urlList:
+ self.edit.insertLine (" %s" % url.url ())
+
+ self.edit.insertLine ("\nFirst url -- urlList [0]:\n")
+ self.edit.insertLine (" " + str (urlList [0]))
+ self.edit.insertLine (" " + str (urlList [0].url ()))
+
+ self.edit.insertLine ("\nLast url -- urlList [-1]:\n")
+ self.edit.insertLine (" " + str (urlList [-1]))
+ self.edit.insertLine (" " + str (urlList [-1].url ()))
+
+ self.edit.insertLine ("\nMiddle urls -- urlList [2:4]:\n")
+ ulist = urlList [2:4]
+ for url in ulist:
+ self.edit.insertLine (" " + str (url))
+ self.edit.insertLine (" " + str (url.url ()))
+
+ self.edit.insertLine ("\nLength of urlList -- len (urlList):\n")
+ self.edit.insertLine (" Length = %i" % len (urlList))
+
+ self.edit.insertLine ('\nurl in urlList? -- KURL ("http://yahoo.com") in urlList\n')
+ self.edit.insertLine (' KURL ("http://yahoo.com") in urlList = %i' % (KURL ("http://yahoo.com") in urlList))
+
+
+#-------------------- 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", "another@email.address")
+
+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/examples/menudemo.py b/examples/menudemo.py
new file mode 100644
index 0000000..61a591a
--- /dev/null
+++ b/examples/menudemo.py
@@ -0,0 +1,291 @@
+"""
+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, QLabel, QIconSet
+
+from kdecore import KApplication, KCmdLineArgs, KAboutData, i18n, KIcon, KIconLoader, KShortcut
+from kdeui import KMainWindow, KMessageBox, KStdAction, KAction, KToggleAction, KFontSizeAction, KFontAction, KRadioAction,\
+ KActionSeparator, KActionMenu, KWindowListMenu
+
+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 (), "special")
+
+ # Demo menu items
+
+ # KToggleAction has an isChecked member and emits the "toggle" signal
+ self.toggle1Action = KToggleAction ("Toggle 1")
+ self.toggle2Action = KToggleAction ("Toggle 2", KShortcut.null (), self.slotToggle2, None)
+
+ # A separator - create once/use everywhere
+ self.separateAction = KActionSeparator ()
+
+ # Font stuff in menus or toolbar
+ self.fontAction = KFontAction ("Font")
+ self.fontSizeAction = KFontSizeAction ("Font Size")
+
+ # Need to assign an icon to actionMenu below
+ icons = KIconLoader ()
+ iconSet = QIconSet (icons.loadIcon ("viewmag", KIcon.Toolbar))
+
+ # Nested menus using KActions (also nested on toolbar)
+ self.actionMenu = KActionMenu ("Action Menu")
+ self.actionMenu.setIconSet (iconSet)
+ self.actionMenu.insert (KStdAction.zoomIn (self.slotZoomIn, self.actionCollection ()))
+ self.actionMenu.insert (KStdAction.zoomOut (self.slotZoomOut, self.actionCollection ()))
+
+ # Doesn't work in KDE 2.1.1
+# self.radio1Action = KRadioAction ("Radio 1")
+# self.radio1Action.setExclusiveGroup ("Radio")
+# self.radio2Action = KRadioAction ("Radio 2")
+# self.radio2Action.setExclusiveGroup ("Radio")
+# self.radio3Action = KRadioAction ("Radio 3")
+# self.radio3Action.setExclusiveGroup ("Radio")
+
+ 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)
+
+ demoMenu = QPopupMenu (self)
+ self.toggle1Action.plug (demoMenu)
+ self.toggle2Action.plug (demoMenu)
+ self.separateAction.plug (demoMenu)
+ self.fontAction.plug (demoMenu)
+ self.fontSizeAction.plug (demoMenu)
+ self.actionMenu.plug (demoMenu)
+# self.radio1Action.plug (demoMenu)
+# self.radio2Action.plug (demoMenu)
+# self.radio3Action.plug (demoMenu)
+ self.menuBar ().insertItem (i18n ("&Demo"), demoMenu)
+
+ # This really belongs in Kicker, not here,
+ # but it actually works
+ wlMenu = KWindowListMenu (self)
+ wlMenu.init ()
+ self.menuBar ().insertItem (i18n ("&WindowListMenu"), wlMenu)
+
+
+
+ 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 ())
+
+ self.separateAction.plug (self.toolBar ())
+ self.separateAction.plug (self.toolBar ())
+ self.separateAction.plug (self.toolBar ())
+
+ self.fontAction.plug (self.toolBar ())
+ self.separateAction.plug (self.toolBar ())
+ self.fontAction.setComboWidth (150)
+
+ self.fontSizeAction.plug (self.toolBar ())
+ self.fontSizeAction.setComboWidth (75)
+
+ self.separateAction.plug (self.toolBar ())
+
+ # This works, but you have to hold down the
+ # button in the toolbar and wait a bit
+ self.actionMenu.plug (self.toolBar ())
+ # This appears to do nothing
+ self.actionMenu.setDelayed (False)
+
+ # Need this to keep the font comboboxes from stretching
+ # to the full width of the toolbar when the window is
+ # maximized (comment out the next two lines to see
+ # what happens)
+ stretchlbl = QLabel ("", self.toolBar ())
+ self.toolBar ().setStretchableWidget (stretchlbl)
+
+
+# self.toolBar ().setHorizontalStretchable (False)
+
+
+ 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 slotToggle2 (self):
+ self.notImpl ("Toggle")
+
+ def slotZoomIn (self):
+ self.notImpl ("Zoom In")
+
+ def slotZoomOut (self):
+ self.notImpl ("Zoom Out")
+
+ def notImpl (self, item):
+ 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", "another@email.address")
+
+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/examples/mimetype.py b/examples/mimetype.py
new file mode 100644
index 0000000..d1926b0
--- /dev/null
+++ b/examples/mimetype.py
@@ -0,0 +1,269 @@
+"""
+This program tests/demos some of the KSharedPtr related classes and
+methods (KMimeType, KService, etc). It generally tests the *::List
+methods for these classes (eg KService::List) since that also tests
+the *::Ptr mapped type code (eg KService::Ptr) at the same time.
+
+This version is suitable for KDE >= 3.0.0 (some methods not available
+in earlier versions)
+"""
+
+"""
+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, QButtonGroup, Qt, QLabel, QListView, QListViewItem
+
+from kdecore import KApplication, KCmdLineArgs, KAboutData, KURL
+from kdeui import KMainWindow, KTabCtl, KListBox
+from kio import KMimeType, KService, KServiceGroup, KServiceType, KTrader, KServiceTypeProfile, KServiceGroup
+
+class MainWin (KMainWindow):
+ def __init__ (self, *args):
+ apply (KMainWindow.__init__, (self,) + args)
+
+ tabctl = KTabCtl (self)
+ self.setGeometry (0, 0, 600, 400)
+ tabctl.setGeometry (10, 10, 550, 380)
+
+ tabctl.addTab (KMimeTypeTab (tabctl), "KMimeType")
+ tabctl.addTab (KServiceTab (tabctl), "KService")
+ tabctl.addTab (KSycocaEntryTab (tabctl), "KSycocaEntry")
+ tabctl.addTab (KServiceTypeTab (tabctl), "KServiceType")
+ tabctl.addTab (OfferListTab (tabctl), "OfferList")
+
+ tabctl.show ()
+
+
+class OfferListTab (QWidget):
+ def __init__ (self, parent, name = ""):
+ QWidget.__init__ (self, parent, name)
+
+ self.setGeometry (0, 0, 500, 370)
+ lvLbl = QLabel ("Offers - text/html", self)
+ lvLbl.setGeometry (10, 10, 150, 20)
+
+ lv = QListView (self)
+ lv.setSorting (-1)
+ lv.addColumn ("type_", 75)
+ lv.addColumn ("name", 100)
+ lv.addColumn ("exec_", 200)
+ lv.addColumn ("library", 100)
+ lv.setGeometry (10, 30, 500, 300)
+ lv.setAllColumnsShowFocus (1)
+
+ # insert list items in reverse order
+
+ pref = KServiceTypeProfile.preferredService ("Application", "image/jpeg")
+ QListViewItem (lv, pref.type_ (), pref.name (), pref.exec_ (), pref.library ())
+ QListViewItem (lv, "Preferred", "--------", "", "")
+ QListViewItem (lv, "", "", "", "")
+
+ trader = KTrader.self ()
+ slist = trader.query ("image/jpeg", "Type == 'Application'")
+ print "KTrader returned:", slist
+ for s in slist:
+ lvi = QListViewItem (lv, s.type_ (), s.name (), s.exec_ (), s.library ())
+
+
+ lv.show ()
+
+class KServiceTypeTab (QWidget):
+ def __init__ (self, parent, name = ""):
+ QWidget.__init__ (self, parent, name)
+
+ self.setGeometry (0, 0, 500, 370)
+ lvLbl = QLabel ("All Service Types", self)
+ lvLbl.setGeometry (10, 10, 250, 20)
+
+ lv = QListView (self)
+ lv.addColumn ("name", 150)
+ lv.addColumn ("desktopEntryPath", 300)
+ lv.setGeometry (10, 30, 500, 300)
+ lv.setAllColumnsShowFocus (1)
+
+ slist = KServiceType.allServiceTypes ()
+
+ for s in slist:
+ lvi = QListViewItem (lv, s.name (), s.desktopEntryPath ())
+
+ lv.show ()
+
+class KSycocaEntryTab (QWidget):
+ def __init__ (self, parent, name = ""):
+ QWidget.__init__ (self, parent, name)
+
+ grp = KServiceGroup.baseGroup ("screensavers")
+ self.setGeometry (0, 0, 500, 370)
+ lvLbl = QLabel ("Entries - 'screensavers': " + grp.name ().latin1 (), self)
+ lvLbl.setGeometry (10, 10, 250, 20)
+
+ lv = QListView (self)
+ lv.addColumn ("name", 150)
+ lv.addColumn ("entryPath", 300)
+ lv.setGeometry (10, 30, 500, 300)
+ lv.setAllColumnsShowFocus (1)
+
+ slist = grp.entries (0, 0)
+
+ for s in slist:
+ lvi = QListViewItem (lv, s.name (), s.entryPath ())
+
+ lv.show ()
+
+class KServiceTab (QWidget):
+ def __init__ (self, parent, name = ""):
+ QWidget.__init__ (self, parent, name)
+
+ self.setGeometry (0, 0, 500, 370)
+ lvLbl = QLabel ("All Services", self)
+ lvLbl.setGeometry (10, 10, 150, 20)
+
+ lv = QListView (self)
+ lv.addColumn ("type_", 75)
+ lv.addColumn ("name", 100)
+ lv.addColumn ("exec_", 200)
+ lv.addColumn ("library", 100)
+ lv.setGeometry (10, 30, 500, 300)
+ lv.setAllColumnsShowFocus (1)
+
+ slist = KService.allServices ()
+ for s in slist:
+ lvi = QListViewItem (lv, s.type_ (), s.name (), s.exec_ (), s.library ())
+
+ lv.show ()
+
+
+# svc = KService.serviceByDesktopName ("kcookiejar")
+# print svc
+# print svc.type_ ()
+# print svc.name ().latin1 ()
+# print svc.exec_ ().latin1 ()
+# print svc.library ()
+
+
+class KMimeTypeTab (QWidget):
+ def __init__ (self, parent, name = ""):
+ QWidget.__init__ (self, parent, name)
+
+ self.setGeometry (0, 0, 500, 370)
+ lbLbl = QLabel ("All Mimetypes", self)
+ lbLbl.setGeometry (10, 10, 150, 20)
+ lb = KListBox (self)
+ lb.setGeometry (10, 30, 200, 300)
+ mlist = KMimeType.allMimeTypes ()
+ lblist = []
+ for mt in mlist:
+ lblist.append (mt.name ().latin1 ())
+
+ lblist.sort ()
+ lb.insertStrList (lblist)
+
+ lb.show ()
+
+ x = 250
+ y = 10
+
+ mt = KMimeType.mimeType ("text/plain")
+ mtlbl = QLabel ("KMimeType.mimeType ('text/plain')", self)
+ mtlbl.setGeometry (x, y, 250, 20)
+ mtnamelbl = QLabel ("name", self)
+ mtnamelbl.setGeometry (x + 15, y + 20, 100, 20)
+ mtname = QLabel (mt.name (), self)
+ mtname.setGeometry (x + 120, y + 20, 100, 20)
+ mtdesklbl = QLabel ("desktopEntryPath", self)
+ mtdesklbl.setGeometry (x + 15, y + 40, 100, 20)
+ mtdesk = QLabel (mt.desktopEntryPath (), self)
+ mtdesk.setGeometry (x + 120, y + 40, 150, 20)
+
+ y = y + 80
+
+ fp = KMimeType.findByPath ("mimetype.py")
+ fplbl = QLabel ("KMimeType.findByPath ('mimetype.py')", self)
+ fplbl.setGeometry (x, y, 250, 20)
+ fpnamelbl = QLabel ("name", self)
+ fpnamelbl.setGeometry (x + 15, y + 20, 100, 20)
+ fpname = QLabel (fp.name (), self)
+ fpname.setGeometry (x + 120, y + 20, 100, 20)
+ fpdesklbl = QLabel ("desktopEntryPath", self)
+ fpdesklbl.setGeometry (x + 15, y + 40, 100, 20)
+ fpdesk = QLabel (fp.desktopEntryPath (), self)
+ fpdesk.setGeometry (x + 120, y + 40, 150, 20)
+
+ y = y + 80
+
+ fu = KMimeType.findByURL (KURL ("file://mimetype.py"))
+ fulbl = QLabel ("KMimeType.findByURL ('file://mimetype.py')", self)
+ fulbl.setGeometry (x, y, 250, 20)
+ funamelbl = QLabel ("name", self)
+ funamelbl.setGeometry (x + 15, y + 20, 100, 20)
+ funame = QLabel (fu.name (), self)
+ funame.setGeometry (x + 120, y + 20, 100, 20)
+ fudesklbl = QLabel ("desktopEntryPath", self)
+ fudesklbl.setGeometry (x + 15, y + 40, 100, 20)
+ fudesk = QLabel (fu.desktopEntryPath (), self)
+ fudesk.setGeometry (x + 120, y + 40, 150, 20)
+
+ y = y + 80
+
+ fc, acc = KMimeType.findByFileContent ("mimetype.py")
+ fclbl = QLabel ("KMimeType.findByFileContent ('mimetype.py')", self)
+ fclbl.setGeometry (x, y, 250, 20)
+ fcnamelbl = QLabel ("name", self)
+ fcnamelbl.setGeometry (x + 15, y + 20, 100, 20)
+ fcname = QLabel (fc.name (), self)
+ fcname.setGeometry (x + 120, y + 20, 100, 20)
+ fcdesklbl = QLabel ("desktopEntryPath", self)
+ fcdesklbl.setGeometry (x + 15, y + 40, 100, 20)
+ fcdesk = QLabel (fc.desktopEntryPath (), self)
+ fcdesk.setGeometry (x + 120, y + 40, 100, 20)
+ fcacclbl = QLabel ("accuracy", self)
+ fcacclbl.setGeometry (x + 15, y + 60, 100, 20)
+ fcacc = QLabel (str (acc), self)
+ fcacc.setGeometry (x + 120, y + 60, 150, 20)
+
+
+
+#-------------------- main ------------------------------------------------
+
+description = "Test/demo KSharedPtr related methods/classes"
+version = "1.0"
+aboutData = KAboutData ("", "",\
+ version, description, KAboutData.License_GPL,\
+ "(C) 2003 Jim Bublitz")
+
+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/examples/pyKHTMLPart.py b/examples/pyKHTMLPart.py
new file mode 100644
index 0000000..7629c11
--- /dev/null
+++ b/examples/pyKHTMLPart.py
@@ -0,0 +1,214 @@
+#
+# pyParts.py (C) 2002 Jim Bublitz <jbublitz@nwinternet.com>
+#
+
+"""
+
+This is an extemely simple and crude example of using
+a KHTMLPart - I put it together mostly to make sure
+the openURL method worked correctly after some modifications
+done in KParts::ReadOnlyPart. It took exactly four lines
+added to a basic PyKDE app framework to display a URL
+via the 'net:
+
+ self.w = KHTMLPart (self, "HTMLPart", self);
+ self.w.openURL (KURL ("http://www.kde.org"));
+ self.w.view ().setGeometry (30, 55, 500, 400);
+ self.w.show ();
+
+(Actually 5 lines if you count the 'import' line)
+
+You can play around with the commented out lines or add
+additional code to make this do something useful. The
+.rc for khtnmlpart (sorry, I never looked it up), doesn't
+seem to provide much help. Also, to follow links, you
+probably need to connect some signals to slots. I
+haven't tried it, but this should work with a plain
+KMainWindow or other widget too.
+
+The KDE website also incorporates gifs, jpegs, and
+I believe CSS too. Playing around with some other
+sites, it appears the font defaults could use some
+improvement.
+
+NOTE!!! For this to work, you (obviously) need to have
+a route to the internet established or specify a local
+URL - PyKDE/KDE will take care of everything else.
+
+Perceptive users will notice the KHTMLPart code is
+lifted from the KDE classref.
+
+"""
+
+# If you import more classes, don't forget to add them here (some of these
+# are extras/not used)
+
+from kdecore import KCmdLineArgs, KURL, KApplication, i18n, KAboutData, BarIcon, KLibLoader
+
+from kdeui import KMainWindow, KMessageBox, KAction, KStdAction, KKeyDialog, KEditToolbar
+
+from qt import QString, QStringList
+
+from kio import KTrader
+
+from khtml import KHTMLPart, KHTMLView
+
+# Importing the KParts namespace gets us all of the KParts:: classes
+from kparts import KParts, createReadOnlyPart, createReadWritePart
+
+import sys, os
+
+FALSE = 0
+TRUE = not FALSE
+
+TOOLBAR_EXIT = 0
+TOOLBAR_OPEN = 1
+
+# Note that we use KParts.MainWindow, not KMainWindow as the superclass
+# (KParts.MainWindow subclasses KMainWindow). Also, be sure the 'apply'
+# clause references KParts.MainWindow - it's a hard bug to track down
+# if it doesn't.
+
+class pyPartsMW (KParts.MainWindow):
+ def __init__ (self, *args):
+ apply (KParts.MainWindow.__init__, (self,) + args)
+
+ # Create the actions for our menu/toolbar to use
+ # Keep in mind that the part loaded will provide its
+ # own menu/toolbar entries
+
+ # check out KParts.MainWindow's ancestry to see where
+ # some of this and later stuff (like self.actionCollection () )
+ # comes from
+
+ quitAction = KStdAction.quit (self.close, self.actionCollection ())
+
+ self.m_toolbarAction = KStdAction.showToolbar(self.optionsShowToolbar, self.actionCollection());
+ self.m_statusbarAction = KStdAction.showStatusbar(self.optionsShowStatusbar, self.actionCollection());
+
+ KStdAction.keyBindings(self.optionsConfigureKeys, self.actionCollection());
+ KStdAction.configureToolbars(self.optionsConfigureToolbars, self.actionCollection());
+
+ self.path = os.getcwd () + '/'
+ self.setGeometry (0, 0, 600, 500)
+
+ # point to our XML file
+ self.setXMLFile (self.path + "pyParts.rc", FALSE)
+
+ # The next few lines are all that's necessary to
+ # create a web browser (of course you have to edit
+ # this file to change url's)
+
+ self.w = KHTMLPart (self, "HTMLPart", self);
+ self.w.openURL (KURL ("http://www.kde.org"));
+
+ self.w.view ().setGeometry (30, 55, 500, 400);
+
+
+# self.v = KHTMLView (self.w, self)
+
+# self.setCentralWidget (self.v)
+
+# self.createGUI (self.w)
+
+ self.w.show ();
+
+
+
+
+ # slots for our actions
+ def optionsShowToolbar (self):
+ if self.m_toolbarAction.isChecked():
+ self.toolBar().show()
+ else:
+ self.toolBar().hide()
+
+ def optionsShowStatusbar (self):
+ if self.m_statusbarAction.isChecked ():
+ self.statusBar().show()
+ else:
+ self.statusBar().hide()
+
+
+ def optionsConfigureKeys (self):
+ KKeyDialog.configureActionKeys (self.actionCollection(), self.xmlFile ())
+
+
+ def optionsConfigureToolbars (self):
+ dlg = KEditToolbar (self.actionCollection(), self.xmlFile ())
+ if dlg.exec_loop ():
+ self.createGUI(self);
+
+
+ # some boilerplate left over from pyKLess/KLess
+ def queryClose(self):
+ res = KMessageBox.warningYesNoCancel(self,\
+ i18n("Save changes to Document?<br>(Does not make sense, we know, but it is just a programming example :-)"))
+ if res == KMessageBox.Yes:
+ #// save document here. If saving fails, return FALSE
+ return TRUE
+
+ elif res == KMessageBox.No:
+ return TRUE
+
+ else: #// cancel
+ return FALSE
+
+ def queryExit(self):
+ #// this slot is invoked in addition when the *last* window is going
+ #// to be closed. We could do some final cleanup here.
+ return TRUE #// accept
+
+ # I'm not sure the session mgmt stuff here works
+
+ # Session management: save data
+ def saveProperties(self, config):
+ # This is provided just as an example.
+ # It is generally not so good to save the raw contents of an application
+ # in its configuration file (as this example does).
+ # It is preferable to save the contents in a file on the application's
+ # data zone and save an URL to it in the configuration resource.
+ config.writeEntry("text", self.edit.text())
+
+
+ # Session management: read data again
+ def readProperties(self, config):
+ # See above
+ self.edit.setText(config.readEntry("text"))
+
+
+
+#------------- main ----------------------------
+
+# A Human readable description of your program
+description = "KHTMLPart - simple example"
+# The version
+version = "0.1"
+
+# stuff for the "About" menu
+aboutData = KAboutData ("pyKHTMLPart", "pyHTMLPart",\
+ version, description, KAboutData.License_GPL,\
+ "(c) 2002, Jim Bublitz")
+
+aboutData.addAuthor ("Jim Bublitz", "Example for PyKDE", "jbublitz@nwinternet.com")
+
+# This MUST go here (before KApplication () is called)
+KCmdLineArgs.init (sys.argv, aboutData)
+
+app = KApplication ()
+
+if (app.isRestored()):
+ RESTORE(KLess)
+else:
+ # no session management: just create one window
+ # this is our KParts::MainWindow derived class
+ parts = pyPartsMW (None, "pyParts")
+ if len(sys.argv) > 1:
+ # read kcmdlineargs.h for the full unabridged instructions
+ # on using KCmdLineArgs, it's pretty confusing at first, but it works
+ # This is pretty useless in this program - you might want to
+ # expand this in your app (to load a file, etc)
+ args = KCmdLineArgs.parsedArgs()
+
+parts.show()
+app.exec_loop()
diff --git a/examples/pykde-sampler/HOWTO.samples b/examples/pykde-sampler/HOWTO.samples
new file mode 100644
index 0000000..7418054
--- /dev/null
+++ b/examples/pykde-sampler/HOWTO.samples
@@ -0,0 +1,60 @@
+How to Write Samples for the PyKDE Sampler
+==========================================
+
+
+Create or locate a directory within the sampler application root directory.
+
+Add a module.
+
+In side the module, add the following:
+
+- iconName - string (optional)
+ default: 'filenew'
+ example: 'colorize'
+
+ When supplied, this should be the short name of a KDE icon, such as
+ 'stop', 'editclear', etc. If available, This icon will be used as
+ the list item's icon in the sampler. Not all icons are available in
+ all themes, so try to use the icons that are available in the
+ default KDE installation.
+
+
+- labelText - string (optional)
+ default: module name
+ example: 'KMessageBox'
+
+ When supplied, this value is used as the list item text for the
+ sample. If it's not supplied, the application will use the name of
+ the module instead.
+
+
+- docParts - two-tuple (optional)
+ default: None
+ example: ('kdeui', 'KAboutDialog')
+
+ If specified, this sequence should contain two items, first item
+ name of pykde module, second item name of class within the module.
+ These two values are used to form the URL to the documentation for
+ the sample.
+
+
+- one of buildWidget, buildDialog, buildApp, MainFrame - callable (required)
+ default: None
+ example: MainFrame(QFrame): ...
+
+ The sample module must contain a callable with one of these names.
+ The callable must accept a single positional parameter, the parent
+ widget.
+
+ In most cases, it is sufficient to define a subclass of QFrame named
+ 'MainFrame'. To construct a more complex sample, define a function
+ with one of the other names.
+
+ The callable should return (or instatiate) a widget for display in
+ the main sampler widget. The created frame is responsible for
+ displaying it's help text and for any providing any widgets
+ necessary to
+
+
+
+
diff --git a/examples/pykde-sampler/TODO b/examples/pykde-sampler/TODO
new file mode 100644
index 0000000..730cc02
--- /dev/null
+++ b/examples/pykde-sampler/TODO
@@ -0,0 +1,12 @@
+Sampler App
+===========
+
+- Turn off word wrap in the source viewer
+- Add application icon
+- Enable hyperlink signal and slot in doc viewer
+
+
+Samples
+=======
+
+- More samples
diff --git a/examples/pykde-sampler/__init__.py b/examples/pykde-sampler/__init__.py
new file mode 100644
index 0000000..4265cc3
--- /dev/null
+++ b/examples/pykde-sampler/__init__.py
@@ -0,0 +1 @@
+#!/usr/bin/env python
diff --git a/examples/pykde-sampler/about.py b/examples/pykde-sampler/about.py
new file mode 100644
index 0000000..61fdd8a
--- /dev/null
+++ b/examples/pykde-sampler/about.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+""" About the PyKDE Sampler
+
+Defines the 'about' function to create a KAboutData instance for the
+sampler application.
+"""
+from os.path import dirname, join
+from kdecore import KAboutData
+
+
+appName = 'pykdesampler'
+progName = 'PyKDE Sampler'
+authorName = 'Troy Melhase'
+authorEmail = bugsEmailAddress = 'troy@gci.net'
+version = '0.1'
+shortDescription = 'The PyKDE Sampler'
+licenseType = KAboutData.License_GPL_V2
+copyrightStatement = '(c) 2006, %s' % (authorName, )
+homePageAddress = 'http://www.riverbankcomputing.co.uk/pykde/'
+aboutText = ("The application sampler for PyKDE.")
+contributors = [] # module-level global for keeping the strings around; intentional
+
+
+def about():
+ """ creates KAboutData instance for the app
+
+ """
+ about = KAboutData(
+ appName,
+ progName,
+ version,
+ shortDescription,
+ licenseType,
+ copyrightStatement,
+ aboutText,
+ homePageAddress,
+ bugsEmailAddress)
+ about.addAuthor(authorName, '', authorEmail)
+
+ try:
+ contrib = open(join(dirname(__file__), 'contributors.txt'))
+ contrib = [line.strip() for line in contrib]
+ contrib = [line for line in contrib if not line.startswith('#')]
+ for line in contrib:
+ try:
+ name, task, addr = [s.strip() for s in line.split(',')]
+ contributors.append((name, task, addr))
+ except:
+ pass
+ except:
+ pass
+
+ contributors.sort(lambda a, b:cmp(a[0], b[0]))
+ for name, task, addr in contributors:
+ about.addCredit(name, task, addr)
+
+ return about
diff --git a/examples/pykde-sampler/aboutkde.png b/examples/pykde-sampler/aboutkde.png
new file mode 100644
index 0000000..3bb4e68
--- /dev/null
+++ b/examples/pykde-sampler/aboutkde.png
Binary files differ
diff --git a/examples/pykde-sampler/basic_widgets/__init__.py b/examples/pykde-sampler/basic_widgets/__init__.py
new file mode 100644
index 0000000..2442375
--- /dev/null
+++ b/examples/pykde-sampler/basic_widgets/__init__.py
@@ -0,0 +1,17 @@
+labelText = 'Widgets'
+iconName = 'about_kde'
+
+helpText = """KDE provides a large set of basic widgets for application use.
+Select the children of this item to see for yourself."""
+
+from qt import QFrame, QVBoxLayout
+from kdeui import KTextEdit
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ layout = QVBoxLayout(self)
+ self.text = KTextEdit(helpText, '', self)
+ layout.addWidget(self.text, 1)
+ layout.addStretch(1)
diff --git a/examples/pykde-sampler/basic_widgets/datepicker.py b/examples/pykde-sampler/basic_widgets/datepicker.py
new file mode 100644
index 0000000..aa36de5
--- /dev/null
+++ b/examples/pykde-sampler/basic_widgets/datepicker.py
@@ -0,0 +1,42 @@
+from qt import QFrame, QStringList, QVBoxLayout, SIGNAL, QLabel, QSizePolicy, Qt
+from qttable import QTable
+from kdeui import KTextEdit, KDatePicker, KDateWidget
+
+
+labelText = 'KDatePicker'
+iconName = 'date'
+helpText = """A date selection widget.
+
+Provides a widget for calendar date input.
+
+Different from the previous versions, it now emits two types of
+signals, either dateSelected() or dateEntered() (see documentation for
+both signals).
+
+A line edit has been added in the newer versions to allow the user to
+select a date directly by entering numbers like 19990101 or 990101.
+"""
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+ self.dateDisplay = KDateWidget(self)
+
+ self.dateDisplay.setSizePolicy(QSizePolicy(QSizePolicy.Maximum,
+ QSizePolicy.Maximum))
+
+ self.datePicker = KDatePicker(self)
+
+ layout = QVBoxLayout(self)
+ layout.addWidget(self.help, 1)
+ layout.addWidget(self.datePicker, 0, Qt.AlignHCenter)
+ layout.addStretch(1)
+
+ self.other = QLabel('Selected Date:', self)
+ layout.addWidget(self.other, 0)
+ layout.addWidget(self.dateDisplay, 2)
+
+ self.connect(self.datePicker, SIGNAL('dateChanged(QDate)'),
+ self.dateDisplay.setDate)
+
diff --git a/examples/pykde-sampler/basic_widgets/historycombo.py b/examples/pykde-sampler/basic_widgets/historycombo.py
new file mode 100644
index 0000000..aa35b53
--- /dev/null
+++ b/examples/pykde-sampler/basic_widgets/historycombo.py
@@ -0,0 +1,53 @@
+from qt import Qt, QFrame, QHBoxLayout, QVBoxLayout, QStringList, QLabel, \
+ SIGNAL, SLOT
+from kdeui import KHistoryCombo, KTextEdit
+
+
+iconName = 'history'
+labelText = 'KHistoryCombo'
+docParts = ('kdeui', 'KHistoryCombo')
+helpText = ('An example of the KHistoryCombo widget.'
+ '\n\n'
+ 'Completion is enabled via the setHistoryItems call; when the second '
+ 'parameter is True, matching items from the list appear as you type.'
+ '\n\n'
+ 'The activated signal is connected to the addToHistory '
+ 'slot to automatically add new items.')
+
+
+historyText = 'a quick brown fox jumps over the lazy dog'
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+ self.historyCombo = KHistoryCombo(self)
+
+ self.historySelectionLabel = QLabel('Selected value: ', self)
+ self.historySelection = QLabel('(none)', self)
+
+ items = QStringList()
+ for item in historyText.split():
+ items.append(item)
+ self.historyCombo.setHistoryItems(items, True)
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help, 3)
+ layout.addStretch(1)
+ selectionLayout = QHBoxLayout(layout, 4)
+ selectionLayout.addWidget(self.historySelectionLabel, 1)
+ selectionLayout.addWidget(self.historySelection, 10, Qt.AlignLeft)
+ layout.addWidget(self.historyCombo, 0)
+ layout.addStretch(10)
+
+ self.connect(self.historyCombo, SIGNAL('activated(const QString& )'),
+ self.historyCombo, SLOT('addToHistory(const QString&)'))
+ self.connect(self.historyCombo, SIGNAL('cleared()'),
+ self.historyCleared)
+ self.connect(self.historyCombo, SIGNAL('activated(const QString &)'),
+ self.historySelection.setText)
+
+ def historyCleared(self):
+ print 'History combo cleared.'
+
diff --git a/examples/pykde-sampler/contributors.txt b/examples/pykde-sampler/contributors.txt
new file mode 100644
index 0000000..18b9a81
--- /dev/null
+++ b/examples/pykde-sampler/contributors.txt
@@ -0,0 +1,4 @@
+# author, contributions, email
+Phil Thompson, For PyQt and SIP, phil@riverbankcomputing.co.uk
+Jim Bublitz, For PyKDE, jbublitz@nwinternet.com
+
diff --git a/examples/pykde-sampler/dialogs/__init__.py b/examples/pykde-sampler/dialogs/__init__.py
new file mode 100644
index 0000000..c6f70f9
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/__init__.py
@@ -0,0 +1,18 @@
+labelText = 'Dialog Boxes'
+iconName = 'launch'
+
+
+helpText = ("KDE provides a convenient set of dialog boxes for application use. "
+ "Select the children of this item to see for yourself.")
+
+
+from qt import QFrame, QVBoxLayout
+from kdeui import KTextEdit
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ layout = QVBoxLayout(self)
+ self.text = KTextEdit(helpText, '', self)
+ layout.addWidget(self.text, 1)
diff --git a/examples/pykde-sampler/dialogs/about/__init__.py b/examples/pykde-sampler/dialogs/about/__init__.py
new file mode 100644
index 0000000..4c40da7
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/about/__init__.py
@@ -0,0 +1,16 @@
+labelText = 'About Dialogs'
+iconName = 'info'
+
+helpText = ("KDE has multiple dialog types to display information about your "
+"applicaiton and environment. They provide a tremendous amount of functionality "
+"and consistency. They're easy to use, and they're good for the environment!")
+
+from qt import QFrame, QVBoxLayout
+from kdeui import KTextEdit
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ layout = QVBoxLayout(self)
+ self.text = KTextEdit(helpText, '', self)
+ layout.addWidget(self.text, 1)
diff --git a/examples/pykde-sampler/dialogs/about/aboutapp.py b/examples/pykde-sampler/dialogs/about/aboutapp.py
new file mode 100644
index 0000000..afdd71a
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/about/aboutapp.py
@@ -0,0 +1,29 @@
+iconName = 'about_kde'
+labelText = 'KAboutApplication'
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL
+from kdecore import i18n
+from kdeui import KAboutApplication, KPushButton, KTextEdit
+
+
+helpText = ("Typically available via the applications 'Help' menu, this "
+ "dialog presents the user with the applications About widget.")
+
+docParts = ('kdeui', 'KAboutDialog')
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('About Application'), self)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showAboutDialog)
+
+ def showAboutDialog(self):
+ dlg = KAboutApplication(self)
+ dlg.show()
diff --git a/examples/pykde-sampler/dialogs/about/aboutkde.py b/examples/pykde-sampler/dialogs/about/aboutkde.py
new file mode 100644
index 0000000..9c73f9d
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/about/aboutkde.py
@@ -0,0 +1,28 @@
+iconName = 'about_kde'
+labelText = 'KAboutKDE'
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL
+from kdecore import i18n
+from kdeui import KAboutKDE, KPushButton, KTextEdit
+
+
+helpText = ("Typically available via the applications 'Help' menu, this "
+ "dialog presents the user with the standard KDE About dialog.")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('About KDE'), self)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showAboutDialog)
+
+ def showAboutDialog(self):
+ dlg = KAboutKDE(self)
+ dlg.show()
diff --git a/examples/pykde-sampler/dialogs/bugreport.py b/examples/pykde-sampler/dialogs/bugreport.py
new file mode 100644
index 0000000..6c41165
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/bugreport.py
@@ -0,0 +1,34 @@
+iconName = 'core'
+labelText = 'KBugReport'
+
+##~ if we wanted to, we could define the name of a KDE class used for lookup of
+##~ the documentation url. The 'labelText' string above already
+##~ specifies what we want.
+##~ docItemName = 'KBugReport'
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL
+from kdecore import i18n
+from kdeui import KAboutDialog, KPushButton, KBugReport, KTextEdit
+
+
+helpText = ("KDE provides a way to report bugs from applications. This dialog"
+ "is typically available from the application 'Help' menu.")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Bug Report Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showBugDialog)
+
+
+ def showBugDialog(self):
+ dlg = KBugReport(self)
+ dlg.exec_loop()
diff --git a/examples/pykde-sampler/dialogs/color.py b/examples/pykde-sampler/dialogs/color.py
new file mode 100644
index 0000000..b749cce
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/color.py
@@ -0,0 +1,42 @@
+iconName = 'colorize'
+labelText = 'KColorDialog'
+
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL
+from kdecore import i18n
+from kdeui import KPushButton, KColorDialog, KColorPatch, KTextEdit
+
+
+helpText = ("KDE provides a nifty common color selection dialog."
+ "The color selection in the dialog is tracked via a SIGNAL "
+ "connected to the KColorPatch area below.")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Color Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+ self.patch = KColorPatch(self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addWidget(self.patch, 10)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showColorDialog)
+
+ def showColorDialog(self):
+ dlg = KColorDialog(self)
+
+ ## this connection is made so that there's a default color
+ self.connect(dlg, SIGNAL('colorSelected(const QColor &)'),
+ self.patch.setPaletteBackgroundColor)
+ dlg.setColor(self.patch.paletteBackgroundColor())
+
+ ## this connection is the one that changes the patch color to match
+ ## the color selected in the dialog
+ self.connect(dlg, SIGNAL('colorSelected(const QColor &)'),
+ self.patch.setColor)
+ dlg.exec_loop()
diff --git a/examples/pykde-sampler/dialogs/config.py b/examples/pykde-sampler/dialogs/config.py
new file mode 100644
index 0000000..74454ab
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/config.py
@@ -0,0 +1,59 @@
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, QTimer, SIGNAL, QString
+from kdecore import i18n, KConfigSkeleton
+from kdeui import KPushButton, KConfigDialog, KTextEdit
+
+iconName = 'configure'
+labelText = 'KConfigDialog'
+docParts = ('kdeui', 'KConfigDialog')
+helpText = ("")
+
+
+class SampleSettings(KConfigSkeleton):
+ def __init__(self):
+ KConfigSkeleton.__init__(self)
+ self.anyString = QString()
+
+ self.setCurrentGroup("Strings")
+ self.addItemString("Test", self.anyString, "Default Value")
+
+ self.setCurrentGroup("Booleans")
+ self.addItemBool("Any Bool", False)
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Config Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showConfigDialog)
+
+
+ def showConfigDialog(self):
+ config = SampleSettings()
+ dlg = KConfigDialog(self, 'Sampler Config', config)
+ self.strings = StringsSettings(self)
+ self.bools = BoolSettings(self)
+ dlg.addPage(self.strings, 'Strings', 'Strings')
+ dlg.addPage(self.bools, 'Bools', 'Bools')
+ dlg.exec_loop()
+
+
+class StringsSettings(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.text = KTextEdit('A String', '', self)
+
+
+class BoolSettings(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.text = KTextEdit('A Bool', '', self)
+
diff --git a/examples/pykde-sampler/dialogs/edfind.py b/examples/pykde-sampler/dialogs/edfind.py
new file mode 100644
index 0000000..685902e
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/edfind.py
@@ -0,0 +1,52 @@
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, QTimer, SIGNAL, QFont, QString
+from kdecore import i18n
+from kdeui import KPushButton, KEdFind, KTextEdit
+
+iconName = 'find'
+labelText = 'KEdFind'
+docParts = ('kdeui', 'KEdFind')
+helpText = ("An example of the KEdFind dialog.")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Edit Find Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showEdFind)
+
+
+ def showEdFind(self):
+ dlg = self.dlg = KEdFind(self)
+ self.connect(dlg, SIGNAL('done()'),
+ self.doneClicked)
+ self.connect(dlg, SIGNAL('search()'),
+ self.searchClicked)
+ dlg.exec_loop()
+
+
+ def doneClicked(self):
+ print 'done searching'
+
+ def searchClicked(self):
+ print 'searching: ', self.dlg.getText(),
+ if self.dlg.get_direction():
+ print '(backwards) ',
+ else:
+ print '(forwards) ',
+ if self.dlg.case_sensitive():
+ print '(case-sensitive)'
+ else:
+ print '(case-insensitive)'
+
+
+
+
diff --git a/examples/pykde-sampler/dialogs/edreplace.py b/examples/pykde-sampler/dialogs/edreplace.py
new file mode 100644
index 0000000..df95614
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/edreplace.py
@@ -0,0 +1,52 @@
+from qt import QFrame, QHBoxLayout, QVBoxLayout, QTimer, SIGNAL, QFont, QString
+from kdecore import i18n
+from kdeui import KPushButton, KEdReplace, KTextEdit
+
+iconName = 'findreplace'
+labelText = 'KEdReplace'
+docParts = ('kdeui', 'KEdReplace')
+helpText = ("An example of the KEdReplace dialog.")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Edit Find Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showEdReplace)
+
+
+ def showEdReplace(self):
+ dlg = self.dlg = KEdReplace(self)
+ self.connect(dlg, SIGNAL('done()'),
+ self.doneClicked)
+ self.connect(dlg, SIGNAL('replace()'),
+ self.replaceClicked)
+ dlg.exec_loop()
+
+
+ def doneClicked(self):
+ print 'done replacing'
+
+ def replaceClicked(self):
+ print 'replacing: ', self.dlg.getText()
+ return
+ if self.dlg.get_direction():
+ print '(backwards) ',
+ else:
+ print '(forwards) ',
+ if self.dlg.case_sensitive():
+ print '(case-sensitive)'
+ else:
+ print '(case-insensitive)'
+
+
+
+
diff --git a/examples/pykde-sampler/dialogs/font.py b/examples/pykde-sampler/dialogs/font.py
new file mode 100644
index 0000000..ae2189e
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/font.py
@@ -0,0 +1,53 @@
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, QTimer, SIGNAL, QFont, QString
+from kdecore import i18n
+from kdeui import KPushButton, KFontDialog, KTextEdit
+
+iconName = 'fonts'
+labelText = 'KFontDialog'
+docParts = ('kdeui', 'KFontDialog')
+helpText = ("KDE provides a font dialog box for users to select (can you "
+ "guess??) fonts. The button below displays a font dialog box. "
+ "The font of this widget (the text widget you're reading) is used "
+ "as the default. If the dialog is accepted, the font of this "
+ "widget is change to match the selection.")
+
+
+fontText = """Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam
+ante. Nam in mauris. Vestibulum ante velit, condimentum vel, congue
+sit amet, lobortis a, dui. Fusce auctor, quam non pretium nonummy, leo
+ante imperdiet libero, id lobortis erat erat quis eros. Pellentesque
+habitant morbi tristique senectus et netus et malesuada fames ac
+turpis egestas. Cras ut metus. Vivamus suscipit, sapien id tempor
+elementum, nunc quam malesuada dolor, sit amet luctus sapien odio vel
+ligula. Integer scelerisque, risus a interdum vestibulum, felis ipsum
+pharetra eros, nec nonummy libero justo quis risus. Vestibulum
+tincidunt, augue vitae suscipit congue, sem dui adipiscing nulla, ut
+nonummy arcu quam ac sem. Nulla in metus. Phasellus neque.
+"""
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Font Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+ self.example = KTextEdit(fontText, '', self)
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addWidget(self.example, 10)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showFontDialog)
+
+
+ def showFontDialog(self):
+ font = QFont(self.example.font())
+ string = QString()
+ accepted, other = KFontDialog.getFontAndText(font, string, False, self)
+ if accepted:
+ self.example.setFont(font)
+ self.example.setText(string)
diff --git a/examples/pykde-sampler/dialogs/input.py b/examples/pykde-sampler/dialogs/input.py
new file mode 100644
index 0000000..30edc6f
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/input.py
@@ -0,0 +1,87 @@
+iconName = 'editclear'
+labelText = 'KInputDialog'
+
+from qt import QFrame, QGridLayout, QLabel, QStringList, SIGNAL
+from kdecore import i18n
+from kdeui import KPushButton, KInputDialog, KTextEdit
+
+
+helpText = ("KInputDialog allows the programmer to display a simple dialog to "
+ "request a bit of text, an integer value, a double value, or a "
+ "list item from the user.")
+
+
+class MainFrame(QFrame):
+ items = ['Apples', 'Bananas', 'Mangos', 'Oranges', 'Pears', ]
+
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+
+ layout = QGridLayout(self, 5, 2, 4) # five rows, two cols, four px spacing
+ layout.setRowStretch(0, 10)
+ layout.setColStretch(1, 10)
+ layout.addMultiCellWidget(self.help, 0, 1, 0, 1)
+
+ button = KPushButton(i18n('Get Text'), self)
+ self.connect(button, SIGNAL('clicked()'), self.getText)
+ self.getTextLabel = QLabel('text value', self)
+ layout.addWidget(button, 2, 0)
+ layout.addWidget(self.getTextLabel, 2, 1)
+ layout.setRowStretch(2, 0)
+
+ button = KPushButton(i18n('Get Integer'), self)
+ self.connect(button, SIGNAL('clicked()'), self.getInt)
+ self.getIntLabel = QLabel('0', self)
+ layout.addWidget(self.getIntLabel, 3, 1)
+ layout.addWidget(button, 3, 0)
+ layout.setRowStretch(3, 0)
+
+ button = KPushButton(i18n('Get Double'), self)
+ self.connect(button, SIGNAL('clicked()'), self.getDouble)
+ self.getDoubleLabel = QLabel('0.0', self)
+ layout.addWidget(self.getDoubleLabel, 4, 1)
+ layout.addWidget(button, 4, 0)
+ layout.setRowStretch(4, 0)
+
+ button = KPushButton(i18n('Get Item'), self)
+ self.connect(button, SIGNAL('clicked()'), self.getItem)
+ self.getItemLabel = QLabel(self.items[0], self)
+ layout.addWidget(button, 5, 0)
+ layout.addWidget(self.getItemLabel, 5, 1)
+ layout.setRowStretch(5, 0)
+
+ def getText(self):
+ title = 'KInputDialog.getText Dialog'
+ label = 'Enter some text:'
+ default = self.getTextLabel.text()
+ value, accepted = KInputDialog.getText(title, label, default)
+ if accepted:
+ self.getTextLabel.setText(value)
+
+ def getInt(self):
+ title = 'KInputDialog.getInteger Dialog'
+ label = 'Enter an integer:'
+ default = int('%s' % self.getIntLabel.text())
+ value, accepted = KInputDialog.getInteger(title, label, default)
+ if accepted:
+ self.getIntLabel.setText('%s' % value)
+
+ def getDouble(self):
+ title = 'KInputDialog.getDouble Dialog'
+ label = 'Enter a double:'
+ default = float('%s' % self.getDoubleLabel.text())
+ value, accepted = KInputDialog.getDouble(title, label, default, -10.0, 10.0)
+ if accepted:
+ self.getDoubleLabel.setText('%s' % value)
+
+ def getItem(self):
+ title = 'KInputDialog.getItem Dialog'
+ label = 'Select an item:'
+ current = self.items.index('%s' % self.getItemLabel.text())
+ selections = QStringList()
+ for item in self.items:
+ selections.append(item)
+ value, accepted = KInputDialog.getItem(title, label, selections, current)
+ if accepted:
+ self.getItemLabel.setText('%s' % value)
diff --git a/examples/pykde-sampler/dialogs/key.py b/examples/pykde-sampler/dialogs/key.py
new file mode 100644
index 0000000..4c437da
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/key.py
@@ -0,0 +1,29 @@
+iconName = 'configure_shortcuts'
+labelText = 'KKeyDialog'
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL
+from kdecore import i18n
+from kdeui import KPushButton, KKeyDialog, KTextEdit
+
+
+helpText = ("Configuring keystroke shortcuts is simple with KActions and the "
+ "KKeyDialog type. This sample starts the KKeyDialog for the "
+ "sampler application.")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Key Configuration Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showKeysDialog)
+
+ def showKeysDialog(self):
+ top = self.topLevelWidget()
+ KKeyDialog.configure(top.actionCollection(), self)
diff --git a/examples/pykde-sampler/dialogs/msgbox.py b/examples/pykde-sampler/dialogs/msgbox.py
new file mode 100644
index 0000000..a0b3c9a
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/msgbox.py
@@ -0,0 +1,141 @@
+iconName = 'stop'
+labelText = 'KMessageBox'
+
+from random import random
+from traceback import print_exc
+from StringIO import StringIO
+
+from qt import QFrame, QGridLayout, QLabel, QStringList, SIGNAL
+from kdecore import i18n
+from kdeui import KGuiItem, KPushButton, KMessageBox, KTextEdit
+
+
+helpText = ("The KMessageBox Python class wraps the static methods of its C++ "
+ "counterpart. Some of these methods are used below. Refer to the "
+ "docs for KMessageBox for a full list.")
+
+
+class MainFrame(QFrame):
+ msg = 'Do you like food?'
+ caption = 'Simple Question'
+ err = 'Some kind of error happened, but it could be worse!'
+ info = 'Always wash your hands after eating.'
+ items = ['Apples', 'Bananas', 'Cantaloupe', 'Mangos', 'Oranges', 'Pears', ]
+
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ items = QStringList()
+ for item in self.items:
+ items.append(item)
+ self.items = items
+
+ responses = 'Ok Cancel Yes No Continue'.split()
+ responses = [(getattr(KMessageBox, res), res) for res in responses]
+ self.responses = dict(responses)
+
+ self.help = KTextEdit(helpText, '', self)
+
+ layout = QGridLayout(self, 5, 2, 4)
+ layout.setRowStretch(0, 10)
+ layout.setColStretch(1, 10)
+ layout.addMultiCellWidget(self.help, 0, 1, 0, 1)
+
+ button = KPushButton(i18n('Question Yes-No'), self)
+ self.connect(button, SIGNAL('clicked()'), self.questionYesNo)
+ layout.addWidget(button, 2, 0)
+ layout.setRowStretch(2, 0)
+
+ button = KPushButton(i18n('Warning Yes-No-Cancel'), self)
+ self.connect(button, SIGNAL('clicked()'), self.warningYesNoCancel)
+ layout.addWidget(button, 3, 0)
+ layout.setRowStretch(3, 0)
+
+ button = KPushButton(i18n('Warning Continue-Cancel-List'), self)
+ self.connect(button, SIGNAL('clicked()'), self.warningContinueCancelList)
+ layout.addWidget(button, 4, 0)
+ layout.setRowStretch(4, 0)
+
+ button = KPushButton(i18n('Error'), self)
+ self.connect(button, SIGNAL('clicked()'), self.error)
+ layout.addWidget(button, 5, 0)
+ layout.setRowStretch(5, 0)
+
+ button = KPushButton(i18n('Detailed Error'), self)
+ self.connect(button, SIGNAL('clicked()'), self.detailedError)
+ layout.addWidget(button, 6, 0)
+ layout.setRowStretch(6, 0)
+
+ button = KPushButton(i18n('Sorry'), self)
+ self.connect(button, SIGNAL('clicked()'), self.sorry)
+ layout.addWidget(button, 7, 0)
+ layout.setRowStretch(7, 0)
+
+ button = KPushButton(i18n('Detailed Sorry'), self)
+ self.connect(button, SIGNAL('clicked()'), self.detailedSorry)
+ layout.addWidget(button, 8, 0)
+ layout.setRowStretch(8, 0)
+
+ button = KPushButton(i18n('Information'), self)
+ self.connect(button, SIGNAL('clicked()'), self.information)
+ layout.addWidget(button, 9, 0)
+ layout.setRowStretch(9, 0)
+
+ button = KPushButton(i18n('Information List'), self)
+ self.connect(button, SIGNAL('clicked()'), self.informationList)
+ layout.addWidget(button, 10, 0)
+ layout.setRowStretch(10, 0)
+
+ def questionYesNo(self):
+ dlg = KMessageBox.questionYesNo(self, self.msg, self.caption)
+ print 'You pressed "%s"' % (self.responses.get(dlg, dlg), )
+
+ def warningYesNoCancel(self):
+ dlg = KMessageBox.warningYesNoCancel(self, self.msg, self.caption)
+ print 'You pressed "%s"' % (self.responses.get(dlg, dlg), )
+
+ def warningContinueCancelList(self):
+ uiitem = KGuiItem('Time to Eat', 'favorites')
+ ctor = KMessageBox.warningContinueCancelList
+ dlgid = '%s' % random()
+ args = self, self.msg, self.items, self.caption, uiitem, dlgid
+ dlg = ctor(*args)
+ print 'You pressed "%s"' % (self.responses.get(dlg, dlg), )
+
+ def error(self):
+ dlg = KMessageBox.error(self, self.err)
+ print 'You pressed "%s"' % (self.responses.get(dlg, dlg), )
+
+ def detailedError(self):
+ try:
+ x = self.thisAttributeDoesNotExist
+ except (AttributeError, ), ex:
+ handle = StringIO()
+ print_exc(0, handle)
+ details = handle.getvalue()
+ dlg = KMessageBox.detailedError(self, self.err, details)
+ print 'You pressed "%s"' % (self.responses.get(dlg, dlg), )
+
+ def sorry(self):
+ dlg = KMessageBox.sorry(self, self.err)
+ print 'You pressed "%s"' % (self.responses.get(dlg, dlg), )
+
+ def detailedSorry(self):
+ try:
+ x = self.thisAttributeDoesNotExist
+ except (AttributeError, ), ex:
+ handle = StringIO()
+ print_exc(0, handle)
+ details = handle.getvalue()
+ dlg = KMessageBox.detailedSorry(self, self.err, details)
+ print 'You pressed "%s"' % (self.responses.get(dlg, dlg), )
+
+ def information(self):
+ dlgid = '%s' % random()
+ dlg = KMessageBox.information(self, self.info, '', dlgid)
+ print 'You pressed "%s"' % (self.responses.get(dlg, dlg), )
+
+ def informationList(self):
+ dlgid = '%s' % random()
+ ctor = KMessageBox.informationList
+ dlg = ctor(self, self.info, self.items, '', dlgid)
+ print 'You pressed "%s"' % (self.responses.get(dlg, dlg), )
diff --git a/examples/pykde-sampler/dialogs/passwd.py b/examples/pykde-sampler/dialogs/passwd.py
new file mode 100644
index 0000000..554093b
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/passwd.py
@@ -0,0 +1,34 @@
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL
+from kdecore import i18n
+from kdeui import KPushButton, KPasswordDialog, KTextEdit
+
+iconName = 'password'
+labelText = 'KPasswordDialog'
+docParts = ('kdeui', 'KPasswordDialog')
+helpText = ("KDE provides two variations on the password dialog. The simple "
+ "one shown here prompts for a password. The other type allows the "
+ "user to enter a new password, and provides a second field to "
+ "confirm the first entry.")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Password Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showPasswordDialog)
+
+
+ def showPasswordDialog(self):
+ old = 'foo bar baz'
+ prompt = "Enter your super-secret password (enter anything, it's just an example):"
+ result = KPasswordDialog.getPassword(old, prompt)
+ if result == KPasswordDialog.Accepted:
+ pass
+
diff --git a/examples/pykde-sampler/dialogs/progress.py b/examples/pykde-sampler/dialogs/progress.py
new file mode 100644
index 0000000..ba85b8e
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/progress.py
@@ -0,0 +1,39 @@
+iconName = 'go'
+labelText = 'KProgressDialog'
+
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, QTimer, SIGNAL
+from kdecore import i18n
+from kdeui import KPushButton, KProgressDialog, KTextEdit
+
+
+helpText = """KDE provides a ready-built dialog to display a bit of text and a
+progress bar."""
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Progress Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showProgressDialog)
+
+ def showProgressDialog(self):
+ self.dlg = dlg = KProgressDialog(self, None, 'Sample Progress Dialog',
+ helpText)
+ dlg.progressBar().setTotalSteps(20)
+ dlg.progressBar().setFormat('% complete: %p - value: %v - maximum: %m')
+ timer = QTimer(self)
+ self.connect(timer, SIGNAL('timeout()'), self.updateProgress)
+ timer.start(250, False)
+ dlg.exec_loop()
+ timer.stop()
+
+ def updateProgress(self):
+ self.dlg.progressBar().advance(1)
diff --git a/examples/pykde-sampler/dialogs/tip.py b/examples/pykde-sampler/dialogs/tip.py
new file mode 100644
index 0000000..29ac66b
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/tip.py
@@ -0,0 +1,31 @@
+iconName = 'idea'
+labelText = 'KTipDialog'
+
+import os
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL
+from kdecore import i18n
+from kdeui import KPushButton, KTipDatabase, KTipDialog, KTextEdit
+
+
+helpText = ("The KDE standard Tip-of-the-Day dialog.")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Tip-of-the-Day Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showTipDialog)
+
+ def showTipDialog(self):
+ filename = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tips'))
+ tips = KTipDatabase(filename)
+ dlg = KTipDialog(tips, self)
+ dlg.exec_loop()
diff --git a/examples/pykde-sampler/dialogs/tips b/examples/pykde-sampler/dialogs/tips
new file mode 100644
index 0000000..9f24457
--- /dev/null
+++ b/examples/pykde-sampler/dialogs/tips
@@ -0,0 +1,24 @@
+
+<tip category="PyKDE Sampler|General">
+<html>
+<p>Don't tug on Superman's cape.</p>
+</html>
+</tip>
+
+<tip category="PyKDE Sampler|General">
+<html>
+<p>Don't spit into the wind.</p>
+</html>
+</tip>
+
+<tip category="PyKDE Sampler|General">
+<html>
+<p>Don't pull the mask off the Lone Ranger.</p>
+</html>
+</tip>
+
+<tip category="PyKDE Sampler|General">
+<html>
+<p>And don't mess around with <em>Jim</em>!</p>
+</html>
+</tip>
diff --git a/examples/pykde-sampler/gen_todo.py b/examples/pykde-sampler/gen_todo.py
new file mode 100644
index 0000000..02d73de
--- /dev/null
+++ b/examples/pykde-sampler/gen_todo.py
@@ -0,0 +1,19 @@
+mods = ['dcop', 'kdecore', 'kdefx', 'kdeprint', 'kdesu', 'kdeui', 'kfile', 'khtml', 'kio', 'kmdi', 'kparts', 'kspell', ]
+all = []
+
+
+print 'Module,Item,Path,Contributor'
+for mod in mods:
+ module = __import__(mod)
+ items = dir(module)
+ items.sort()
+ items = [item for item in items if not item.startswith('_')]
+ items = [item for item in items if not item in all]
+
+ for item in items:
+ all.append(item)
+ print '%s,%s,,,' % (mod, item, )
+
+
+
+
diff --git a/examples/pykde-sampler/icon_handling/__init__.py b/examples/pykde-sampler/icon_handling/__init__.py
new file mode 100644
index 0000000..f25a8f0
--- /dev/null
+++ b/examples/pykde-sampler/icon_handling/__init__.py
@@ -0,0 +1,18 @@
+labelText = 'Icons'
+iconName = 'icons'
+
+
+helpText = ("KDE icons are nice. "
+ "Select the children of this item to see for yourself.")
+
+
+from qt import QFrame, QVBoxLayout
+from kdeui import KTextEdit
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ layout = QVBoxLayout(self)
+ self.text = KTextEdit(helpText, '', self)
+ layout.addWidget(self.text, 1)
diff --git a/examples/pykde-sampler/icon_handling/misc.py b/examples/pykde-sampler/icon_handling/misc.py
new file mode 100644
index 0000000..4c7f425
--- /dev/null
+++ b/examples/pykde-sampler/icon_handling/misc.py
@@ -0,0 +1,31 @@
+
+iconName = 'icons'
+labelText = 'Misc.'
+
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL, QPoint
+from kdecore import i18n
+from kdeui import KAboutDialog, KPushButton, KBugReport, KTextEdit
+from kdeui import KRootPermsIcon, KWritePermsIcon
+
+
+helpText = ("Samples for the KRootPermsIcon and KWritePermsIcon classes."
+ "These icons don't do anything.")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+
+ layout = QVBoxLayout(self, 4)
+ layout.setAutoAdd(True)
+
+ self.help = KTextEdit(helpText, '', self)
+ self.root = KRootPermsIcon(None)
+ self.root.reparent(self, 0, QPoint(0,0), True)
+
+ import os
+ fn = os.path.abspath('.')
+ print fn
+ self.write = KWritePermsIcon(fn)
+ self.write.reparent(self, 0, QPoint(0,0), True)
diff --git a/examples/pykde-sampler/icon_handling/sizes.py b/examples/pykde-sampler/icon_handling/sizes.py
new file mode 100644
index 0000000..b3f5e1c
--- /dev/null
+++ b/examples/pykde-sampler/icon_handling/sizes.py
@@ -0,0 +1,30 @@
+
+iconName = 'icons'
+labelText = 'Icon Sizing'
+
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL
+from kdecore import i18n
+from kdeui import KAboutDialog, KPushButton, KBugReport, KTextEdit
+
+
+helpText = ("")
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Bug Report Dialog'), self)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showBugDialog)
+
+
+ def showBugDialog(self):
+ dlg = KBugReport(self)
+ dlg.exec_loop()
diff --git a/examples/pykde-sampler/lib.py b/examples/pykde-sampler/lib.py
new file mode 100644
index 0000000..875ae1a
--- /dev/null
+++ b/examples/pykde-sampler/lib.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+"""
+
+"""
+import os
+import sys
+
+from os import listdir, walk
+from os.path import dirname, isdir, abspath, split, join, exists
+
+
+samplerpath = dirname(abspath(__file__))
+packagepath, packagename = split(samplerpath)
+
+samplerpath += os.path.sep
+packagepath += os.path.sep
+
+
+def namedimport(name):
+ """ import a module given a dotted package name
+
+ Taken directly from the Python library docs for __import __
+ """
+ mod = __import__(name)
+ components = name.split('.')
+ for comp in components[1:]:
+ mod = getattr(mod, comp)
+ return mod
+
+
+def ispackage(path):
+ return isdir(path) and exists(join(path, '__init__.py'))
+
+
+def ismodule(path):
+ head, tail = os.path.split(path)
+ if tail in ('__init__.py', '__init__.pyc', '__init__.pyo'):
+ return False
+ head, tail = os.path.splitext(path)
+ return tail in ('.py', ) # don't use these, which filters them out dupes ( '.pyc', '.pyo')
+
+
+def listimports(top):
+ top = abspath(top)
+ yield top
+ for path in listdir(top):
+ path = join(top, path)
+ if ispackage(path):
+ yield path
+ for subpath in listimports(path):
+ yield subpath
+ elif ismodule(path):
+ yield path
+
+
+def listmodules():
+ if samplerpath not in sys.path:
+ sys.path.append(samplerpath)
+
+ dirs = [join(samplerpath, d) for d in listdir(samplerpath)]
+ dirs = [d for d in dirs if exists(join(d, '__init__.py'))]
+
+ modules = []
+ for dirname in dirs:
+ dirpath = join(samplerpath, dirname)
+ for path in listimports(dirpath):
+ path = path.replace('.py', '')
+ path = path.replace(samplerpath, '').replace(os.path.sep, '.')
+ try:
+ module = namedimport(path)
+ except (ValueError, ImportError, ), exc:
+ print 'Exception %s importing %s' % (exc, path, )
+ else:
+ modules.append((path, module))
+ modules.sort()
+ return [(path, SamplerModule(module)) for path, module in modules]
+
+
+class SamplerModule(object):
+ defaultIcon = 'filenew'
+
+
+ def __init__(self, module):
+ self.module = module
+
+
+ def name(self):
+ return self.module.__name__.split('.')[-1]
+
+
+ def labelText(self):
+ return getattr(self.module, 'labelText', self.name())
+
+
+ def icon(self):
+ return getattr(self.module, 'iconName', self.defaultIcon)
+
+
+ def builder(self):
+ for name in ('buildWidget', 'buildDialog', 'buildApp', 'MainFrame'):
+ try:
+ return getattr(self.module, name)
+ except (AttributeError, ):
+ pass
+ raise AttributeError('No builder found')
diff --git a/examples/pykde-sampler/misc/__init__.py b/examples/pykde-sampler/misc/__init__.py
new file mode 100644
index 0000000..b0c9208
--- /dev/null
+++ b/examples/pykde-sampler/misc/__init__.py
@@ -0,0 +1,16 @@
+labelText = 'Misc'
+iconName = 'misc'
+
+
+helpText = ("")
+
+from qt import QFrame, QVBoxLayout
+from kdeui import KTextEdit
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ layout = QVBoxLayout(self)
+ self.text = KTextEdit(helpText, '', self)
+ layout.addWidget(self.text, 1)
diff --git a/examples/pykde-sampler/misc/gradientselect.py b/examples/pykde-sampler/misc/gradientselect.py
new file mode 100644
index 0000000..724dd52
--- /dev/null
+++ b/examples/pykde-sampler/misc/gradientselect.py
@@ -0,0 +1,51 @@
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL, QColor, QSizePolicy, QLabel
+from kdecore import i18n
+from kdeui import KPushButton, KGradientSelector, KTextEdit, KDualColorButton, KColorPatch
+
+iconName = 'colors'
+labelText = 'KGradientSelector'
+docParts = ('kdeui', 'KGradientSelector')
+helpText = ("An example of the KGradientSelector widget."
+ "\n"
+ "Change the start and finish colors with the dual color button."
+ )
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+ self.selector = KGradientSelector(self)
+ self.dualLabel = QLabel('Select Colors:', self)
+
+ self.startColor = QColor('red')
+ self.finishColor = QColor('blue')
+
+ self.selector.setColors(self.startColor, self.finishColor)
+ self.selector.setText('Start', 'Finish')
+
+ self.dualButton = KDualColorButton(self.startColor, self.finishColor, self)
+ self.dualButton.setSizePolicy(QSizePolicy(QSizePolicy.Maximum,
+ QSizePolicy.Maximum))
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help, 20)
+
+ buttonLayout = QHBoxLayout(layout, 4)
+ buttonLayout.addWidget(self.dualLabel, 0)
+ buttonLayout.addWidget(self.dualButton, 1)
+
+ layout.addWidget(self.selector, 10)
+
+
+ self.connect(self.dualButton, SIGNAL('fgChanged(const QColor &)'),
+ self.selector.setFirstColor)
+ self.connect(self.dualButton, SIGNAL('bgChanged(const QColor &)'),
+ self.selector.setSecondColor)
+ self.connect(self.selector, SIGNAL('valueChanged(int)'),
+ self.updateValue)
+
+
+ def updateValue(self, value):
+ ## this should be extended to update a color swatch
+ pass
diff --git a/examples/pykde-sampler/misc/passivepop.py b/examples/pykde-sampler/misc/passivepop.py
new file mode 100644
index 0000000..81d383a
--- /dev/null
+++ b/examples/pykde-sampler/misc/passivepop.py
@@ -0,0 +1,43 @@
+from qt import Qt, QFrame, QHBoxLayout, QVBoxLayout, QLabel, SIGNAL
+from kdeui import KPassivePopup, KTextEdit, KPushButton
+from kdecore import KGlobal, KIcon
+
+iconName = 'popup'
+labelText = 'KPassivePopup'
+docParts = ('kdeui', 'KPassivePopup')
+helpText = ('Examples of the KPassivePopup widget.')
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+ self.button = KPushButton('Show Passive Popups', self)
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help, 10)
+ buttonLayout = QHBoxLayout(layout, 4)
+ buttonLayout.addWidget(self.button, 1)
+ buttonLayout.addStretch(10)
+ layout.addStretch(10)
+
+
+ self.connect(self.button, SIGNAL('clicked()'), self.showPopups)
+
+
+ def showPopups(self):
+ ## no support for all of the 3.5 calls
+ pop = KPassivePopup.message('Hello, <i>KPassivePopup</i>', self)
+ pop.setTimeout(3000)
+ pop.show()
+
+
+ pos = pop.pos()
+ pos.setY(pos.y() + pop.height() + 10)
+
+ ico = KGlobal.instance().iconLoader().loadIcon('help', KIcon.NoGroup,
+ KIcon.SizeSmall)
+ pop = KPassivePopup.message('<b>Hello</b>', 'With Icons', ico, self)
+ pop.setTimeout(3000)
+ pop.show()
+ pop.move(pos)
diff --git a/examples/pykde-sampler/misc/window_info.py b/examples/pykde-sampler/misc/window_info.py
new file mode 100644
index 0000000..08bff22
--- /dev/null
+++ b/examples/pykde-sampler/misc/window_info.py
@@ -0,0 +1,35 @@
+
+
+
+from qt import QFrame, QHBoxLayout, QVBoxLayout, SIGNAL
+from kdeui import KWindowInfo, KPushButton, KTextEdit
+from kdecore import i18n, KApplication
+
+iconName = 'misc'
+labelText = 'KWindowInfo'
+helpText = ''
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent):
+ QFrame.__init__(self, parent)
+ self.button = KPushButton(i18n('Show Message'), self)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ buttonlayout = QHBoxLayout(layout, 4)
+ buttonlayout.addWidget(self.button)
+ buttonlayout.addStretch(1)
+ layout.addStretch(1)
+ self.connect(self.button, SIGNAL('clicked()'), self.showWindowInfo)
+
+
+ def showWindowInfo(self):
+ main = KApplication.kApplication()
+ print main
+ print main.mainWidget()
+
+ info = KWindowInfo(main)
+ info.message('Updated Window Info', 3)
+
+
diff --git a/examples/pykde-sampler/qt_widgets/CONTRIB b/examples/pykde-sampler/qt_widgets/CONTRIB
new file mode 100644
index 0000000..e814d1e
--- /dev/null
+++ b/examples/pykde-sampler/qt_widgets/CONTRIB
@@ -0,0 +1,537 @@
+Module,Item,Path,Contributor
+dcop,DCOPClient,,,
+dcop,DCOPClientTransaction,,,
+dcop,DCOPObject,,,
+dcop,DCOPObjectProxy,,,
+dcop,DCOPRef,,,
+dcop,DCOPReply,,,
+dcop,DCOPStub,,,
+kdecore,BarIcon,,,
+kdecore,BarIconSet,,,
+kdecore,DesktopIcon,,,
+kdecore,DesktopIconSet,,,
+kdecore,IconSize,,,
+kdecore,KAboutData,,,
+kdecore,KAboutPerson,,,
+kdecore,KAboutTranslator,,,
+kdecore,KAccel,,,
+kdecore,KAccelAction,,,
+kdecore,KAccelActions,,,
+kdecore,KAccelBase,,,
+kdecore,KAccelShortcutList,,,
+kdecore,KApplication,,,
+kdecore,KAsyncIO,,,
+kdecore,KAudioPlayer,,,
+kdecore,KBufferedIO,,,
+kdecore,KCalendarSystem,,,
+kdecore,KCalendarSystemFactory,,,
+kdecore,KCatalogue,,,
+kdecore,KCharsets,,,
+kdecore,KClipboardSynchronizer,,,
+kdecore,KCmdLineArgs,,,
+kdecore,KCmdLineOptions,,,
+kdecore,KCodecs,,,
+kdecore,KCompletion,,,
+kdecore,KCompletionBase,,,
+kdecore,KConfig,,,
+kdecore,KConfigBackEnd,,,
+kdecore,KConfigBase,,,
+kdecore,KConfigDialogManager,,,
+kdecore,KConfigGroup,,,
+kdecore,KConfigGroupSaver,,,
+kdecore,KConfigINIBackEnd,,,
+kdecore,KConfigSkeleton,,,
+kdecore,KConfigSkeletonItem,,,
+kdecore,KCrash,,,
+kdecore,KDCOPPropertyProxy,,,
+kdecore,KDE,,,
+kdecore,KDesktopFile,,,
+kdecore,KEntry,,,
+kdecore,KEntryKey,,,
+kdecore,KGlobal,,,
+kdecore,KGlobalAccel,,,
+kdecore,KGlobalSettings,,,
+kdecore,KIDNA,,,
+kdecore,KIPC,,,
+kdecore,KIcon,,,
+kdecore,KIconEffect,,,
+kdecore,KIconLoader,,,
+kdecore,KIconTheme,,,
+kdecore,KInstance,,,
+kdecore,KKey,,,
+kdecore,KKeyNative,,,
+kdecore,KKeySequence,,,
+kdecore,KKeyServer,,,
+kdecore,KLibFactory,,,
+kdecore,KLibLoader,,,
+kdecore,KLibrary,,,
+kdecore,KLocale,,,
+kdecore,KMD5,,,
+kdecore,KMacroExpander,,,
+kdecore,KMacroExpanderBase,,,
+kdecore,KMimeSourceFactory,,,
+kdecore,KMountPoint,,,
+kdecore,KMultipleDrag,,,
+kdecore,KNotifyClient,,,
+kdecore,KPalette,,,
+kdecore,KPixmapProvider,,,
+kdecore,KProcIO,,,
+kdecore,KProcess,,,
+kdecore,KProcessController,,,
+kdecore,KPty,,,
+kdecore,KRFCDate,,,
+kdecore,KRandomSequence,,,
+kdecore,KRegExp,,,
+kdecore,KRootProp,,,
+kdecore,KSaveFile,,,
+kdecore,KSelectionOwner,,,
+kdecore,KSelectionWatcher,,,
+kdecore,KServerSocket,,,
+kdecore,KSessionManaged,,,
+kdecore,KShared,,,
+kdecore,KSharedConfig,,,
+kdecore,KShell,,,
+kdecore,KShellProcess,,,
+kdecore,KShortcut,,,
+kdecore,KShortcutList,,,
+kdecore,KSimpleConfig,,,
+kdecore,KSocket,,,
+kdecore,KStandardDirs,,,
+kdecore,KStartupInfo,,,
+kdecore,KStartupInfoData,,,
+kdecore,KStartupInfoId,,,
+kdecore,KStaticDeleterBase,,,
+kdecore,KStdAccel,,,
+kdecore,KStringHandler,,,
+kdecore,KTempDir,,,
+kdecore,KTempFile,,,
+kdecore,KURL,,,
+kdecore,KURLDrag,,,
+kdecore,KUniqueApplication,,,
+kdecore,KWin,,,
+kdecore,KWinModule,,,
+kdecore,KZoneAllocator,,,
+kdecore,MainBarIcon,,,
+kdecore,MainBarIconSet,,,
+kdecore,NET,,,
+kdecore,NETIcon,,,
+kdecore,NETPoint,,,
+kdecore,NETRect,,,
+kdecore,NETRootInfo,,,
+kdecore,NETRootInfo2,,,
+kdecore,NETSize,,,
+kdecore,NETStrut,,,
+kdecore,NETWinInfo,,,
+kdecore,SmallIcon,,,
+kdecore,SmallIconSet,,,
+kdecore,UserIcon,,,
+kdecore,UserIconSet,,,
+kdecore,i18n,,,
+kdecore,locate,,,
+kdecore,locateLocal,,,
+kdecore,testKEntryMap,,,
+kdecore,urlcmp,,,
+kdefx,KCPUInfo,,,
+kdefx,KImageEffect,,,
+kdefx,KPixmap,,,
+kdefx,KPixmapEffect,,,
+kdefx,KPixmapSplitter,,,
+kdefx,KStyle,,,
+kdefx,kColorBitmaps,,,
+kdefx,kDrawBeButton,,,
+kdefx,kDrawNextButton,,,
+kdefx,kDrawRoundButton,,,
+kdefx,kDrawRoundMask,,,
+kdefx,kRoundMaskRegion,,,
+kdeprint,DrBase,,,
+kdeprint,DrBooleanOption,,,
+kdeprint,DrChoiceGroup,,,
+kdeprint,DrConstraint,,,
+kdeprint,DrFloatOption,,,
+kdeprint,DrGroup,,,
+kdeprint,DrIntegerOption,,,
+kdeprint,DrListOption,,,
+kdeprint,DrMain,,,
+kdeprint,DrPageSize,,,
+kdeprint,DrStringOption,,,
+kdeprint,KMJob,,,
+kdeprint,KMJobManager,,,
+kdeprint,KMManager,,,
+kdeprint,KMObject,,,
+kdeprint,KMPrinter,,,
+kdeprint,KPReloadObject,,,
+kdeprint,KPrintAction,,,
+kdeprint,KPrintDialog,,,
+kdeprint,KPrintDialogPage,,,
+kdeprint,KPrinter,,,
+kdeprint,pageNameToPageSize,,,
+kdeprint,pageSizeToPageName,,,
+kdeprint,rangeToSize,,,
+kdesu,KCookie,,,
+kdesu,KDEsuClient,,,
+kdesu,PTY,,,
+kdesu,PtyProcess,,,
+kdesu,SshProcess,,,
+kdesu,StubProcess,,,
+kdesu,SuProcess,,,
+kdeui,KAboutApplication,,,
+kdeui,KAboutContainer,,,
+kdeui,KAboutContributor,,,
+kdeui,KAboutDialog,,,
+kdeui,KAboutKDE,,,
+kdeui,KAboutWidget,,,
+kdeui,KAction,,,
+kdeui,KActionCollection,,,
+kdeui,KActionMenu,,,
+kdeui,KActionPtrShortcutList,,,
+kdeui,KActionSeparator,,,
+kdeui,KActionShortcutList,,,
+kdeui,KActiveLabel,,,
+kdeui,KAnimWidget,,,
+kdeui,KArrowButton,,,
+kdeui,KAuthIcon,,,
+kdeui,KBugReport,,,
+kdeui,KButtonBox,,,
+kdeui,KCModule,,,
+kdeui,KCharSelect,,,
+kdeui,KCharSelectTable,,,
+kdeui,KColor,,,
+kdeui,KColorButton,,,
+kdeui,KColorCells,,,
+kdeui,KColorCombo,,,
+kdeui,KColorDialog,,,
+kdeui,KColorDrag,,,
+kdeui,KColorPatch,,,
+kdeui,KComboBox,,,
+kdeui,KCommand,,,
+kdeui,KCommandHistory,,,
+kdeui,KCompletionBox,,,
+kdeui,KConfigDialog,,,
+kdeui,KContextMenuManager,,,
+kdeui,KCursor,,,
+kdeui,KDCOPActionProxy,,,
+kdeui,KDateInternalMonthPicker,,,
+kdeui,KDateInternalWeekSelector,,,
+kdeui,KDateInternalYearSelector,,,
+kdeui,KDatePicker,,,
+kdeui,KDateTable,,,
+kdeui,KDateTimeWidget,,,
+kdeui,KDateValidator,,,
+kdeui,KDateWidget,,,
+kdeui,KDialog,,,
+kdeui,KDialogBase,,,
+kdeui,KDialogQueue,,,
+kdeui,KDockArea,,,
+kdeui,KDockMainWindow,,,
+kdeui,KDockManager,,,
+kdeui,KDockTabGroup,,,
+kdeui,KDockWidget,,,
+kdeui,KDockWidgetAbstractHeader,,,
+kdeui,KDockWidgetAbstractHeaderDrag,,,
+kdeui,KDockWidgetHeader,,,
+kdeui,KDockWidgetHeaderDrag,,,
+kdeui,KDockWindow,,,
+kdeui,KDoubleNumInput,,,
+kdeui,KDoubleSpinBox,,,
+kdeui,KDoubleValidator,,,
+kdeui,KDualColorButton,,,
+kdeui,KEdFind,,,
+kdeui,KEdGotoLine,,,
+kdeui,KEdReplace,,,
+kdeui,KEdit,,,
+kdeui,KEditListBox,,,
+kdeui,KEditToolbar,,,
+kdeui,KEditToolbarWidget,,,
+kdeui,KFloatValidator,,,
+kdeui,KFontAction,,,
+kdeui,KFontChooser,,,
+kdeui,KFontCombo,,,
+kdeui,KFontDialog,,,
+kdeui,KFontRequester,,,
+kdeui,KFontSizeAction,,,
+kdeui,KGradientSelector,,,
+kdeui,KGuiItem,,,
+kdeui,KHSSelector,,,
+kdeui,KHelpMenu,,,
+kdeui,KHistoryCombo,,,
+kdeui,KIconView,,,
+kdeui,KIconViewItem,,,
+kdeui,KInputDialog,,,
+kdeui,KIntNumInput,,,
+kdeui,KIntSpinBox,,,
+kdeui,KIntValidator,,,
+kdeui,KJanusWidget,,,
+kdeui,KKeyButton,,,
+kdeui,KKeyChooser,,,
+kdeui,KKeyDialog,,,
+kdeui,KLed,,,
+kdeui,KLineEdit,,,
+kdeui,KLineEditDlg,,,
+kdeui,KListAction,,,
+kdeui,KListBox,,,
+kdeui,KListView,,,
+kdeui,KListViewItem,,,
+kdeui,KMacroCommand,,,
+kdeui,KMainWindow,,,
+kdeui,KMainWindowInterface,,,
+kdeui,KMenuBar,,,
+kdeui,KMessageBox,,,
+kdeui,KMimeTypeValidator,,,
+kdeui,KNamedCommand,,,
+kdeui,KNumInput,,,
+kdeui,KPaletteTable,,,
+kdeui,KPanelAppMenu,,,
+kdeui,KPanelApplet,,,
+kdeui,KPanelExtension,,,
+kdeui,KPanelMenu,,,
+kdeui,KPassivePopup,,,
+kdeui,KPasswordDialog,,,
+kdeui,KPasswordEdit,,,
+kdeui,KPasteTextAction,,,
+kdeui,KPixmapIO,,,
+kdeui,KPopupFrame,,,
+kdeui,KPopupMenu,,,
+kdeui,KPopupTitle,,,
+kdeui,KProgress,,,
+kdeui,KProgressDialog,,,
+kdeui,KPushButton,,,
+kdeui,KRadioAction,,,
+kdeui,KRecentFilesAction,,,
+kdeui,KRestrictedLine,,,
+kdeui,KRootPermsIcon,,,
+kdeui,KRootPixmap,,,
+kdeui,KRuler,,,
+kdeui,KSelectAction,,,
+kdeui,KSelector,,,
+kdeui,KSeparator,,,
+kdeui,KSplashScreen,,,
+kdeui,KSqueezedTextLabel,,,
+kdeui,KStatusBar,,,
+kdeui,KStatusBarLabel,,,
+kdeui,KStdAction,,,
+kdeui,KStdGuiItem,,,
+kdeui,KStringListValidator,,,
+kdeui,KSystemTray,,,
+kdeui,KTabBar,,,
+kdeui,KTabCtl,,,
+kdeui,KTabWidget,,,
+kdeui,KTextBrowser,,,
+kdeui,KTextEdit,,,
+kdeui,KTimeWidget,,,
+kdeui,KTipDatabase,,,
+kdeui,KTipDialog,,,
+kdeui,KToggleAction,,,
+kdeui,KToggleFullScreenAction,,,
+kdeui,KToggleToolBarAction,,,
+kdeui,KToolBar,,,
+kdeui,KToolBarButton,,,
+kdeui,KToolBarPopupAction,,,
+kdeui,KToolBarRadioGroup,,,
+kdeui,KToolBarSeparator,,,
+kdeui,KURLLabel,,,
+kdeui,KValueSelector,,,
+kdeui,KWidgetAction,,,
+kdeui,KWindowInfo,,,
+kdeui,KWindowListMenu,,,
+kdeui,KWizard,,,
+kdeui,KWordWrap,,,
+kdeui,KWritePermsIcon,,,
+kdeui,KXMLGUIBuilder,,,
+kdeui,KXMLGUIClient,,,
+kdeui,KXMLGUIFactory,,,
+kdeui,KXYSelector,,,
+kdeui,QXEmbed,,,
+kdeui,testKActionList,,,
+kfile,KApplicationPropsPlugin,,,
+kfile,KBindingPropsPlugin,,,
+kfile,KCombiView,,,
+kfile,KCustomMenuEditor,,,
+kfile,KDesktopPropsPlugin,,,
+kfile,KDevicePropsPlugin,,,
+kfile,KDirOperator,,,
+kfile,KDirSelectDialog,,,
+kfile,KDirSize,,,
+kfile,KDiskFreeSp,,,
+kfile,KEncodingFileDialog,,,
+kfile,KExecPropsPlugin,,,
+kfile,KFile,,,
+kfile,KFileDetailView,,,
+kfile,KFileDialog,,,
+kfile,KFileFilterCombo,,,
+kfile,KFileIconView,,,
+kfile,KFileIconViewItem,,,
+kfile,KFileListViewItem,,,
+kfile,KFileOpenWithHandler,,,
+kfile,KFilePermissionsPropsPlugin,,,
+kfile,KFilePreview,,,
+kfile,KFilePropsPlugin,,,
+kfile,KFileSharePropsPlugin,,,
+kfile,KFileTreeBranch,,,
+kfile,KFileTreeView,,,
+kfile,KFileTreeViewItem,,,
+kfile,KFileTreeViewToolTip,,,
+kfile,KFileView,,,
+kfile,KFileViewSignaler,,,
+kfile,KIconButton,,,
+kfile,KIconCanvas,,,
+kfile,KIconDialog,,,
+kfile,KImageFilePreview,,,
+kfile,KNotify,,,
+kfile,KNotifyDialog,,,
+kfile,KOpenWithDlg,,,
+kfile,KPreviewWidgetBase,,,
+kfile,KPropertiesDialog,,,
+kfile,KPropsDlgPlugin,,,
+kfile,KRecentDocument,,,
+kfile,KURLBar,,,
+kfile,KURLBarItem,,,
+kfile,KURLBarItemDialog,,,
+kfile,KURLBarListBox,,,
+kfile,KURLComboBox,,,
+kfile,KURLComboRequester,,,
+kfile,KURLPropsPlugin,,,
+kfile,KURLRequester,,,
+kfile,KURLRequesterDlg,,,
+khtml,DOM,,,
+khtml,KHTMLPart,,,
+khtml,KHTMLSettings,,,
+khtml,KHTMLView,,,
+kio,KAr,,,
+kio,KArchive,,,
+kio,KArchiveDirectory,,,
+kio,KArchiveEntry,,,
+kio,KArchiveFile,,,
+kio,KAutoMount,,,
+kio,KAutoUnmount,,,
+kio,KDCOPServiceStarter,,,
+kio,KDEDesktopMimeType,,,
+kio,KDataTool,,,
+kio,KDataToolAction,,,
+kio,KDataToolInfo,,,
+kio,KDirLister,,,
+kio,KDirNotify,,,
+kio,KDirWatch,,,
+kio,KEMailSettings,,,
+kio,KExecMimeType,,,
+kio,KFileFilter,,,
+kio,KFileItem,,,
+kio,KFileMetaInfo,,,
+kio,KFileMetaInfoGroup,,,
+kio,KFileMetaInfoItem,,,
+kio,KFileMetaInfoProvider,,,
+kio,KFileMimeTypeInfo,,,
+kio,KFilePlugin,,,
+kio,KFileShare,,,
+kio,KFileSharePrivate,,,
+kio,KFilterBase,,,
+kio,KFilterDev,,,
+kio,KFolderType,,,
+kio,KIO,,,
+kio,KImageIO,,,
+kio,KMimeMagic,,,
+kio,KMimeMagicResult,,,
+kio,KMimeType,,,
+kio,KOCRDialog,,,
+kio,KOCRDialogFactory,,,
+kio,KOpenWithHandler,,,
+kio,KProcessRunner,,,
+kio,KProtocolInfo,,,
+kio,KProtocolManager,,,
+kio,KRun,,,
+kio,KST_CTimeInfo,,,
+kio,KST_KCustom,,,
+kio,KST_KDEDesktopMimeType,,,
+kio,KST_KExecMimeType,,,
+kio,KST_KFolderType,,,
+kio,KST_KImageIO,,,
+kio,KST_KImageIOFormat,,,
+kio,KST_KMimeType,,,
+kio,KST_KProtocolInfo,,,
+kio,KST_KProtocolInfoFactory,,,
+kio,KST_KService,,,
+kio,KST_KServiceFactory,,,
+kio,KST_KServiceGroup,,,
+kio,KST_KServiceGroupFactory,,,
+kio,KST_KServiceType,,,
+kio,KST_KServiceTypeFactory,,,
+kio,KST_KSycocaEntry,,,
+kio,KScanDialog,,,
+kio,KScanDialogFactory,,,
+kio,KService,,,
+kio,KServiceGroup,,,
+kio,KServiceOffer,,,
+kio,KServiceSeparator,,,
+kio,KServiceType,,,
+kio,KServiceTypeProfile,,,
+kio,KShellCompletion,,,
+kio,KShred,,,
+kio,KSimpleFileFilter,,,
+kio,KSycoca,,,
+kio,KSycocaEntry,,,
+kio,KSycocaFactory,,,
+kio,KTar,,,
+kio,KTrader,,,
+kio,KURIFilter,,,
+kio,KURIFilterData,,,
+kio,KURIFilterPlugin,,,
+kio,KURLCompletion,,,
+kio,KURLPixmapProvider,,,
+kio,KZip,,,
+kio,KZipFileEntry,,,
+kio,Observer,,,
+kio,RenameDlgPlugin,,,
+kio,ThumbCreator,,,
+kio,testKIOMetaData,,,
+kio,testKIOUDSEntry,,,
+kio,testKIOUDSEntryList,,,
+kmdi,KMdi,,,
+kmdi,KMdiChildArea,,,
+kmdi,KMdiChildFrm,,,
+kmdi,KMdiChildFrmCaption,,,
+kmdi,KMdiChildFrmDragBeginEvent,,,
+kmdi,KMdiChildFrmDragEndEvent,,,
+kmdi,KMdiChildFrmMoveEvent,,,
+kmdi,KMdiChildFrmResizeBeginEvent,,,
+kmdi,KMdiChildFrmResizeEndEvent,,,
+kmdi,KMdiChildView,,,
+kmdi,KMdiMainFrm,,,
+kmdi,KMdiTaskBar,,,
+kmdi,KMdiTaskBarButton,,,
+kmdi,KMdiToolViewAccessor,,,
+kmdi,KMdiViewCloseEvent,,,
+kmdi,KMdiWin32IconButton,,,
+kparts,KParts,,,
+kparts,createReadOnlyPart,,,
+kparts,createReadWritePart,,,
+kparts,testQMapQCStringInt,,,
+kspell,KS_ADD,,,
+kspell,KS_CANCEL,,,
+kspell,KS_CLIENT_ASPELL,,,
+kspell,KS_CLIENT_HSPELL,,,
+kspell,KS_CLIENT_ISPELL,,,
+kspell,KS_CONFIG,,,
+kspell,KS_E_ASCII,,,
+kspell,KS_E_CP1251,,,
+kspell,KS_E_CP1255,,,
+kspell,KS_E_KOI8R,,,
+kspell,KS_E_KOI8U,,,
+kspell,KS_E_LATIN1,,,
+kspell,KS_E_LATIN13,,,
+kspell,KS_E_LATIN15,,,
+kspell,KS_E_LATIN2,,,
+kspell,KS_E_LATIN3,,,
+kspell,KS_E_LATIN4,,,
+kspell,KS_E_LATIN5,,,
+kspell,KS_E_LATIN7,,,
+kspell,KS_E_LATIN8,,,
+kspell,KS_E_LATIN9,,,
+kspell,KS_E_UTF8,,,
+kspell,KS_IGNORE,,,
+kspell,KS_IGNOREALL,,,
+kspell,KS_REPLACE,,,
+kspell,KS_REPLACEALL,,,
+kspell,KS_STOP,,,
+kspell,KS_SUGGEST,,,
+kspell,KSpell,,,
+kspell,KSpellConfig,,,
+kspell,KSpellDlg,,,
diff --git a/examples/pykde-sampler/qt_widgets/__init__.py b/examples/pykde-sampler/qt_widgets/__init__.py
new file mode 100644
index 0000000..ffe7bed
--- /dev/null
+++ b/examples/pykde-sampler/qt_widgets/__init__.py
@@ -0,0 +1,17 @@
+labelText = 'Qt Widgets'
+iconName = 'designer'
+
+helpText = """Qt provides a rich set of widgets for application use.
+Select the children of this item to see for yourself."""
+
+from qt import QFrame, QVBoxLayout, SIGNAL
+from kdeui import KTextEdit
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ layout.addStretch(1)
diff --git a/examples/pykde-sampler/qt_widgets/table.py b/examples/pykde-sampler/qt_widgets/table.py
new file mode 100644
index 0000000..d6b6e3e
--- /dev/null
+++ b/examples/pykde-sampler/qt_widgets/table.py
@@ -0,0 +1,42 @@
+labelText = 'QTable'
+iconName = 'inline_table'
+
+helpText = """From the docs: 'The QTable class provides a flexible
+editable table widget.'
+"""
+
+import csv
+import os
+
+from qt import QFrame, QStringList, QVBoxLayout, SIGNAL
+from qttable import QTable
+
+from kdeui import KTextEdit
+
+contrib = os.path.join(os.path.split(__file__)[0], 'CONTRIB')
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+
+ data = csv.reader(open(contrib))
+ header = data.next()
+ items = [item for item in data]
+
+ self.table = table = QTable(len(items), len(header), self)
+ headers = QStringList()
+ for headertext in header:
+ headers.append(headertext)
+ table.setColumnLabels(headers)
+
+ cols = range(len(header))
+ for row, record in enumerate(items):
+ for col in cols:
+ table.setText(row, col, record[col])
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help)
+ layout.addWidget(self.table)
+ layout.addStretch(1)
diff --git a/examples/pykde-sampler/runner.py b/examples/pykde-sampler/runner.py
new file mode 100755
index 0000000..8b1ad2c
--- /dev/null
+++ b/examples/pykde-sampler/runner.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+"""
+
+"""
+import sys
+from kdecore import KApplication, KCmdLineArgs
+from kdeui import KMainWindow
+from qt import QVBoxLayout
+
+## relative import -- cry me a river!
+import about
+
+
+class SamplerRunnerWindow(KMainWindow):
+ def __init__(self, ctor):
+ KMainWindow.__init__(self)
+ layout = QVBoxLayout(self)
+ layout.setAutoAdd(True)
+ self.widget = ctor(self)
+
+
+def importItem(name):
+ """ importItem(name) -> import an item from a module by dotted name
+
+ """
+ def importName(name):
+ """ importName(name) -> import and return a module by name in dotted form
+
+ Copied from the Python lib docs.
+ """
+ mod = __import__(name)
+ for comp in name.split('.')[1:]:
+ mod = getattr(mod, comp)
+ return mod
+
+ names = name.split('.')
+ modname, itemname = names[0:-1], names[-1]
+ mod = importName(str.join('.', modname))
+ return getattr(mod, itemname)
+
+
+
+if __name__ == '__main__':
+ options = [('+item', 'An item in the sys.path')]
+ KCmdLineArgs.init(sys.argv, about.about)
+ KCmdLineArgs.addCmdLineOptions(options)
+
+ args = KCmdLineArgs.parsedArgs()
+ if not args.count():
+ args.usage()
+ else:
+ pathitem = args.arg(0)
+ widget = importItem(pathitem)
+
+ app = KApplication()
+ mainWindow = SamplerRunnerWindow(widget)
+ mainWindow.show()
+ app.exec_loop()
diff --git a/examples/pykde-sampler/sampler.py b/examples/pykde-sampler/sampler.py
new file mode 100755
index 0000000..bacf634
--- /dev/null
+++ b/examples/pykde-sampler/sampler.py
@@ -0,0 +1,423 @@
+#!/usr/bin/env python
+""" The PyKDE application sampler
+
+This module defines the top-level widgets for displaying the sampler
+application.
+
+
+"""
+import inspect
+import os
+import sys
+
+from qt import SIGNAL, SLOT, PYSIGNAL, Qt
+from qt import QVBoxLayout, QLabel, QPixmap, QSplitter, QFrame, QDialog
+from qt import QSizePolicy, QHBoxLayout, QSpacerItem, QPushButton
+
+from kdecore import i18n, KAboutData, KApplication, KCmdLineArgs, KGlobal
+from kdecore import KGlobalSettings, KWin, KWinModule, KURL, KIcon
+
+from kdeui import KComboBox, KListView, KListViewItem, KTabWidget, KTextEdit
+from kdeui import KMainWindow, KPushButton, KSplashScreen, KStdAction
+from kdeui import KKeyDialog, KEditToolbar
+
+from kio import KTrader
+from kparts import createReadOnlyPart, createReadWritePart
+from khtml import KHTMLPart
+
+import about
+import lib
+
+
+try:
+ __file__
+except (NameError, ):
+ __file__ = sys.argv[0]
+
+
+sigDoubleClicked = SIGNAL('doubleClicked(QListViewItem *)')
+sigViewItemSelected = SIGNAL('selectionChanged(QListViewItem *)')
+sigSampleSelected = PYSIGNAL('sample selected')
+
+blank = KURL('about:blank')
+
+
+def appConfig(group=None):
+ """ appConfig(group=None) -> returns the application KConfig
+
+ """
+ config = KGlobal.instance().config()
+ if group is not None:
+ config.setGroup(group)
+ return config
+
+
+def getIcon(name, group=KIcon.NoGroup, size=KIcon.SizeSmall):
+ """ returns a kde icon by name
+
+ """
+ return KGlobal.instance().iconLoader().loadIcon(name, group, size)
+
+
+def getIconSet(name, group=KIcon.NoGroup, size=KIcon.SizeSmall):
+ """ returns a kde icon set by name
+
+ """
+ return KGlobal.instance().iconLoader().loadIconSet(name, group, size)
+
+
+def buildPart(parent, query, constraint, writable=False):
+ """ builds the first available offered part on the parent
+
+ """
+ offers = KTrader.self().query(query, constraint)
+ for ptr in offers:
+ if writable:
+ builder = createReadWritePart
+ else:
+ builder = createReadOnlyPart
+ part = builder(ptr.library(), parent, ptr.name())
+ if part:
+ break
+ return part
+
+
+
+class CommonFrame(QFrame):
+ """ provides a modicum of reuse
+
+ """
+ def __init__(self, parent):
+ QFrame.__init__(self, parent)
+ layout = QVBoxLayout(self)
+ layout.setAutoAdd(True)
+ layout.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
+
+
+class SamplerFrame(CommonFrame):
+ """ frame type that swaps out old widgets for new when told to do so
+
+ """
+ def __init__(self, parent):
+ CommonFrame.__init__(self, parent)
+ self.widget = None
+
+ def setWidget(self, widget):
+ self.layout().deleteAllItems()
+ previous = self.widget
+ if previous:
+ previous.close()
+ delattr(self, 'widget')
+ self.widget = widget
+
+ def showSample(self, item, module):
+ try:
+ frameType = module.builder()
+ except (AttributeError, ):
+ print 'No sample callable defined in %s' % (module.name(), )
+ else:
+ frame = frameType(self)
+ self.setWidget(frame)
+ frame.show()
+
+
+class SourceFrame(CommonFrame):
+ """ frame with part for displaying python source
+
+ """
+ def __init__(self, parent):
+ CommonFrame.__init__(self, parent)
+ query = ''
+ self.part = buildPart(self, 'application/x-python', query, False)
+
+ def showModuleSource(self, item, module):
+ if not self.part:
+ print 'No part available for displaying python source.'
+ return
+ try:
+ modulefile = inspect.getabsfile(module.module)
+ except:
+ return
+ self.part.openURL(blank)
+ if os.path.splitext(modulefile)[-1] == '.py':
+ self.part.openURL(KURL('file://%s' % modulefile))
+
+
+class WebFrame(CommonFrame):
+ """ frame with part for viewing web pages
+
+ """
+ docBase = 'http://www.riverbankcomputing.com/Docs/PyKDE3/classref/'
+
+ def __init__(self, parent):
+ CommonFrame.__init__(self, parent)
+ self.part = part = buildPart(self, 'text/html', "Type == 'Service'")
+ #part.connect(part, SIGNAL('khtmlMousePressEvent(a)'), self.onURL)
+
+ def onURL(self, a):
+ print '****', a
+
+ def showDocs(self, item, module):
+ try:
+ mod, cls = module.module.docParts
+ except (AttributeError, ):
+ url = blank
+ else:
+ url = KURL(self.docUrl(mod, cls))
+ self.part.openURL(url)
+
+
+ def docUrl(self, module, klass):
+ """ docUrl(name) -> return a doc url given a name from the kde libs
+
+ """
+ return '%s/%s/%s.html' % (self.docBase, module, klass, )
+
+
+class OutputFrame(KTextEdit):
+ """ text widget that acts (just enough) like a file
+
+ """
+ def __init__(self, parent, filehandle):
+ KTextEdit.__init__(self, parent)
+ self.filehandle = filehandle
+ self.setReadOnly(True)
+ self.setFont(KGlobalSettings.fixedFont())
+
+
+ def write(self, text):
+ self.insert(text)
+
+
+ def clear(self):
+ self.setText('')
+
+
+ def __getattr__(self, name):
+ return getattr(self.filehandle, name)
+
+
+class SamplerListView(KListView):
+ """ the main list view of samples
+
+ """
+ def __init__(self, parent):
+ KListView.__init__(self, parent)
+ self.addColumn(i18n('Sample'))
+ self.setRootIsDecorated(True)
+
+ modules = lib.listmodules()
+ modules.sort(lambda a, b: cmp(a[0], b[0]))
+
+ modmap = dict(modules)
+ modules = [(name.split('.'), name, mod) for name, mod in modules]
+ roots, cache = {}, {}
+
+ for names, modname, module in modules:
+ topname, subnames = names[0], names[1:]
+ item = roots.get(topname, None)
+ if item is None:
+ roots[topname] = item = KListViewItem(self, module.labelText())
+ item.module = module
+ item.setPixmap(0, getIcon(module.icon()))
+
+ bname = ''
+ subitem = item
+ for subname in subnames:
+ bname = '%s.%s' % (bname, subname, )
+ item = cache.get(bname, None)
+ if item is None:
+ subitem = cache[bname] = \
+ KListViewItem(subitem, module.labelText())
+ subitem.module = module
+ subitem.setPixmap(0, getIcon(module.icon()))
+ subitem = item
+
+ for root in roots.values():
+ self.setOpen(root, True)
+
+
+class SamplerMainWindow(KMainWindow):
+ """ the main window
+
+ """
+ def __init__(self, *args):
+ KMainWindow.__init__(self, *args)
+ self.hSplitter = hSplit = QSplitter(Qt.Horizontal, self)
+ self.samplesList = samplesList = SamplerListView(hSplit)
+ self.vSplitter = vSplit = QSplitter(Qt.Vertical, hSplit)
+ self.setCentralWidget(hSplit)
+ self.setIcon(getIcon('kmail'))
+
+ hSplit.setOpaqueResize(True)
+ vSplit.setOpaqueResize(True)
+
+ self.contentTabs = cTabs = KTabWidget(vSplit)
+ self.outputTabs = oTabs = KTabWidget(vSplit)
+
+ self.sampleFrame = SamplerFrame(cTabs)
+ self.sourceFrame = SourceFrame(cTabs)
+ self.webFrame = WebFrame(cTabs)
+
+ cTabs.insertTab(self.sampleFrame, getIconSet('exec'), i18n('Sample'))
+ cTabs.insertTab(self.sourceFrame, getIconSet('source'), i18n('Source'))
+ cTabs.insertTab(self.webFrame, getIconSet('help'), i18n('Docs'))
+
+ sys.stdout = self.stdoutFrame = OutputFrame(oTabs, sys.stdout)
+ sys.stderr = self.stderrFrame = OutputFrame(oTabs, sys.stderr)
+
+ termIcons = getIconSet('terminal')
+ oTabs.insertTab(self.stdoutFrame, termIcons, i18n('stdout'))
+ oTabs.insertTab(self.stderrFrame, termIcons, i18n('stderr'))
+
+ self.resize(640, 480)
+ height, width = self.height(), self.width()
+ hSplit.setSizes([width * 0.35, width * 0.65])
+ vSplit.setSizes([height * 0.80, height * 0.20])
+
+ self.xmlRcFileName = os.path.abspath(os.path.join(os.path.dirname(__file__), 'sampler.rc'))
+ self.setXMLFile(self.xmlRcFileName)
+ config = appConfig()
+ actions = self.actionCollection()
+ actions.readShortcutSettings("", config)
+ self.quitAction = KStdAction.quit(self.close, actions)
+
+ self.toggleMenubarAction = \
+ KStdAction.showMenubar(self.showMenubar, actions)
+ self.toggleToolbarAction = \
+ KStdAction.showToolbar(self.showToolbar, actions)
+ self.toggleStatusbarAction = \
+ KStdAction.showStatusbar(self.showStatusbar, actions)
+ self.configureKeysAction = \
+ KStdAction.keyBindings(self.showConfigureKeys, actions)
+ self.configureToolbarAction = \
+ KStdAction.configureToolbars(self.showConfigureToolbars, actions)
+ self.configureAppAction = \
+ KStdAction.preferences(self.showConfiguration, actions)
+
+ connect = self.connect
+ connect(samplesList, sigViewItemSelected, self.sampleSelected)
+ connect(self, sigSampleSelected, self.reloadModule)
+ connect(self, sigSampleSelected, self.sourceFrame.showModuleSource)
+ connect(self, sigSampleSelected, self.sampleFrame.showSample)
+ connect(self, sigSampleSelected, self.webFrame.showDocs)
+
+ self.restoreWindowSize(config)
+ self.createGUI(self.xmlRcFileName, 0)
+ self.sourceFrame.part.openURL(KURL('file://%s' % os.path.abspath(__file__)))
+
+
+ def showConfiguration(self):
+ """ showConfiguration() -> display the config dialog
+
+ """
+ return
+ ## not yet implemented
+ dlg = configdialog.ConfigurationDialog(self)
+ for obj in (self.stderrFrame, self.stdoutFrame, self.pythonShell):
+ call = getattr(obj, 'configChanged', None)
+ if call:
+ self.connect(dlg, util.sigConfigChanged, call)
+ dlg.show()
+
+
+ def senderCheckShow(self, widget):
+ """ senderCheckShow(widget) -> show or hide widget if sender is checked
+
+ """
+ if self.sender().isChecked():
+ widget.show()
+ else:
+ widget.hide()
+
+
+ def showMenubar(self):
+ """ showMenuBar() -> toggle the menu bar
+
+ """
+ self.senderCheckShow(self.menuBar())
+
+
+ def showToolbar(self):
+ """ showToolbar() -> toggle the tool bar
+
+ """
+ self.senderCheckShow(self.toolBar())
+
+
+ def showStatusbar(self):
+ """ showStatusbar() -> toggle the status bar
+
+ """
+ self.senderCheckShow(self.statusBar())
+
+
+ def showConfigureKeys(self):
+ """ showConfigureKeys() -> show the shortcut keys dialog
+
+ """
+ ret = KKeyDialog.configure(self.actionCollection(), self)
+ print ret
+ if ret == QDialog.Accepted:
+ actions = self.actionCollection()
+ actions.writeShortcutSettings(None, appConfig())
+
+
+ def showConfigureToolbars(self):
+ """ showConfigureToolbars() -> broken
+
+ """
+ dlg = KEditToolbar(self.actionCollection(), self.xmlRcFileName)
+ self.connect(dlg, SIGNAL('newToolbarConfig()'), self.rebuildGui)
+ #connect(self, sigSampleSelected, self.sourceFrame.showModuleSource)
+
+ dlg.exec_loop()
+
+
+ def rebuildGui(self):
+ """ rebuildGui() -> recreate the gui and refresh the palette
+
+ """
+ self.createGUI(self.xmlRcFileName, 0)
+ for widget in (self.toolBar(), self.menuBar(), ):
+ widget.setPalette(self.palette())
+
+
+ def sampleSelected(self):
+ """ sampleSelected() -> emit the current item and its module
+
+ """
+ self.stdoutFrame.clear()
+ self.stderrFrame.clear()
+ item = self.sender().currentItem()
+ self.emit(sigSampleSelected, (item, item.module))
+
+
+ def setSplashPixmap(self, pixmap):
+ """ setSplashPixmap(pixmap) -> assimilate the splash screen pixmap
+
+ """
+ target = self.sampleFrame
+ label = QLabel(target)
+ label.setPixmap(pixmap)
+ target.setWidget(label)
+
+
+ def reloadModule(self, item, module):
+ print >> sys.__stdout__, 'reload: ', reload(module.module)
+
+
+if __name__ == '__main__':
+ aboutdata = about.about()
+ KCmdLineArgs.init(sys.argv, aboutdata)
+ app = KApplication()
+
+ splashpix = QPixmap(os.path.join(lib.samplerpath, 'aboutkde.png'))
+ splash = KSplashScreen(splashpix)
+ splash.resize(splashpix.size())
+ splash.show()
+ mainWindow = SamplerMainWindow()
+ mainWindow.setSplashPixmap(splashpix)
+ mainWindow.show()
+ splash.finish(mainWindow)
+ app.exec_loop()
diff --git a/examples/pykde-sampler/sampler.rc b/examples/pykde-sampler/sampler.rc
new file mode 100644
index 0000000..fc068ca
--- /dev/null
+++ b/examples/pykde-sampler/sampler.rc
@@ -0,0 +1,13 @@
+<!DOCTYPE kpartgui>
+<kpartgui version="1" name="MainWindow" >
+ <MenuBar>
+ <Merge/>
+ </MenuBar>
+ <ToolBar noMerge="1" name="mainToolBar" >
+ <Action name="options_configure_toolbars" />
+ <Action name="options_configure_keybinding" />
+ <Action name="file_quit" />
+ <Action name="help_about_kde" />
+ </ToolBar>
+ <ActionProperties/>
+</kpartgui>
diff --git a/examples/pykde-sampler/wizards/__init__.py b/examples/pykde-sampler/wizards/__init__.py
new file mode 100644
index 0000000..63472b4
--- /dev/null
+++ b/examples/pykde-sampler/wizards/__init__.py
@@ -0,0 +1,2 @@
+iconName = 'wizard'
+labelText = 'Wizards'
diff --git a/examples/pykde-sampler/wizards/wiz.py b/examples/pykde-sampler/wizards/wiz.py
new file mode 100644
index 0000000..1cb5544
--- /dev/null
+++ b/examples/pykde-sampler/wizards/wiz.py
@@ -0,0 +1,2 @@
+iconName = 'wizard'
+labelText = 'Wizard'
diff --git a/examples/pykde-sampler/xwin/__init__.py b/examples/pykde-sampler/xwin/__init__.py
new file mode 100644
index 0000000..f9ff0b1
--- /dev/null
+++ b/examples/pykde-sampler/xwin/__init__.py
@@ -0,0 +1,18 @@
+labelText = 'X Windows Features'
+iconName = 'kcmx'
+
+helpText = """KDE and PyKDE allow interaction with the X Window system. Check
+out the nifty samples below."""
+
+from qt import QFrame, QLabel, QVBoxLayout
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ layout = QVBoxLayout(self)
+ self.text = QLabel(helpText, self)
+ layout.addWidget(self.text, 1)
+
+
+
+
diff --git a/examples/pytestimage.png b/examples/pytestimage.png
new file mode 100644
index 0000000..3bb4e68
--- /dev/null
+++ b/examples/pytestimage.png
Binary files differ
diff --git a/examples/qxembed_example.png b/examples/qxembed_example.png
new file mode 100644
index 0000000..55eb729
--- /dev/null
+++ b/examples/qxembed_example.png
Binary files differ
diff --git a/examples/qxembedexample.py b/examples/qxembedexample.py
new file mode 100644
index 0000000..0e21631
--- /dev/null
+++ b/examples/qxembedexample.py
@@ -0,0 +1,79 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'qxembedexample.ui'
+#
+# Created: Thu Apr 29 02:17:37 2004
+# by: The PyQt User Interface Compiler (pyuic) 3.11
+#
+# WARNING! All changes made in this file will be lost!
+
+
+from qt import *
+
+
+class QXEmbedExample(QWidget):
+ def __init__(self,parent = None,name = None,fl = 0):
+ QWidget.__init__(self,parent,name,fl)
+
+ if not name:
+ self.setName("QXEmbedExample")
+
+
+ QXEmbedExampleLayout = QVBoxLayout(self,11,6,"QXEmbedExampleLayout")
+
+ layout2 = QHBoxLayout(None,0,6,"layout2")
+
+ self.appNameCombo = KComboBox(0,self,"appNameCombo")
+ self.appNameCombo.setSizePolicy(QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Fixed,0,0,self.appNameCombo.sizePolicy().hasHeightForWidth()))
+ layout2.addWidget(self.appNameCombo)
+
+ self.launchButton = KPushButton(self,"launchButton")
+ self.launchButton.setSizePolicy(QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Fixed,0,0,self.launchButton.sizePolicy().hasHeightForWidth()))
+ layout2.addWidget(self.launchButton)
+ spacer1 = QSpacerItem(209,31,QSizePolicy.Expanding,QSizePolicy.Minimum)
+ layout2.addItem(spacer1)
+ QXEmbedExampleLayout.addLayout(layout2)
+
+ self.line1 = QFrame(self,"line1")
+ self.line1.setFrameShape(QFrame.HLine)
+ self.line1.setFrameShadow(QFrame.Sunken)
+ self.line1.setFrameShape(QFrame.HLine)
+ QXEmbedExampleLayout.addWidget(self.line1)
+
+ self.mainTabs = QTabWidget(self,"mainTabs")
+
+ self.tab = QWidget(self.mainTabs,"tab")
+ tabLayout = QHBoxLayout(self.tab,11,6,"tabLayout")
+
+ self.textLabel1 = QLabel(self.tab,"textLabel1")
+ tabLayout.addWidget(self.textLabel1)
+ self.mainTabs.insertTab(self.tab,QString(""))
+ QXEmbedExampleLayout.addWidget(self.mainTabs)
+
+ self.languageChange()
+
+ self.resize(QSize(471,499).expandedTo(self.minimumSizeHint()))
+ self.clearWState(Qt.WState_Polished)
+
+ self.connect(self.launchButton,SIGNAL("clicked()"),self.launchApp)
+
+
+ def languageChange(self):
+ self.setCaption(self.__tr("QXEmbed Example"))
+ self.appNameCombo.clear()
+ self.appNameCombo.insertItem(self.__tr("kcalc"))
+ self.appNameCombo.insertItem(self.__tr("konqueror"))
+ self.appNameCombo.insertItem(self.__tr("kedit"))
+ self.launchButton.setText(self.__tr("Launch and Embed"))
+ self.textLabel1.setText(self.__tr("<b>QXEmbed Example</b>\n"
+"<br><br>\n"
+"\n"
+"Select one of the app names from the combo list, then launch it with the button. Two seconds after launch, the window for the new process will get added as a new tab."))
+ self.mainTabs.changeTab(self.tab,self.__tr("Help"))
+
+
+ def launchApp(self):
+ print "QXEmbedExample.launchApp(): Not implemented yet"
+
+ def __tr(self,s,c = None):
+ return qApp.translate("QXEmbedExample",s,c)
diff --git a/examples/qxembedexample.ui b/examples/qxembedexample.ui
new file mode 100644
index 0000000..d346516
--- /dev/null
+++ b/examples/qxembedexample.ui
@@ -0,0 +1,150 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>QXEmbedExample</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>QXEmbedExample</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>471</width>
+ <height>499</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>QXEmbed Example</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KComboBox">
+ <item>
+ <property name="text">
+ <string>kcalc</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>konqueror</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>kedit</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>appNameCombo</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="KPushButton">
+ <property name="name">
+ <cstring>launchButton</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Launch and Embed</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>209</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>mainTabs</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Help</string>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;QXEmbed Example&lt;/b&gt;
+&lt;br&gt;&lt;br&gt;
+
+Select one of the app names from the combo list, then launch it with the button. Two seconds after launch, the window for the new process will get added as a new tab.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>launchButton</sender>
+ <signal>clicked()</signal>
+ <receiver>QXEmbedExample</receiver>
+ <slot>launchApp()</slot>
+ </connection>
+</connections>
+<slots>
+ <slot>launchApp()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/examples/systray.py b/examples/systray.py
new file mode 100644
index 0000000..7391c9b
--- /dev/null
+++ b/examples/systray.py
@@ -0,0 +1,54 @@
+"""
+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
+from kdecore import KApplication, KIcon, KIconLoader
+from kdeui import KMainWindow, KSystemTray
+
+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")
+icons = KIconLoader ()
+
+systray = KSystemTray (mainWindow)
+systray.setPixmap (icons.loadIcon("stop", KIcon.Desktop))
+systray.show ()
+
+#mainWindow.show()
+app.exec_loop()
+
+
diff --git a/examples/uikmdi.py b/examples/uikmdi.py
new file mode 100644
index 0000000..3a213bc
--- /dev/null
+++ b/examples/uikmdi.py
@@ -0,0 +1,203 @@
+#!/usr/bin/env python
+"""
+This is a rough Python translation of the ideas presented in this KMDI tutorial:
+
+ http://web.tiscali.it/andreabergia/kmditutorial.html
+
+What does work:
+
+ IDEAlMode - yay!
+
+ Adding and closing child views
+
+ Two-way syncing between a tool widget and a matching child view
+
+All is not rosy, however:
+
+ Instances of the KmdiExample maintain a dictionary of child views. Values
+ cannot be deleted from this dictionary during a window close (causes an
+ immediate segfault).
+
+ Child views created after initialization aren't numbered correctly; given
+ the first problem, it's harder to do this than it's really worth.
+
+ The example segfaults at shutdown if the tool (on the left) is is open but
+ is not in overlap-mode.
+
+"""
+import os
+import sys
+
+from qt import SIGNAL, QVBoxLayout, QLabel
+from kdecore import i18n, KAboutData, KApplication, KGlobal, KIcon, KCmdLineArgs
+from kdeui import KDockWidget, KListBox, KStdAction
+
+try:
+ from kmdi import KMdi, KMdiMainFrm, KMdiChildView
+except (ImportError, ):
+ print 'Exception importing KMDI; check your PyKDE installation'
+ sys.exit(1)
+
+
+sigChildCloseRequest = SIGNAL('childWindowCloseRequest(KMdiChildView *)')
+sigChildViewActivated = SIGNAL('viewActivated(KMdiChildView *)')
+sigBoxSelectionChanged = SIGNAL('selectionChanged(QListBoxItem *)')
+
+
+def getIcon(name, group=KIcon.NoGroup, size=KIcon.SizeSmall):
+ """ returns a kde icon by name
+
+ """
+ return KGlobal.instance().iconLoader().loadIcon(name, group, size)
+
+
+class KmdiExample(KMdiMainFrm):
+ """ KmdiExample(parent=None) -> an example KMdiMainFrm window
+
+ """
+ uifilebase = 'uikmdi.rc'
+ viewIcons = ('network', 'email', 'stop', 'back', 'forward', )
+ toolIcons = ('view_icon', 'configure')
+
+ def __init__(self, parent=None):
+ KMdiMainFrm.__init__(self, parent, 'KmdiExample', KMdi.IDEAlMode)
+
+ xmlfile = os.path.join('.', self.uifilebase)
+ self.setXMLFile(os.path.abspath(xmlfile))
+ actions = self.actionCollection()
+ self.openNewAction = KStdAction.openNew(self.newView, actions)
+ self.quitAction = KStdAction.quit(self.close, actions)
+ self.closeAction = KStdAction.close(self.closeActiveChild, actions)
+ self.createGUI(None)
+ self.statusBar()
+ self.resize(400, 300)
+
+ self.tools = {}
+ for idx, ico in enumerate(self.toolIcons):
+ wid = KListBox(self, 'list%s' % idx)
+ self.makeTool(wid, 'Tool %s' % idx, ico)
+ ## smells
+ self.mainToolWidget = maintool = self.tools['Tool 0'][0]
+
+ self.childs = {}
+ for idx, ico in enumerate(self.viewIcons):
+ self.makeView('View %s' % idx, ico, ico)
+
+
+ self.connect(self, sigChildViewActivated, self.activatedMessage)
+ self.connect(self, sigChildViewActivated, self.syncFromChildView)
+ self.connect(maintool, sigBoxSelectionChanged, self.syncFromMainTool)
+ self.syncFromChildView(self.activeWindow())
+
+
+ def syncFromMainTool(self, item):
+ """ activate the view that matches the item text
+
+ """
+ try:
+ self.activateView(self.findWindow(item.text()))
+ except (RuntimeError, ):
+ pass
+
+ def syncFromChildView(self, child):
+ """ sync the main tool to the indicated child
+
+ """
+ maintool = self.mainToolWidget
+ item = maintool.findItem(child.tabCaption())
+ if item:
+ maintool.setSelected(item, True)
+
+ def makeTool(self, widget, caption, icon, percent=50):
+ """ makes a tool from the widget
+
+ """
+ tip = i18n('%s Tool Tip' % caption)
+ dock = KDockWidget.DockLeft
+ maindock = self.getMainDockWidget()
+ widget.setIcon(getIcon(icon))
+ tool = self.addToolWindow(widget, dock, maindock, percent, tip, caption)
+ self.tools[caption] = (widget, tool)
+
+ def makeView(self, label, icon, text):
+ """ makes a child view with a text label and a pixmap label
+
+ """
+ view = KMdiChildView(label, self)
+ self.childs[label] = view
+ view.setIcon(getIcon(icon))
+ layout = QVBoxLayout(view)
+ layout.setAutoAdd(True)
+
+ lbl = i18n('Label for a view with an icon named %s' % text)
+ lbl = QLabel(lbl, view)
+ pxm = QLabel('', view)
+ pxm.setPixmap(getIcon(icon, size=KIcon.SizeLarge))
+
+ self.addWindow(view)
+ self.mainToolWidget.insertItem(label)
+ self.connect(view, sigChildCloseRequest, self.closeChild)
+
+ def removeMainToolItem(self, view):
+ """ remove item from the main list tool that corresponds to the view
+
+ """
+ maintool = self.mainToolWidget
+ maintool.takeItem(maintool.findItem(view.tabCaption(), 0))
+
+ def newView(self):
+ """ make a view when the user invokes the new action
+
+ """
+ self.makeView('View %s' % len(self.childs), 'network', 'A Fresh View')
+ self.syncFromChildView(self.activeWindow())
+
+ def closeActiveChild(self):
+ """ close the current view
+
+ """
+ self.removeMainToolItem(self.activeWindow())
+ self.closeActiveView()
+ self.syncFromChildView(self.activeWindow())
+
+ def closeChild(self, which):
+ """ called to close a view from its tab close button
+
+ """
+ try:
+ caption = which.tabCaption()
+ except (AttributeError, ):
+ ## probably None; bug in kmdi?
+ return
+ self.removeMainToolItem(which)
+ which.close()
+ self.statusBar().message(i18n('%s closed' % caption))
+ self.syncFromChildView(self.activeWindow())
+
+ def activatedMessage(self, view):
+ """ updates the status bar with the caption of the current view
+
+ """
+ try:
+ self.statusBar().message(i18n('%s activated' % view.tabCaption()))
+ except (RuntimeError, ):
+ ## sometimes the status bar or the current object is already gone...
+ pass
+
+
+if __name__ == '__main__':
+ aname = 'PyKDE KMDI Sample'
+ desc = 'A Simple PyKDE KMDI Sample'
+ ver = '1.0'
+ lic = KAboutData.License_GPL
+ author = 'Troy Melhase'
+ authormail = 'troy@gci.net'
+
+ about = KAboutData(aname, aname, ver, desc, lic, '%s (c) 2004' % authormail)
+ about.addAuthor(author, 'hi, mom!', authormail)
+ about.addAuthor ('Jim Bublitz', 'For PyKDE', 'jbublitz@nwinternet.com')
+ KCmdLineArgs.init(sys.argv, about)
+ app = KApplication()
+ mainWindow = KmdiExample()
+ mainWindow.show()
+ app.exec_loop()
diff --git a/examples/uikmdi.rc b/examples/uikmdi.rc
new file mode 100644
index 0000000..a7e2196
--- /dev/null
+++ b/examples/uikmdi.rc
@@ -0,0 +1,11 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="testfoo" version="1">
+<MenuBar>
+
+<!-- <Menu name="custom"><text>C&amp;ustom</text>
+ <Action name="custom_action" />
+ </Menu>
+-->
+
+</MenuBar>
+</kpartgui>
diff --git a/examples/uimodules/uidialogs.py b/examples/uimodules/uidialogs.py
new file mode 100644
index 0000000..0f86072
--- /dev/null
+++ b/examples/uimodules/uidialogs.py
@@ -0,0 +1,232 @@
+from qt import QVBox, QLabel, QLineEdit, QString, QPixmap, QPushButton, QColor, SIGNAL, QButtonGroup,\
+ QRadioButton, Qt, QWidget
+
+from kdecore import KAccel, i18n
+
+from kdeui import KAboutDialog, KAboutKDE, KBugReport, KColorDialog, KDialog, KDialogBase, KFontDialog,\
+ KPasswordDialog, KMessageBox, KLineEditDlg, KKeyDialog, KWizard
+
+# despite what the docs say, there is no enum (in 2.1.1 anyway)
+# that contains these values
+QuestionYesNo = 0
+WarningYesNo = 1
+WarningContinueCancel = 2
+WarningYesNoCancel = 3
+Information = 4
+Sorry = 5
+Error = 6
+
+# Python 2.2.2 supplies these, but they're duplicated here
+# for backward compatibility
+False = 0
+True = 1
+
+class CustomDlg (KDialog):
+ def __init__ (self, parent, name = "custom dlg", modal = False):
+ KDialog.__init__ (self, parent, name, modal)
+
+ x = 20
+ y = 10
+
+ rLbl = QLabel ("r", self)
+ gLbl = QLabel ("g", self)
+ bLbl = QLabel ("b", self)
+ self.rEd = QLineEdit ("64", self)
+ self.gEd = QLineEdit ("64", self)
+ self.bEd = QLineEdit ("64", self)
+ self.dlgBtn = QPushButton ("Set/Get Color", self)
+ self.okBtn = QPushButton ("OK", self)
+ self.canBtn = QPushButton ("Cancel", self)
+
+ rLbl.setGeometry (x, y, 25, 20)
+ gLbl.setGeometry (x + 30, y, 25, 20)
+ bLbl.setGeometry (x + 60, y, 25, 20)
+ y = y + 20
+ self.rEd.setGeometry (x, y, 25, 20)
+ self.gEd.setGeometry (x + 30, y, 25, 20)
+ self.bEd.setGeometry (x + 60, y, 25, 20)
+ y = y + 30
+ self.dlgBtn.setGeometry (x, y, 90, 22)
+ y = y + 30
+ self.okBtn.setGeometry (x, y, 40, 22)
+ self.canBtn.setGeometry (x + 50, y, 40, 22)
+
+ self.connect (self.dlgBtn, SIGNAL ("clicked()"), self.dlgClicked)
+ self.connect (self.okBtn, SIGNAL ("clicked ()"), self.okClicked)
+ self.connect (self.canBtn, SIGNAL ("clicked ()"), self.cancelClicked)
+
+ def dlgClicked (self):
+ # get some (numerical) color values from the original dialog
+ red = int (self.rEd.text ().latin1 ())
+ green = int (self.gEd.text ().latin1 ())
+ blue = int (self.bEd.text ().latin1 ())
+
+ # convert the numbers to a QColor
+ color = QColor (red, green, blue)
+
+ # invoke the dialog (getColor is a 'static' call)
+ # initialize with the colors from above (in color)
+ # color will also hold the new value chosen in the
+ # KColorDialog
+ result = KColorDialog.getColor (color, self)
+
+ # get the numerical color values back
+ red, green, blue = color.rgb ()
+
+ # update the QLineEdits in the original dialog
+ self.rEd.setText (str (red))
+ self.gEd.setText (str (green))
+ self.bEd.setText (str (blue))
+
+ def okClicked (self):
+ self.done (1)
+
+ def cancelClicked (self):
+ self.done (0)
+
+class MessageDlg (KDialog):
+ def __init__ (self, parent, name = "message dlg", modal = False):
+ KDialog.__init__ (self, parent, name, modal)
+
+ buttons = ["QuestionYesNo", "WarningYesNo", "WarningContiueCancel", "WarningYesNoCancel",\
+ "Information", "Sorry", "Error"]
+
+ n = len (buttons)
+
+ grp = QButtonGroup (n, Qt.Vertical, "MessageBoxes", self, "button grp")
+ grp.setGeometry (10, 10, 200, 30*n)
+ for i in range (n):
+ QRadioButton (buttons [i], grp)
+
+ self.connect (grp, SIGNAL ("clicked (int)"), self.launch)
+
+ def launch (self, which):
+ if which == QuestionYesNo:
+ KMessageBox.questionYesNo (self, "This is a questionYesNo message box\nThere is also a list version of this dialog",\
+ "questionYesNo")
+
+ elif which == WarningYesNo:
+ KMessageBox.warningYesNo (self, "This is a warningYesNo message box", "warningYesNo")
+
+ elif which == WarningContinueCancel:
+ KMessageBox.warningContinueCancel (self, "This is a warningContinueCancel message box", "warningContinueCancel");
+
+ elif which == WarningYesNoCancel:
+ KMessageBox.warningYesNoCancel (self, "This is a warningYesNoCancel message box", "warningYesNoCancel")
+
+ elif which == Information:
+ KMessageBox.information (self, "This is an information message box", "Information")
+
+ elif which == Sorry:
+ KMessageBox.sorry (self, "This is a 'sorry' message box", "Sorry")
+
+ elif which == Error:
+ KMessageBox.error (self, "No - this isn't really an error\nIt's an error message box\n", "Error")
+
+
+def dlgKAboutDialog (parent):
+ dlg = KAboutDialog (parent, 'about dialog', False)
+ dlg.setLogo (QPixmap ("pytestimage.png"))
+ dlg.setTitle ("UISampler for PyKDE")
+ dlg.setAuthor ("Jim Bublitz", "jbublitz@nwinternet.com", "http://www.riverbankcomputing.co.uk",\
+ "\n\nPyKDE -- Python bindings\n\tfor KDE")
+ dlg.addContributor ("PyKDE list", "pykde@mats.gmd.de", QString.null, QString.null)
+
+ dlg.show ()
+
+
+def dlgKBugReport (parent):
+ dlg = KBugReport (parent)
+ dlg.exec_loop ()
+
+def dlgKAboutKDE (parent):
+ dlg = KAboutKDE (parent, "about kde", False)
+ dlg.show ()
+
+def dlgKColorDialog (parent):
+ dlg = KColorDialog (parent, "color dlg", False)
+ dlg.show ()
+
+def dlgKDialog (parent):
+ dlg = CustomDlg (parent)
+ dlg.show ()
+
+def dlgKDialogBase (parent):
+ caption = "KDialogBase sample"
+ text_ = "This is a KDialogBase example"
+ dlg = KDialogBase (parent, "sample_dialog", False, caption,\
+ KDialogBase.Ok | KDialogBase.Cancel, KDialogBase.Ok, True )
+
+ page = dlg.makeVBoxMainWidget();
+
+ # making 'page' the parent inserts the widgets in
+ # the VBox created above
+ label = QLabel( caption, page, "caption" );
+
+ lineedit = QLineEdit(text_, page, "lineedit" );
+ lineedit.setMinimumWidth(dlg.fontMetrics().maxWidth()*20);
+
+ # This tests some handwritten code in KDialogBase
+ label0 = QLabel ("Border widths", page)
+ a, b, c, d = dlg.getBorderWidths ()
+ labelA = QLabel ("Upper Left X: " + str (a), page)
+ labelB = QLabel ("Upper Left Y: " + str (b), page)
+ labelC = QLabel ("Lower Right X: " + str (c), page)
+ labelD = QLabel ("Lower Right Y: " + str (d), page)
+
+ dlg.show ()
+
+def dlgKFontDialog (parent):
+ dlg = KFontDialog (parent, "font dlg", False, False)
+ dlg.show ()
+
+def dlgKKeyDialog (parent):
+ # This really doesn't do anything except pop up the dlg
+ keys = KAccel (parent)
+ keys.insertItem( i18n( "Zoom in" ), "Zoom in", "+" );
+ keys.readSettings();
+ KKeyDialog.configureKeys (keys)
+
+def dlgKLineEditDlg (parent):
+ result, ok = KLineEditDlg.getText ("Enter text", "<Your input here>", parent)
+ print "result", result
+ print "ok", ok
+
+ # pop up another dlg to show what happened in the KLineEditDlg
+ if ok:
+ result = result.latin1 ()
+ KMessageBox.information (parent, "OK was pressed\nText: " + result, "KLineEditDlg result")
+ else:
+ result = ""
+ KMessageBox.information (parent, "Cancel pressed\nText: " + result, "KLineEditDlg result")
+
+def dlgKMessageBox (parent):
+ dlg = MessageDlg (parent)
+ dlg.show ()
+
+def dlgKPasswordDialog (parent):
+ dlg = KPasswordDialog (KPasswordDialog.Password, "Enter password (just a test)")
+ dlg.exec_loop ()
+
+def dlgKWizard (parent):
+ wiz = KWizard (parent)
+
+ page1 = QWidget (wiz)
+ p1Lbl = QLabel ("This is page 1", page1)
+ p1Lbl.setGeometry (20, 20, 100, 20)
+ page2 = QWidget (wiz)
+ p2Lbl = QLabel ("This is page 2", page2)
+ p2Lbl.setGeometry (50, 20, 100, 20)
+ page3 = QWidget (wiz)
+ p3Lbl = QLabel ("This is page 3", page3)
+ p3Lbl.setGeometry (80, 20, 100, 20)
+
+ wiz.addPage (page1, "Page 1")
+ wiz.addPage (page2, "Page 2")
+ wiz.addPage (page3, "Page 3")
+ wiz.show ()
+
+if __name__ == "__main__":
+ print
+ print "Please run uisampler.py"
+ print \ No newline at end of file
diff --git a/examples/uimodules/uimenus.py b/examples/uimodules/uimenus.py
new file mode 100644
index 0000000..19173b3
--- /dev/null
+++ b/examples/uimodules/uimenus.py
@@ -0,0 +1,108 @@
+import os
+
+from qt import QLabel
+
+from kdecore import KApplication
+
+class PageLaunch:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ launchLbl = QLabel ("Launching application ... please wait\n\nClose launched application to continue", self.page)
+ launchLbl.setGeometry (x, y, 300, 80)
+ launchLbl.show ()
+
+ self.page.show ()
+
+ KApplication.kApplication ().processEvents ()
+
+
+class PageNotImpl:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ niLbl = QLabel ("Nothing is currently implemented for this widget", self.page)
+ niLbl.setGeometry (x, y, 300, 20)
+ niLbl.show ()
+
+
+def menuKAccelGen (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def menuKAccelMenu (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def menuKAction (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python menudemo.py")
+
+def menuKActionMenu (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python menudemo.py")
+
+def menuKActionSeparator (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python menudemo.py")
+
+def menuKContextMenuManager (parent):
+ pass
+
+def menuKDCOPActionProxy (parent):
+ pass
+
+def menuKHelpMenu (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python menudemo.py")
+
+def menuKMenuBar (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python menudemo.py")
+
+def menuKPanelApplet (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def menuKPanelExtension (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def menuKPanelMenu (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def menuKPopupFrame (parent):
+ pass
+
+def menuKPopupMenu (parent):
+ pass
+
+def menuKPopupTitle (parent):
+ pass
+
+def menuKStatusBar (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python menudemo.py")
+
+def menuKStatusBarLabel (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python menudemo.py")
+
+def menuKStdAction (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python menudemo.py")
+
+def menuKToolBar (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python menudemo.py")
+
+def menuKWindowListMenu (parent):
+ pass
+
+
+if __name__ == "__main__":
+ print
+ print "Please run uisampler.py"
+ print \ No newline at end of file
diff --git a/examples/uimodules/uimisc.py b/examples/uimodules/uimisc.py
new file mode 100644
index 0000000..31f7c18
--- /dev/null
+++ b/examples/uimodules/uimisc.py
@@ -0,0 +1,239 @@
+import os, time
+
+from qt import QImage, QLabel, QPixmap, QPushButton, SIGNAL, QColor, QValidator
+
+from kdeui import KMessageBox, KDateValidator, KFloatValidator, KIntValidator, KLineEdit, KLed
+
+
+
+class Page3:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 15
+
+ green = QColor (0, 255, 0)
+ yellow = QColor (255, 255, 0)
+ red = QColor (255, 0, 0)
+
+ ivLbl = QLabel ("KIntValidator", self.page)
+ ivLbl.setGeometry (x, y, 100, 20)
+ ivLbl.show ()
+
+ self.iv = KLineEdit (self.page)
+ self.iv.setGeometry (x, y + 20, 100, 20)
+ self.iv.show ()
+ self.page.connect (self.iv, SIGNAL("textChanged (const QString &)"), self.ivChanged)
+
+ self.ivVal = KIntValidator (self.page)
+ self.ivVal.setRange (20, 50)
+
+ ivRngLbl = QLabel ("Range is 20 - 50", self.page)
+ ivRngLbl.setGeometry (x, y + 45, 100, 20)
+ ivRngLbl.show ()
+
+ ivAccLbl = QLabel ("Acceptable", self.page)
+ ivAccLbl.setGeometry (x + 125, y + 45, 85, 20)
+ ivAccLbl.show ()
+ ivInterLbl = QLabel ("Intermediate", self.page)
+ ivInterLbl.setGeometry (x + 125, y + 20, 85, 20)
+ ivInterLbl.show ()
+ ivInvalLbl = QLabel ("Invalid", self.page)
+ ivInvalLbl.setGeometry (x + 125, y - 5, 85, 20)
+ ivInvalLbl.show ()
+ self.ivInvalLed = KLed (red, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
+ self.ivInvalLed.setGeometry (x + 215, y - 5, 18, 18)
+ self.ivInvalLed.show ()
+ self.ivInterLed = KLed (yellow, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
+ self.ivInterLed.setGeometry (x + 215, y + 20, 18, 18)
+ self.ivInterLed.show ()
+ self.ivAccLed = KLed (green, KLed.On, KLed.Sunken, KLed.Circular,self.page)
+ self.ivAccLed.setGeometry (x + 215, y + 45, 18, 18)
+ self.ivAccLed.show ()
+
+ y = y + 100
+
+ fvLbl = QLabel ("KFloatValidator", self.page)
+ fvLbl.setGeometry (x, y, 100, 20)
+ fvLbl.show ()
+
+ self.fv = KLineEdit (self.page)
+ self.fv.setGeometry (x, y + 20, 100, 20)
+ self.fv.show ()
+ self.page.connect (self.fv, SIGNAL("textChanged (const QString &)"), self.fvChanged)
+
+ self.fvVal = KFloatValidator (self.page)
+ self.fvVal.setRange (10.0, 40.0)
+
+ fvRngLbl = QLabel ("Range is 10.0 - 40.0", self.page)
+ fvRngLbl.setGeometry (x, y + 45, 100, 20)
+ fvRngLbl.show ()
+
+ fvAccLbl = QLabel ("Acceptable", self.page)
+ fvAccLbl.setGeometry (x + 125, y + 45, 85, 20)
+ fvAccLbl.show ()
+ fvInterLbl = QLabel ("Intermediate", self.page)
+ fvInterLbl.setGeometry (x + 125, y + 20, 95, 20)
+ fvInterLbl.show ()
+ fvInvalLbl = QLabel ("Invalid", self.page)
+ fvInvalLbl.setGeometry (x + 125, y - 5, 85, 20)
+ fvInvalLbl.show ()
+ self.fvInvalLed = KLed (red, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
+ self.fvInvalLed.setGeometry (x + 215, y - 5, 18, 18)
+ self.fvInvalLed.show ()
+ self.fvInterLed = KLed (yellow, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
+ self.fvInterLed.setGeometry (x + 215, y + 20, 18, 18)
+ self.fvInterLed.show ()
+ self.fvAccLed = KLed (green, KLed.On, KLed.Sunken, KLed.Circular,self.page)
+ self.fvAccLed.setGeometry (x + 215, y + 45, 18, 18)
+ self.fvAccLed.show ()
+
+ y = y + 100
+
+ dvLbl = QLabel ("KDateValidator", self.page)
+ dvLbl.setGeometry (x, y, 100, 20)
+ dvLbl.show ()
+
+ self.dv = KLineEdit (self.page)
+ self.dv.setGeometry (x, y + 20, 100, 20)
+ self.dv.show ()
+# self.page.connect (self.dv, SIGNAL("textChanged (const QString &)"), self.dvChanged)
+
+ self.dvVal = KDateValidator (self.page)
+# self.dvVal.setRange (10.0, 40.0)
+
+# dvRngLbl = QLabel ("Range is 10.0 - 40.0", self.page)
+# dvRngLbl.setGeometry (x, y + 45, 100, 20)
+# dvRngLbl.show ()
+
+ dvBtn = QPushButton ("Validate", self.page)
+ dvBtn.setGeometry (x, y + 45, 60, 22)
+ dvBtn.show ()
+ self.page.connect (dvBtn, SIGNAL ("clicked ()"), self.dvChanged)
+
+ dvNoteLbl = QLabel ("Format is locale dependent\nShort date only\nTry DD-MM-YY", self.page)
+ dvNoteLbl.setGeometry (x, y + 70, 150, 60)
+ dvNoteLbl.show ()
+
+ dvAccLbl = QLabel ("Acceptable", self.page)
+ dvAccLbl.setGeometry (x + 125, y + 45, 85, 20)
+ dvAccLbl.show ()
+ dvInterLbl = QLabel ("Intermediate", self.page)
+ dvInterLbl.setGeometry (x + 125, y + 20, 85, 20)
+ dvInterLbl.show ()
+ dvInvalLbl = QLabel ("Invalid", self.page)
+ dvInvalLbl.setGeometry (x + 125, y - 5, 85, 20)
+ dvInvalLbl.show ()
+ self.dvInvalLed = KLed (red, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
+ self.dvInvalLed.setGeometry (x + 215, y - 5, 18, 18)
+ self.dvInvalLed.show ()
+ self.dvInterLed = KLed (yellow, KLed.Off, KLed.Sunken, KLed.Circular,self.page)
+ self.dvInterLed.setGeometry (x + 215, y + 20, 18, 18)
+ self.dvInterLed.show ()
+ self.dvAccLed = KLed (green, KLed.On, KLed.Sunken, KLed.Circular,self.page)
+ self.dvAccLed.setGeometry (x + 215, y + 45, 18, 18)
+ self.dvAccLed.show ()
+
+ def ivChanged (self):
+ self.ivInvalLed.off ()
+ self.ivInterLed.off ()
+ self.ivAccLed.off ()
+
+ state, i = self.ivVal.validate (self.iv.text ())
+
+ if state == QValidator.Acceptable:
+ self.ivAccLed.on ()
+ elif state == QValidator.Intermediate:
+ self.ivInterLed.on ()
+ else:
+ self.ivInvalLed.on ()
+
+ def fvChanged (self):
+ self.fvInvalLed.off ()
+ self.fvInterLed.off ()
+ self.fvAccLed.off ()
+
+ state, i = self.fvVal.validate (self.fv.text ())
+
+ if state == QValidator.Acceptable:
+ self.fvAccLed.on ()
+ elif state == QValidator.Intermediate:
+ self.fvInterLed.on ()
+ else:
+ self.fvInvalLed.on ()
+
+ def dvChanged (self):
+ self.dvInvalLed.off ()
+ self.dvInterLed.off ()
+ self.dvAccLed.off ()
+
+ state, i = self.dvVal.validate (self.dv.text ())
+
+ if state == QValidator.Acceptable:
+ self.dvAccLed.on ()
+ elif state == QValidator.Intermediate:
+ self.dvInterLed.on ()
+ else:
+ self.dvInvalLed.on ()
+
+class PageNotImpl:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ niLbl = QLabel ("Nothing is currently implemented for this widget", self.page)
+ niLbl.setGeometry (x, y, 300, 20)
+ niLbl.show ()
+
+def miscKAlphaPainter (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscKCModule (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscKColor (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscKColorDrag (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscKCommand (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscKCommandHistory (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscKDockWindow (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscKFloatValidator (parent):
+ parent.currentPageObj = Page3 (parent)
+
+def miscKDateValidator (parent):
+ parent.currentPageObj = Page3 (parent)
+
+def miscKIntValidator (parent):
+ parent.currentPageObj = Page3 (parent)
+
+def miscKPixmapIO (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscKSharedPixmap (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscKSystemTray (parent):
+ KMessageBox.information (parent, "See the systray.py example in the templates/ subdirectories")
+
+def miscKThemeBase (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def miscQXEmbed (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+if __name__ == "__main__":
+ print
+ print "Please run uisampler.py"
+ print \ No newline at end of file
diff --git a/examples/uimodules/uiwidgets.py b/examples/uimodules/uiwidgets.py
new file mode 100644
index 0000000..b12df10
--- /dev/null
+++ b/examples/uimodules/uiwidgets.py
@@ -0,0 +1,754 @@
+import time, sys
+
+from qt import QLabel, QFrame, QColor, QPushButton, SIGNAL, QButtonGroup, QRadioButton, Qt, QString, QChar,\
+ QWidget, QTimer
+
+from kdecore import KApplication
+from kdeui import KEdit, KComboBox, KColorCombo, KEditListBox, KListBox, KLineEdit, KRestrictedLine,\
+ KSqueezedTextLabel, KFontChooser, KButtonBox, KColorButton, KColorCells,\
+ KColorPatch, KDualColorButton,\
+ KRootPermsIcon, KWritePermsIcon, KCharSelect, KDialog, KLed, KRootPixmap,\
+ KTabCtl, KProgress, KDatePicker, KDateTable, KGradientSelector, KHSSelector,\
+ KIntNumInput, KDoubleNumInput, KPasswordEdit, KURLLabel, KPaletteTable,\
+ KSeparator
+
+if sys.version [:6] < "2.2.2":
+ False = 0
+ True = 1
+
+class Page1:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ editLbl = QLabel ("KEdit", self.page)
+ editLbl.setGeometry (x, y, 50, 20)
+ editLbl.show ()
+
+ textList = ["Now is the winter of our discontent",\
+ "made glorious summer by this sun of York;",\
+ "and all the clouds that lour'd upon our house",\
+ "in the deep bosom of the ocean buried."]
+
+ parent.edit = KEdit (self.page)
+ parent.edit.setGeometry (x, y + 20, 300, 100)
+ for line in textList:
+ parent.edit.insertLine (line)
+ parent.edit.show ()
+
+ y = y + 125
+ searchBtn = QPushButton ("Search", self.page)
+ replaceBtn = QPushButton ("Replace", self.page)
+ gotoBtn = QPushButton ("GoTo Line", self.page)
+
+ searchBtn.setGeometry (x, y, 60, 22)
+ replaceBtn.setGeometry (x + 90, y, 60, 22)
+ gotoBtn.setGeometry (x + 180, y, 60, 22)
+
+ self.page.connect (searchBtn, SIGNAL ("clicked ()"), parent.edit.search)
+ self.page.connect (replaceBtn, SIGNAL ("clicked ()"), parent.edit.replace)
+ self.page.connect (gotoBtn, SIGNAL ("clicked ()"), parent.edit.doGotoLine)
+
+ searchBtn.show ()
+ replaceBtn.show ()
+ gotoBtn.show ()
+
+ y = y + 35
+
+ lineeditLbl = QLabel ("KLineEdit", self.page)
+ lineeditLbl.setGeometry (x, y, 70, 20)
+ lineeditLbl.show ()
+
+ lineedit = KLineEdit (self.page)
+ lineedit.setGeometry (x, y + 20, 100, 20)
+ lineedit.show ()
+
+ intLbl = QLabel ("KIntNumInput", self.page)
+ intLbl.setGeometry (x + 195, y + 35, 95, 20)
+ intLbl.show ()
+
+ intNum = KIntNumInput (5, self.page)
+ intNum.setGeometry (x + 195, y + 55, 175, 50)
+# intNum.setSuffix (" GB")
+# intNum.setPrefix ("hdc ")
+ intNum.setLabel ("Capacity")
+ intNum.setRange (0, 10, 1, True)
+ intNum.show ()
+
+ y = y + 50
+
+ dblLbl = QLabel ("KDoubleNumInput", self.page)
+ dblLbl.setGeometry (x + 195, y + 80, 115, 20)
+ dblLbl.show ()
+
+ dblNum = KDoubleNumInput (2.5, self.page)
+ dblNum.setGeometry (x + 195, y + 100, 175, 50)
+ dblNum.setLabel ("Variable")
+ dblNum.setRange (0.0, 10.0, 0.5, True)
+ dblNum.show ()
+
+ restricteditLbl = QLabel ("KRestrictedLine", self.page)
+ restricteditLbl.setGeometry (x, y, 95, 20)
+ restricteditLbl.show ()
+
+ self.restrictlineedit = KRestrictedLine (self.page)
+ self.restrictlineedit.setGeometry (x, y + 20, 100, 20)
+ self.restrictlineedit.show ()
+
+ buttons = ["Numbers Only", "Upper Case Only", "Lower Case Only"]
+
+ n = len (buttons)
+
+ self.validLbl = QLabel ("", self.page)
+ self.validLbl.setGeometry (x, y + 50, 250, 20)
+ self.validLbl.show ()
+
+ grp = QButtonGroup (n, Qt.Vertical, "Select valid chars", self.page, "button grp")
+ grp.setGeometry (x, y + 75, 150, 5+30*n)
+ for i in range (n):
+ QRadioButton (buttons [i], grp)
+
+ grp.connect (grp, SIGNAL ("clicked (int)"), self.restrict)
+
+ grp.find (0).setChecked (True)
+ self.restrict (0)
+
+ grp.show ()
+
+ self.page.show ()
+ kapp = KApplication.kApplication ()
+ kapp.processEvents ()
+
+ y = y + 195
+ sqzLbl = QLabel ("This text is too long to fit in the label below", self.page)
+ sqzLbl.setGeometry (x, y, 350, 20)
+ sqzLbl.show ()
+
+ sqzLbl1 = QLabel ("KSqueezedTxtLabel:", self.page)
+ sqzLbl1.setGeometry (x, y + 20, 120, 20)
+ sqzLbl1.show ()
+
+ squeeze = KSqueezedTextLabel ("This text is too long to fit in the label below", self.page)
+ squeeze.setGeometry (x + 125, y + 20, 125, 20)
+ squeeze.setBackgroundMode (QWidget.PaletteBase)
+ squeeze.show ()
+
+ def restrict (self, which):
+ r = {0: "0123456789", 1: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 2: "abcdefghijklmnopqrstuvwxyz"}
+ self.restrictlineedit.setValidChars (r [which])
+ self.validLbl.setText ("Valid: " + self.restrictlineedit.validChars ().latin1 ())
+
+
+class Page2:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x1 = 10
+ y1 = 10
+ x2 = 240
+ y2 = 100
+
+
+
+ cbLbl = QLabel ("KComboBox", self.page)
+ cbLbl.setGeometry (x1, y1, 75, 20)
+ cbLbl.show ()
+
+ combo = KComboBox (self.page)
+ combo.insertStrList (["One", "Two", "Three"])
+ combo.setGeometry (x1, y1 + 20, 100, 25)
+ combo.show ()
+
+ ccbLbl = QLabel ("KColorCombo", self.page)
+ ccbLbl.setGeometry (x2, y1, 100, 20)
+ ccbLbl.show ()
+
+ colorCombo = KColorCombo (self.page)
+ colorCombo.setGeometry (x2, y1 + 20, 100, 25)
+ colorCombo.show ()
+
+ editListBox = KEditListBox ("KEditListBox", self.page)
+ editListBox.setGeometry (x1, y2, 220, 175)
+ editListBox.insertStrList (["One", "Two", "Three"])
+ editListBox.show ()
+
+ lbLbl = QLabel ("KListBox", self.page)
+ lbLbl.setGeometry (x2, y2, 100, 20)
+ lbLbl.show ()
+
+ listBox = KListBox (self.page)
+ listBox.setGeometry (x2, y2 + 20, 100, 100)
+ listBox.insertStrList (["One", "Two", "Three"])
+ listBox.show ()
+
+class Page3:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ fontLbl = QLabel ("KFontChooser", self.page)
+ fontLbl.setGeometry (x, y, 95, 20)
+ fontLbl.show ()
+
+ fontChoose = KFontChooser (self.page)
+ fontChoose.setGeometry (x, y + 20, 375, 300)
+ fontChoose.show ()
+
+ y = y + 330
+
+class Page4:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ cbLbl = QLabel ("KColorButton", self.page)
+ cbLbl.setGeometry (x, y, 75, 20)
+ cbLbl.show ()
+
+ cb = KColorButton (self.page)
+ cb.setColor (QColor (255, 0, 0))
+ cb.setGeometry (x, y + 20, 30, 30)
+ cb.show ()
+
+ ccbLbl = QLabel ("KColorCombo", self.page)
+ ccbLbl.setGeometry (x + 150, y, 100, 20)
+ ccbLbl.show ()
+
+ colorCombo = KColorCombo (self.page)
+ colorCombo.setGeometry (x + 150, y + 20, 100, 25)
+ colorCombo.show ()
+
+ y = y + 60
+
+ cpLbl = QLabel ("KColorPatch", self.page)
+ cpLbl.setGeometry (x, y, 75, 20)
+ cpLbl.show ()
+
+ cp = KColorPatch (self.page)
+ cp.setColor (QColor (255, 0, 0))
+ cp.setGeometry (x, y + 20, 20, 20)
+ cp.show ()
+
+ x = x + 150
+
+ ccLbl = QLabel ("KColorCells", self.page)
+ ccLbl.setGeometry (x, y, 75, 20)
+ ccLbl.show ()
+
+ cc = KColorCells (self.page, 1, 5)
+ cc.setColor (0, QColor (0, 0, 0))
+ cc.setColor (1, QColor (255, 0, 0))
+ cc.setColor (2, QColor (0, 255, 0))
+ cc.setColor (3, QColor (0, 0, 255))
+ cc.setColor (4, QColor (255, 255, 255))
+ cc.setGeometry (x, y + 20, 100, 20)
+ cc.show ()
+
+ x = 10
+ y = y + 50
+
+ dcLbl = QLabel ("KDualColorButton", self.page)
+ dcLbl.setGeometry (x, y, 105, 20)
+ dcLbl.show ()
+
+ dc = KDualColorButton (QColor (255, 0, 0), QColor (0, 0, 0), self.page)
+ dc.setGeometry (x, y + 20, 40, 40)
+ dc.show ()
+
+ gsLbl = QLabel ("KGradientSelector", self.page)
+ gsLbl.setGeometry (x + 80, y + 30, 110, 20)
+ gsLbl.show ()
+
+ gs = KGradientSelector (self.page)
+ gs.setGeometry (x + 80, y + 50, 250, 20)
+ gs.setColors (QColor (255, 0, 0), QColor (255, 255, 0))
+ gs.show ()
+
+ y = y + 80
+
+ hsLbl = QLabel ("KHSSelector", self.page)
+ hsLbl.setGeometry (x, y, 95, 20)
+ hsLbl.show ()
+
+ hs = KHSSelector (self.page)
+ hs.setGeometry (x, y + 20, 350, 80)
+ hs.show ()
+
+ y = y + 110
+
+ ptLbl = QLabel ("KPaletteTable", self.page)
+ ptLbl.setGeometry (x, y, 95, 20)
+ ptLbl.show ()
+
+ pt = KPaletteTable (self.page, 340, 24)
+ pt.setPalette ("Royal")
+ pt.setGeometry (x, y + 20, 340, 40)
+ pt.show ()
+
+class Page5:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ rpLbl = QLabel ("KRootPermsIcon", self.page)
+ rpLbl.setGeometry (x, y, 95, 20)
+ rpLbl.show ()
+
+ rp = KRootPermsIcon (self.page)
+ rp.setGeometry (x, y + 20, 32, 32)
+ rp.show ()
+
+ wpLbl = QLabel ("KWritePermsIcon", self.page)
+ wpLbl.setGeometry (x + 125, y, 95, 20)
+ wpLbl.show ()
+
+ wp = KWritePermsIcon ("/usr/bin/gcc", self.page)
+ wp.setGeometry (x + 125, y + 20, 32, 32)
+ wp.show ()
+
+ y = y + 75
+
+ pw1Lbl = QLabel ("KPasswordEdit - echo *", self.page)
+ pw1Lbl.setGeometry (x, y, 150, 20)
+ pw1Lbl.show ()
+
+ pw1 = KPasswordEdit (self.page, "", KPasswordEdit.OneStar)
+ pw1.setGeometry (x, y + 20, 100, 20)
+ pw1.show ()
+
+ y = y + 50
+
+ pw2Lbl = QLabel ("KPasswordEdit - echo ***", self.page)
+ pw2Lbl.setGeometry (x, y, 150, 20)
+ pw2Lbl.show ()
+
+ pw2 = KPasswordEdit (self.page, "", KPasswordEdit.ThreeStars)
+ pw2.setGeometry (x, y + 20, 100, 20)
+ pw2.show ()
+
+ y = y + 50
+
+ pw3Lbl = QLabel ("KPasswordEdit - no echo", self.page)
+ pw3Lbl.setGeometry (x, y, 150, 20)
+ pw3Lbl.show ()
+
+ pw3 = KPasswordEdit (self.page, "", KPasswordEdit.NoEcho)
+ pw3.setGeometry (x, y + 20, 100, 20)
+ pw3.show ()
+
+ y = y + 50
+
+ urlLbl = QLabel ("KURLLabel", self.page)
+ urlLbl.setGeometry (x, y, 100, 20)
+ urlLbl.show ()
+
+ url = KURLLabel ("http://riverbankcomputing.co.uk", "PyKDE", self.page)
+ url.setGeometry (x, y + 20, 100, 20)
+ url.setUseTips (True)
+ url.setTipText ("http://riverbankcomputing.co.uk")
+ url.show ()
+
+ x = 70
+ y = y + 50
+
+ bbLbl = QLabel ("KButtonBox", self.page)
+ bbLbl.setGeometry (x, y, 75, 20)
+ bbLbl.show ()
+
+ bbox = KButtonBox (self.page, Qt.Horizontal)
+ bbox.setGeometry (x, y + 20, 300, 22)
+ bbox.addButton ("Button 1")
+ bbox.addButton ("Button 2")
+ bbox.addButton ("Button 3")
+ bbox.show ()
+
+ y = y + 50
+
+# dbLbl = QLabel ("KDirectionButton", self.page)
+# dbLbl.setGeometry (x, y, 95, 20)
+# dbLbl.show ()
+
+# dbUp = KDirectionButton (Qt.UpArrow, self.page)
+# dbDown = KDirectionButton (Qt.DownArrow, self.page)
+# dbRight = KDirectionButton (Qt.RightArrow, self.page)
+# dbLeft = KDirectionButton (Qt.LeftArrow, self.page)
+
+# dbUp.setGeometry (x, y + 20, 22, 22)
+# dbDown.setGeometry (x + 30, y + 20, 22, 22)
+# dbRight.setGeometry (x + 60, y + 20, 22, 22)
+# dbLeft.setGeometry (x + 90, y + 20, 22, 22)
+
+# dbUp.show ()
+# dbDown.show ()
+# dbRight.show ()
+# dbLeft.show ()
+
+ x = x + 150
+
+# kbLbl = QLabel ("KKeyButton", self.page)
+# kbLbl.setGeometry (x, y, 95, 20)
+# kbLbl.show ()
+
+# kb = KKeyButton (self.page)
+# kb.setText ("Enter")
+# kb.setGeometry (x, y + 20, 50, 32)
+# kb.show ()
+
+ x = 70
+ y = y + 50
+
+# tbLbl = QLabel ("KTabButton", self.page)
+# tbLbl.setGeometry (x, y, 95, 20)
+# tbLbl.show ()
+
+# tbUp = KTabButton (Qt.UpArrow, self.page)
+# tbDown = KTabButton (Qt.DownArrow, self.page)
+# tbRight = KTabButton (Qt.RightArrow, self.page)
+# tbLeft = KTabButton (Qt.LeftArrow, self.page)
+
+# tbUp.setGeometry (x, y + 20, 22, 25)
+# tbDown.setGeometry (x + 30, y + 20, 22, 25)
+# tbRight.setGeometry (x + 60, y + 20, 22, 25)
+# tbLeft.setGeometry (x + 90, y + 20, 22, 25)
+
+# tbUp.show ()
+# tbDown.show ()
+# tbRight.show ()
+# tbLeft.show ()
+
+class Page6:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 20
+ y = 10
+
+ red = QColor (255, 0, 0)
+ green = QColor (0, 255, 0)
+ yellow = QColor (255, 255, 0)
+ blue = QColor (0, 0, 255)
+
+ ledcolor = [red, green, yellow, blue]
+ ledshape = [KLed.Rectangular, KLed.Circular]
+ ledlook = [KLed.Flat, KLed.Raised, KLed.Sunken]
+ ledsize = [10, 18, 25]
+ self.ledlist = []
+
+ for look in ledlook:
+ for color in ledcolor:
+ for shape in ledshape:
+ for size in ledsize:
+ led = KLed(color, KLed.On, look, shape,self.page)
+ led.setGeometry (x, y, size, size)
+ self.ledlist.append (led)
+ led.show ()
+ x = x + 50
+ x = x + 50
+ x = 20
+ y = y + 30
+ y = y + 10
+
+ toggle = QPushButton ("Toggle", self.page)
+ toggle.setGeometry (150, 400, 60, 22)
+ toggle.show ()
+
+ self.page.connect (toggle, SIGNAL ("clicked ()"), self.toggleClicked)
+
+ self.page.show ()
+
+
+ def toggleClicked (self):
+ for led in self.ledlist:
+ led.toggle ()
+
+class Page7:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ tabLbl = QLabel ("KTabCtl", self.page)
+ tabLbl.setGeometry (x, y, 95, 20)
+ tabLbl.show ()
+
+ tab = KTabCtl (self.page)
+ tab.setGeometry (x, y + 20, 300, 100)
+
+ page1 = QWidget (tab)
+ p1Lbl = QLabel ("This is page 1", page1)
+ p1Lbl.setGeometry (20, 20, 100, 20)
+ page2 = QWidget (tab)
+ p2Lbl = QLabel ("This is page 2", page2)
+ p2Lbl.setGeometry (50, 20, 100, 20)
+ page3 = QWidget (tab)
+ p3Lbl = QLabel ("This is page 3", page3)
+ p3Lbl.setGeometry (20, 50, 100, 20)
+
+ tab.addTab (page1, "Tab 1")
+ tab.addTab (page2, "Tab 2")
+ tab.addTab (page3, "Tab 3")
+ tab.show ()
+
+ x = 10
+ y = 150
+
+ progLbl = QLabel ("KProgress", self.page)
+ progLbl.setGeometry (x, y + 50, 95, 20)
+ progLbl.show ()
+
+ self.p1 = KProgress (self.page)
+ self.p2 = KProgress (15, self.page)
+ self.p1.setRange (0, 25)
+ self.p2.setRange (0, 25)
+
+ self.p1.setGeometry (x, y + 80, 125, 20)
+ self.p2.setGeometry (x, y + 120, 125, 20)
+
+ self.p2.setPercentageVisible (0)
+
+ self.p1.show ()
+ self.p2.show ()
+
+ self.total = 0
+
+ y = y + 150
+ sepLbl = QLabel ("KSeparator", self.page)
+ sepLbl.setGeometry (x, y, 95, 20)
+ sepLbl.show ()
+
+ sep = KSeparator (QFrame.HLine, self.page)
+ sep.setGeometry (x, y + 20, 75, 10)
+ sep.show ()
+
+
+ self.page.show ()
+
+ self.add1 (self)
+
+ def add1 (self, junk = 0):
+ self.total = self.total + 1
+ self.p1.advance (1)
+ self.p2.advance (1)
+
+ if self.total < 26:
+ QTimer.singleShot (100, self.add1)
+
+
+
+class Page8:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 40
+ y = 10
+
+ dpLbl = QLabel ("KDatePicker", self.page)
+ dpLbl.setGeometry (x, y, 95, 20)
+ dpLbl.show ()
+
+ dp = KDatePicker (self.page)
+ dp.setGeometry (x, y + 20, 300, 170)
+ dp.show ()
+
+ y = y + 210
+
+ dtLbl = QLabel ("KDateTable", self.page)
+ dtLbl.setGeometry (x, y, 95, 20)
+ dtLbl.show ()
+
+ dt = KDateTable (self.page)
+ dt.setGeometry (x, y + 20, 300, 130)
+ dt.show ()
+
+class PageThisApp:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ taLbl = QLabel ("This application uses KMainWindow as its top level widget\n and KListView in the"\
+ " left-hand panel", self.page)
+ taLbl.setGeometry (x, y, 300, 60)
+ taLbl.show ()
+
+class PageNotImpl:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ niLbl = QLabel ("Nothing is currently implemented for this widget", self.page)
+ niLbl.setGeometry (x, y, 300, 20)
+ niLbl.show ()
+
+class CSDlg (KDialog):
+ def __init__ (self, parent, name = "char select dlg", modal = False):
+ KDialog.__init__ (self, parent, name, modal)
+
+ self.setGeometry (150, 50, 700, 320)
+ x = 10
+ y = 10
+
+ csLbl = QLabel ("KCharSelect", self)
+ csLbl.setGeometry (x, y, 95, 20)
+ csLbl.show ()
+
+ cs = KCharSelect (self, "chselect", QString.null, QChar (' '), 0)
+ cs.setGeometry (x, y + 20, 680, 250)
+ cs.show ()
+
+ closeBtn = QPushButton ("Close", self)
+ closeBtn.setGeometry ( 610, 280, 60, 22)
+ closeBtn.show ()
+
+ self.connect (closeBtn, SIGNAL ("clicked ()"), self.closeClicked)
+
+ def closeClicked (self):
+ self.done (1)
+
+def widKAnimWidget (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def widKAuthIcon (parent):
+ parent.currentPageObj = Page5 (parent)
+
+def widKButtonBox (parent):
+ parent.currentPageObj = Page5 (parent)
+
+def widKCharSelect (parent):
+ dlg = CSDlg (parent)
+ dlg.show ()
+
+def widKColorButton (parent):
+ parent.currentPageObj = Page4 (parent)
+
+def widKColorCells (parent):
+ parent.currentPageObj = Page4 (parent)
+
+def widKColorCombo (parent):
+ parent.currentPageObj = Page2 (parent)
+
+def widKColorPatch (parent):
+ parent.currentPageObj = Page4 (parent)
+
+def widKComboBox (parent):
+ parent.currentPageObj = Page2 (parent)
+
+def widKCompletionBox (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def widKContainerLayout (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def widKCursor (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def widKDatePicker (parent):
+ parent.currentPageObj = Page8 (parent)
+
+def widKDateTable (parent):
+ parent.currentPageObj = Page8 (parent)
+
+def widKDirectionButton (parent):
+ parent.currentPageObj = Page5 (parent)
+
+def widKDualColorButton (parent):
+ parent.currentPageObj = Page4 (parent)
+
+def widKEdit (parent):
+ parent.currentPageObj = Page1 (parent)
+
+def widKEditListBox (parent):
+ parent.currentPageObj = Page2 (parent)
+
+def widKFontChooser (parent):
+ parent.currentPageObj = Page3 (parent)
+
+def widKHSSelector (parent):
+ parent.currentPageObj = Page4 (parent)
+
+def widKIconView (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def widKJanusWidget (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+#def widKKeyButton (parent):
+# parent.currentPageObj = Page5 (parent)
+
+def widKKeyChooser (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def widKLed (parent):
+ parent.currentPageObj = Page6 (parent)
+
+def widKLineEdit (parent):
+ parent.currentPageObj = Page1 (parent)
+
+def widKListBox (parent):
+ parent.currentPageObj = Page2 (parent)
+
+def widKListView (parent):
+ parent.currentPageObj = PageThisApp (parent)
+
+def widKNumInput (parent):
+ parent.currentPageObj = Page1 (parent)
+
+def widKPaletteTable (parent):
+ parent.currentPageObj = Page4 (parent)
+
+def widKPasswordEdit (parent):
+ parent.currentPageObj = Page5 (parent)
+
+def widKProgress (parent):
+ parent.currentPageObj = Page7 (parent)
+
+def widKRootPixmap (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def widKMainWindow (parent):
+ parent.currentPageObj = PageThisApp (parent)
+
+def widKRestrictedLine (parent):
+ parent.currentPageObj = Page1 (parent)
+
+def widKRuler (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def widKSelector (parent):
+ parent.currentPageObj = Page4 (parent)
+
+def widKSeparator (parent):
+ parent.currentPageObj = Page7 (parent)
+
+def widKSqueezedTextLabel (parent):
+ parent.currentPageObj = Page1 (parent)
+
+def widKTabButton (parent):
+ parent.currentPageObj = Page5 (parent)
+
+def widKTabCtl (parent):
+ parent.currentPageObj = Page7 (parent)
+
+def widKTextBrowser (parent):
+ parent.currentPageObj = PageNotImpl (parent)
+
+def widKURLLabel (parent):
+ parent.currentPageObj = Page5 (parent)
+
+
+if __name__ == "__main__":
+ print
+ print "Please run uisampler.py"
+ print \ No newline at end of file
diff --git a/examples/uimodules/uixml.py b/examples/uimodules/uixml.py
new file mode 100644
index 0000000..baa6c86
--- /dev/null
+++ b/examples/uimodules/uixml.py
@@ -0,0 +1,45 @@
+import os
+
+from qt import QLabel
+
+from kdecore import KApplication
+
+class PageLaunch:
+ def __init__ (self, parent):
+ self.page = parent.addPage ()
+
+ x = 10
+ y = 10
+
+ launchLbl = QLabel ("Launching application ... please wait\n\nClose launched application to continue", self.page)
+ launchLbl.setGeometry (x, y, 300, 80)
+ launchLbl.show ()
+
+ self.page.show ()
+
+ KApplication.kApplication ().processEvents ()
+
+def xmlKActionCollection (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python xmlmenudemo.py")
+
+def xmlKEditToolbar (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python xmlmenudemo.py")
+
+def xmlKEditToolbarWidget (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python xmlmenudemo.py")
+
+def xmlKXMLGUIBuilder (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python xmlmenudemo.py")
+
+def xmlKXMLGUIClient (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python xmlmenudemo.py")
+
+def xmlKXMLGUIFactory (parent):
+ parent.currentPageObj = PageLaunch (parent)
+ os.system ("python xmlmenudemo.py")
+
diff --git a/examples/uiqxembed.py b/examples/uiqxembed.py
new file mode 100644
index 0000000..4f223b7
--- /dev/null
+++ b/examples/uiqxembed.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+"""
+
+"""
+import sys
+
+from qt import QIconSet, QProcess, QTimer, SIGNAL, SLOT
+
+from kdecore import KAboutData, KApplication, KCmdLineArgs, KGlobal, KIcon
+from kdecore import KWin, KWinModule
+from kdeui import KComboBox, KMainWindow, KPushButton, QXEmbed
+
+
+## add the missing items to the pyuic-generated module
+import qxembedexample
+qxembedexample.KComboBox = KComboBox
+qxembedexample.KPushButton = KPushButton
+
+from qxembedexample import QXEmbedExample
+
+
+def getIcon(name, group=KIcon.NoGroup, size=KIcon.SizeSmall):
+ """ returns a kde icon by name
+
+ """
+ return KGlobal.instance().iconLoader().loadIcon(name, group, size)
+
+def getIconSet(name, group=KIcon.NoGroup, size=KIcon.SizeSmall):
+ """ returns a kde icon set by name
+
+ """
+ return KGlobal.instance().iconLoader().loadIconSet(name, group, size)
+
+
+def getWindow(pid):
+ """ return a window info object for the process id (or None)
+
+ """
+ for winid in KWinModule().windows():
+ info = KWin.info(winid)
+ if pid == info.pid:
+ return info
+
+
+class ExampleForm(QXEmbedExample):
+ """ wraps the pyuic generated form class with our behavior
+
+ """
+ def __init__(self, parent):
+ QXEmbedExample.__init__(self, parent)
+ combo = self.appNameCombo
+ items = [(idx, '%s' % combo.text(idx)) for idx in range(combo.count())]
+ for idx, name in items:
+ combo.changeItem(getIcon(name), name, idx)
+ self.mainTabs.setTabIconSet(self.tab, getIconSet('help'))
+ self.launchButton.setIconSet(getIconSet('exec'))
+ self.launchButton.setText('Launch and Embed')
+
+ def launchApp(self):
+ """ launch the process selected in the combo
+
+ """
+ name = self.appNameCombo.currentText()
+ self.proc = proc = QProcess()
+ proc.addArgument(name)
+ code = proc.start()
+ if code:
+ pid = proc.processIdentifier()
+ self.launchPid = pid ## cheap
+ QTimer.singleShot(2000, self.embedLaunchedWindow)
+ else:
+ print 'failed to start %s' % name
+ return
+
+ def embedLaunchedWindow(self):
+ """ embed the window of the last launched pid
+
+ """
+ pid = self.launchPid
+ winobj = getWindow(pid)
+ if winobj:
+ tabs = self.mainTabs
+ embedded = QXEmbed(self)
+ caption = '%s (%s)' % (winobj.name, pid, )
+ tabs.insertTab(embedded, caption)
+ embedded.embed(winobj.win)
+ tabs.showPage(embedded)
+ pxm = KWin.icon(winobj.win)
+ tabs.setTabIconSet(embedded, QIconSet(pxm))
+
+
+class ExampleMain(KMainWindow):
+ """ an example main window
+
+ """
+ def __init__ (self, *args):
+ KMainWindow.__init__(self, *args)
+ self.setGeometry(0, 0, 400, 400)
+ self.embed = embed = ExampleForm(self)
+ self.setCentralWidget(embed)
+
+
+if __name__ == '__main__':
+ aname = 'PyKDE QXEmbed Sample'
+ desc = 'A Simple PyKDE QXEmbed Sample'
+ ver = '1.0'
+ lic = KAboutData.License_GPL
+ author = 'Troy Melhase'
+ authormail = 'troy@gci.net'
+
+ about = KAboutData(aname, aname, ver, desc, lic, '%s (c) 2004' % authormail)
+ about.addAuthor(author, 'hi, mom!', authormail)
+ about.addAuthor ('Jim Bublitz', 'For PyKDE', 'jbublitz@nwinternet.com')
+ KCmdLineArgs.init(sys.argv, about)
+ app = KApplication()
+ mainWindow = ExampleMain()
+ mainWindow.show()
+ app.connect(app, SIGNAL('lastWindowClosed()'), app, SLOT('quit()'))
+ app.exec_loop()
diff --git a/examples/uisampler.py b/examples/uisampler.py
new file mode 100644
index 0000000..00dd006
--- /dev/null
+++ b/examples/uisampler.py
@@ -0,0 +1,227 @@
+import sys
+sys.path.append ("./uimodules")
+
+from qt import QSplitter, QWidgetStack, QWidget, QListViewItem, SIGNAL, QCString , QScrollView, QRect, Qt
+
+from kdecore import KApplication, KCmdLineArgs, KAboutData
+from kdeui import KMainWindow, KListView
+
+from uidialogs import *
+from uiwidgets import *
+from uimenus import *
+from uixml import *
+from uimisc import *
+
+False = 0
+True = not False
+
+listItems = {"Dialogs":
+ {"KAboutDialog": ["KAboutApplication", "KAboutContainer", "KImageTrackLabel",\
+ "KAboutContainerBase", "KAboutContributor", "KAboutWidget"],\
+ "KAboutKDE": [],\
+ "KBugReport": [],\
+ "KColorDialog": [],\
+ "KDialog": [],\
+ "KDialogBase": ["KDialogBaseButton", "KDialogBase::SButton", "KDialogBaseTile"],\
+ "KFontDialog": [],\
+ "KKeyDialog": [],\
+ "KLineEditDlg": [],\
+ "KMessageBox": [],\
+ "KPasswordDialog": [],\
+ "KWizard": []},\
+ "Widgets":
+ {"KAnimWidget": [],\
+ "KAuthIcon": ["KRootPermsIcon", "KWritePermsIcon"],\
+ "KButtonBox": [],\
+ "KCharSelect": ["KCharSelectTable"],\
+ "KColorButton": [],\
+ "KColorCells": [],\
+ "KColorCombo": [],\
+ "KColorPatch": [],\
+ "KComboBox": [],\
+ "KCompletionBox": [],\
+ "KContainerLayout": ["KContainerLayout::KContainerLayoutItem"],\
+ "KCursor": [],\
+ "KDatePicker": ["KDateInternalMonthPicker", "KDateInternalYearSelector"],\
+ "KDateTable": [],\
+ "KDualColorButton": [],\
+ "KEdit": ["KEdFind", "KEdGotoLine", "KEdReplace"],\
+ "KEditListBox": [],\
+ "KFontChooser": [],\
+ "KHSSelector": [],\
+ "KIconView": [],\
+ "KJanusWidget": ["KJanusWidget::IconListBox"],\
+ "KKeyChooser": [],\
+ "KLed": [],\
+ "KLineEdit": [],\
+ "KListBox": [],\
+ "KListView": [],\
+ "KNumInput": ["KDoubleNumInput", "KIntNumInput"],\
+ "KPaletteTable": [],\
+ "KPasswordEdit": [],\
+ "KProgress": [],\
+ "KRootPixmap": [],\
+ "KMainWindow": [],\
+ "KRestrictedLine": [],\
+ "KRuler": [],\
+ "KSelector": ["KGradientSelector", "KValueSelector", "KHSSelector", "KXYSelector"],\
+ "KSeparator": [],\
+ "KSqueezedTextLabel": [],\
+ "KTabCtl": [],\
+ "KTextBrowser": [],\
+ "KURLLabel": []},\
+ "XML":
+ {"KActionCollection": [],\
+ "KEditToolbar": [],\
+ "KEditToolbarWidget": [],\
+ "KXMLGUIBuilder": [],\
+ "KXMLGUIClient": ["KXMLGUIClient::DocStruct"],\
+ "KXMLGUIFactory": []},\
+ "Menus/Toolbars":
+ {"KAccelMenu": [],\
+ "KAction": ["KFontAction", "KFontSizeAction", "KListAction", "KRecentFilesAction", "KRadioAction",\
+ "KSelectAction", "KToggleAction"],\
+ "KActionMenu": [],\
+ "KActionSeparator": [],\
+ "KContextMenuManager": [],\
+ "KDCOPActionProxy": [],\
+ "KHelpMenu": [],\
+ "KMenuBar": [],\
+ "KPanelApplet": [],\
+ "KPanelExtension": [],\
+ "KPanelMenu": [],\
+ "KPopupFrame": [],\
+ "KPopupMenu": [],\
+ "KPopupTitle": [],\
+ "KStatusBar": [],\
+ "KStatusBarLabel": [],\
+ "KStdAction": [],\
+ "KToolBar": ["KToolBarButton", "KToolBarButtonList", "KToolBarPopupAction",\
+ "KToolBarRadioGroup", "KToolBarSeparator"],\
+ "KWindowListMenu": []},\
+ "Other":
+ {"KAlphaPainter": [],\
+ "KCModule": [],\
+ "KColor": [],\
+ "KColorDrag": [],\
+ "KCommand": ["KMacroCommand"],\
+ "KCommandHistory": [],\
+ "KDateValidator": [],\
+ "KDockWindow": ["KDockButton_Private - KPanelMenu", "KDockButton_Private",\
+ "KDockSplitter", "KDockTabCtl_PrivateStruct", "KDockWidgetAbstractHeader",\
+ "KDockWidgetAbstractHeaderDrag", "KDockWidgetHeader",\
+ "KDockWidgetHeaderDrag", "KDockWidgetPrivate"],\
+ "KFloatValidator": [],\
+ "KIntValidator": [],\
+ "KPixmapIO": [],\
+ "KSharedPixmap": [],\
+ "KSystemTray": [],\
+ "KThemeBase": ["KThemeCache", "KThemePixmap", "KThemeStyle"],\
+ "QXEmbed": []}}
+
+prefix = {"Dialogs": "dlg", "Widgets": "wid", "XML": "xml", "Menus/Toolbars": "menu", "Other": "misc"}
+
+# The following leave about 375 x 390 for the rt hand panel
+mainGeom = QRect (0, 0, 640, 500)
+treeWidth = 220
+
+blankMsg = """ UISampler - provides examples of PyKDE widgets
+
+Select a dialog/widget/menu/etc example from the tree at left
+"""
+
+
+class MainWin (KMainWindow):
+ def __init__ (self, *args):
+ apply (KMainWindow.__init__, (self,) + args)
+
+ self.setCaption ("Samples of PyKDE widget usage")
+ self.setGeometry (mainGeom)
+
+ # create the main view - list view on the left and an
+ # area to display frames on the right
+ self.mainView = QSplitter (self, "main view")
+ self.tree = KListView (self.mainView, "tree")
+ self.page = QWidgetStack (self.mainView, "page")
+ self.blankPage = QWidget (self.page, "blank")
+ self.blankPage.setGeometry (0, 0, 375, 390)
+ self.blankPage.setBackgroundMode (QWidget.PaletteBase)
+
+ blankLbl = QLabel (blankMsg, self.blankPage)
+ blankLbl.setGeometry (40, 10, 380, 150)
+ blankLbl.setBackgroundMode (QWidget.PaletteBase)
+
+ blankPM = QPixmap ("pytestimage.png")
+ pmLbl = QLabel ("", self.blankPage)
+ pmLbl.setPixmap (blankPM)
+ pmLbl.setGeometry (40, 160, 300, 200)
+ pmLbl.setBackgroundMode (QWidget.PaletteBase)
+
+ self.page.addWidget (self.blankPage, 1)
+ self.page.raiseWidget (1)
+
+ self.setCentralWidget (self.mainView)
+
+ self.initListView ()
+ self.connect (self.tree, SIGNAL ("clicked (QListViewItem *)"), self.lvClicked)
+
+ self.edit = None
+ self.currentPageObj = None
+
+ def initListView (self):
+ self.tree.addColumn ("Category", treeWidth - 21)
+# self.tree.setMaximumWidth (treeWidth)
+ self.mainView.setSizes ([treeWidth, 375])
+ self.tree.setRootIsDecorated (True)
+ self.tree.setVScrollBarMode (QScrollView.AlwaysOn)
+ topLevel = listItems.keys ()
+ for item_1 in topLevel:
+ parent = QListViewItem (self.tree, item_1)
+ secondLevel = listItems [item_1].keys ()
+ for item_2 in secondLevel:
+ child = QListViewItem (parent, item_2)
+ for item_3 in listItems [item_1][item_2]:
+ QListViewItem (child, item_3)
+
+ def lvClicked (self, lvItem):
+ if not lvItem:
+ return
+
+ if lvItem.text (0).latin1 () in listItems.keys ():
+ return
+
+ p = lvItem.parent ()
+ if p.text (0).latin1 () in listItems.keys ():
+ pfx = prefix [p.text (0).latin1 ()]
+ funcCall = pfx + lvItem.text (0).latin1 () + "(self)"
+ else:
+ pfx = prefix [p.parent ().text (0).latin1 ()]
+ funcCall = pfx + lvItem.parent ().text (0).latin1 () + "(self)"
+
+ eval (funcCall)
+
+ def addPage (self):
+ self.edit = None
+ self.currentPageObj = None
+ current = self.page.widget (2)
+ if current:
+ self.page.removeWidget (current)
+ del current
+
+ newPage = QWidget (self.page)
+ newPage.setGeometry (0, 0, 375, 390)
+# newPage.setBackgroundMode (QWidget.PaletteBase)
+ self.page.addWidget (newPage, 2)
+ self.page.raiseWidget (2)
+
+ return newPage
+
+
+#-------------------- main ------------------------------------------------
+
+appName = "UISampler"
+app = KApplication (sys.argv, appName)
+mainWindow = MainWin (None, "main window")
+mainWindow.show()
+app.exec_loop()
+
diff --git a/examples/xmlmenudemo.py b/examples/xmlmenudemo.py
new file mode 100644
index 0000000..ab91dd5
--- /dev/null
+++ b/examples/xmlmenudemo.py
@@ -0,0 +1,291 @@
+"""
+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, os
+
+from qt import QPopupMenu, SIGNAL, QLabel, QIconSet
+
+from kdecore import KApplication, KCmdLineArgs, KAboutData, i18n, KIcon, KIconLoader, KShortcut, KGlobal
+from kdeui import KMainWindow, KMessageBox, KStdAction, KAction, KToggleAction, KFontSizeAction, KFontAction, KRadioAction,\
+ KActionSeparator, KActionMenu, KWindowListMenu, KXMLGUIClient, 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.setGeometry (0, 0, 350, 200)
+
+ # The second arg of createGUI needs to be 0 (or False)
+ # to enable XMLGUI features like ActionList (in 'dynamicActions')
+ # If the default is used (True), the dynamic actions will not
+ # appear in the menus
+ self.createGUI (os.path.join (mainpath, "xmlmenudemoui.rc"), 0)
+
+ self.dynamicActions()
+
+ # Can't do this until the toolBar has been created in createGUI
+ stretchlbl = QLabel ("", self.toolBar ())
+ self.toolBar ().setStretchableWidget (stretchlbl)
+
+ self.initStatusBar ()
+
+ self.saveAction.setEnabled (False)
+ self.saveAsAction.setEnabled (False)
+
+ def initActions (self):
+ # This is used in all of the KAction/KStdAction constructors --
+ # Seems more efficient to only do the call once
+ acts = self.actionCollection ()
+
+ # This is used often enough, we just define it here
+ scNull = KShortcut.null ()
+
+ # "File" menu items
+ self.newAction = KStdAction.openNew (self.slotNew, acts)
+ self.openAction = KStdAction.open (self.slotOpen, acts)
+ self.saveAction = KStdAction.save (self.slotSave, acts)
+ self.saveAsAction = KStdAction.saveAs (self.slotSaveAs, acts)
+ self.printAction = KStdAction.print_ (self.slotPrint, acts)
+ self.quitAction = KStdAction.quit (self.slotQuit, acts)
+
+ # "Edit" menu items
+ self.undoAction = KStdAction.undo (self.slotUndo, acts)
+ self.redoAction = KStdAction.redo (self.slotRedo, acts)
+ self.cutAction = KStdAction.cut (self.slotCut, acts)
+ self.copyAction = KStdAction.copy (self.slotCopy, acts)
+ self.pasteAction = KStdAction.paste (self.slotPaste, acts)
+ self.findAction = KStdAction.find (self.slotFind, acts)
+ self.findNextAction = KStdAction.findNext (self.slotFindNext, acts)
+ self.replaceAction = KStdAction.replace (self.slotReplace, acts)
+
+ # NOTE!!!! You must specify a parent and name for the action object in its constructor
+ # Normally in a constructor like
+ #
+ # someObject (QWidget *parent = 0, const char *name = 0)
+ #
+ # the parent may or may not be assigned, but widgets usually ignore the
+ # name argument. For an action of *any* type (other than KStdAction),
+ # the 'name' argument is what is used to load the action into the menus
+ # and toolBar (in the line below, "specialActionName"). The XMLGUI mechanism
+ # has no way to find out about the action objects except through their
+ # object names - the variable the object is assigned to ('self.specialAction')
+ # has no meaning in XNLGUI terms except through the objects 'name' member value
+
+ self.specialAction = KAction (i18n ("Special"), scNull, self.slotSpecial, acts, "specialActionName")
+
+ # Demo menu items
+
+ # KToggleAction has an isChecked member and emits the "toggle" signal
+ self.toggle1Action = KToggleAction ("Toggle 1", scNull, acts, "toggle1Action")
+ self.toggle2Action = KToggleAction ("Toggle 2", scNull, self.slotToggle2, acts, "toggle2Action")
+
+ # A separator - create once/use everywhere
+ self.separateAction = KActionSeparator (acts, "separateAction")
+
+ # Font stuff in menus or toolbar
+ self.fontAction = KFontAction ("Font", scNull, acts, "fontAction")
+ self.fontSizeAction = KFontSizeAction ("Font Size", scNull, acts, "fontSizeAction")
+
+ self.fontAction.setComboWidth (150)
+ self.fontSizeAction.setComboWidth (75)
+
+ # Need to assign an icon to actionMenu below
+ icons = KIconLoader ()
+ iconSet = QIconSet (icons.loadIcon ("viewmag", KIcon.Toolbar))
+
+ # Nested menus using KActions (also nested on toolbar)
+ self.actionMenu = KActionMenu ("Action Menu", acts, "actionMenu")
+ self.actionMenu.setIconSet (iconSet)
+
+ # By using KStdAction here, the XMLGUI mechanism will automatically
+ # create a 'View' menu and insert "Zoom In" and "Zoom Out" objects
+ # in it. This happens because before parsing our *ui.rc file,
+ # the standard KDE file config/ui/ui_standards.rc is parsed, and
+ # then our *ui.rc file is merged with the result - this gives KDE
+ # menus and toolBars a standard "look" and item placement (including
+ # separators). Creating the KStdActions alone is sufficient - you
+ # could delete their references from the *ui.rc file and the menu
+ # items would still be created via ui_standards.rc
+ self.actionMenu.insert (KStdAction.zoomIn (self.slotZoomIn, acts))
+ self.actionMenu.insert (KStdAction.zoomOut (self.slotZoomOut, acts))
+
+ self.radio1Action = KRadioAction ("Radio 1", scNull, self.slotRadio, acts, "radio1")
+ self.radio1Action.setExclusiveGroup ("Radio")
+ self.radio1Action.setChecked (1)
+ self.radio2Action = KRadioAction ("Radio 2", scNull, self.slotRadio, acts, "radio2")
+ self.radio2Action.setExclusiveGroup ("Radio")
+ self.radio3Action = KRadioAction ("Radio 3", scNull, self.slotRadio, acts, "radio3")
+ self.radio3Action.setExclusiveGroup ("Radio")
+
+
+ def initStatusBar (self):
+ self.statusBar ().insertItem ("", STATUSBAR_LEFT, 1000, True)
+ self.statusBar ().insertItem ("", STATUSBAR_MIDDLE, 1000, True)
+ self.statusBar ().insertItem ("", STATUSBAR_RIGHT, 1000, True)
+
+ def dynamicActions (self):
+ # This creates something like a 'recent files list' in the 'File' menu
+ # (There is a KRecentFilesAction that probably should be used instead,
+ # but this demos the use of action lists)
+ # The code here corresponds to the <ActionList name="recent"/> entry
+ # in the rc file
+
+ # Just fake some filenames for now
+ fakeFiles = ["kaction.sip", "kxmlguiclient.sip"]
+
+ # Clear the old entries, so we don't end up accumulating entries in the menu
+ self.unplugActionList("recent");
+ self.dynamicActionsList = []
+
+ # Create a KAction for each entry and store the KActions in a list
+ # Use 'None' for the KActionCollection argument in the KAction constructor
+ # in this case only
+ for i in range (len (fakeFiles)):
+ act = KAction (i18n (" ".join (["&" + str (i), fakeFiles [i]])), KShortcut.null (),\
+ self.slotFake, None, fakeFiles [i][:-4] + "open")
+ self.dynamicActionsList.append(act)
+
+ # Update the menu with the most recent KActions
+ self.plugActionList("recent", self.dynamicActionsList)
+
+
+#-------------------- slots -----------------------------------------------
+
+ def slotFake (self):
+ # sender () should be called before anything else
+ # (including "notImpl") so the correct sender
+ # value is returned
+ sender = self.sender ().name ()
+ self.notImpl ("Recent files (%s)" % sender)
+
+ # 'id' is for toolbar button signals - ignored for menu signals
+ 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 slotToggle2 (self):
+ self.notImpl ("Toggle")
+
+ def slotZoomIn (self):
+ self.notImpl ("Zoom In")
+
+ def slotZoomOut (self):
+ self.notImpl ("Zoom Out")
+
+ def slotRadio (self):
+ sender = self.sender ().name ()
+ self.notImpl ("Radio %s" % sender [-1])
+
+ 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"
+
+# The appName (xmlmenudemo - first argument) is required
+# if the program is to automatically locate it *ui.rc file
+aboutData = KAboutData ("xmlmenudemo", "xmlmenudemo",\
+ 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", "another@email.address")
+
+mainpath = os.path.dirname (os.path.abspath (sys.argv[0]))
+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/examples/xmlmenudemoui.rc b/examples/xmlmenudemoui.rc
new file mode 100644
index 0000000..58f07cf
--- /dev/null
+++ b/examples/xmlmenudemoui.rc
@@ -0,0 +1,49 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" ><kpartgui name="xmlmenudemo" version="1">
+<MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="newAction"/>
+ <Action name="openAction"/>
+ <Action name="saveAction"/>
+ <Action name="saveAsAction"/>
+ <Action name="printAction"/>
+ <Action name="quitAction"/>
+ <ActionList name="recent" />
+ </Menu>
+ <Menu name="edit"><text>&amp;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>
+ <Menu name="demo"><text>&amp;Demo</text>
+ <Action name="toggle1Action"/>
+ <Action name="toggle2Action"/>
+ <Action name="separateAction"/>
+ <Action name="fontAction"/>
+ <Action name="fontSizeAction"/>
+ <Action name="separateAction"/>
+ <Action name="actionMenu"/>
+ <Action name="radio1"/>
+ <Action name="radio2"/>
+ <Action name="radio3"/>
+ </Menu>
+</MenuBar>
+<ToolBar name="mainToolBar">
+ <Action name="actionMenu"/>
+ <Action name="separateAction"/>
+ <Action name="separateAction"/>
+ <Action name="fontAction"/>
+ <Action name="separateAction"/>
+ <Action name="fontSizeAction" comboWidth="75"/>
+ <Action name="radio1"/>
+ <Action name="radio2"/>
+ <Action name="radio3"/>
+ <Merge/>
+</ToolBar>
+<ActionProperties />
+</kpartgui>