summaryrefslogtreecommitdiffstats
path: root/python/pykde/examples/pykde-sampler
diff options
context:
space:
mode:
Diffstat (limited to 'python/pykde/examples/pykde-sampler')
-rw-r--r--python/pykde/examples/pykde-sampler/HOWTO.samples60
-rw-r--r--python/pykde/examples/pykde-sampler/TODO12
-rw-r--r--python/pykde/examples/pykde-sampler/__init__.py1
-rw-r--r--python/pykde/examples/pykde-sampler/about.py57
-rw-r--r--python/pykde/examples/pykde-sampler/basic_widgets/__init__.py17
-rw-r--r--python/pykde/examples/pykde-sampler/basic_widgets/datepicker.py42
-rw-r--r--python/pykde/examples/pykde-sampler/basic_widgets/historycombo.py53
-rw-r--r--python/pykde/examples/pykde-sampler/contributors.txt4
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/__init__.py18
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/about/__init__.py16
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/about/aboutapp.py29
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/about/aboutkde.py28
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/bugreport.py34
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/color.py42
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/config.py59
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/edfind.py52
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/edreplace.py52
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/font.py53
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/input.py87
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/key.py29
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/msgbox.py141
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/passwd.py34
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/progress.py39
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/tip.py31
-rw-r--r--python/pykde/examples/pykde-sampler/dialogs/tips24
-rw-r--r--python/pykde/examples/pykde-sampler/gen_todo.py19
-rw-r--r--python/pykde/examples/pykde-sampler/icon_handling/__init__.py18
-rw-r--r--python/pykde/examples/pykde-sampler/icon_handling/misc.py31
-rw-r--r--python/pykde/examples/pykde-sampler/icon_handling/sizes.py30
-rw-r--r--python/pykde/examples/pykde-sampler/lib.py105
-rw-r--r--python/pykde/examples/pykde-sampler/misc/__init__.py16
-rw-r--r--python/pykde/examples/pykde-sampler/misc/gradientselect.py51
-rw-r--r--python/pykde/examples/pykde-sampler/misc/passivepop.py43
-rw-r--r--python/pykde/examples/pykde-sampler/misc/window_info.py35
-rw-r--r--python/pykde/examples/pykde-sampler/qt_widgets/CONTRIB537
-rw-r--r--python/pykde/examples/pykde-sampler/qt_widgets/__init__.py17
-rw-r--r--python/pykde/examples/pykde-sampler/qt_widgets/table.py42
-rw-r--r--python/pykde/examples/pykde-sampler/runner.py58
-rw-r--r--python/pykde/examples/pykde-sampler/sampler.py423
-rw-r--r--python/pykde/examples/pykde-sampler/sampler.rc13
-rw-r--r--python/pykde/examples/pykde-sampler/wizards/__init__.py2
-rw-r--r--python/pykde/examples/pykde-sampler/wizards/wiz.py2
-rw-r--r--python/pykde/examples/pykde-sampler/xwin/__init__.py18
43 files changed, 2474 insertions, 0 deletions
diff --git a/python/pykde/examples/pykde-sampler/HOWTO.samples b/python/pykde/examples/pykde-sampler/HOWTO.samples
new file mode 100644
index 00000000..74180541
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/TODO b/python/pykde/examples/pykde-sampler/TODO
new file mode 100644
index 00000000..730cc02c
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/__init__.py b/python/pykde/examples/pykde-sampler/__init__.py
new file mode 100644
index 00000000..4265cc3e
--- /dev/null
+++ b/python/pykde/examples/pykde-sampler/__init__.py
@@ -0,0 +1 @@
+#!/usr/bin/env python
diff --git a/python/pykde/examples/pykde-sampler/about.py b/python/pykde/examples/pykde-sampler/about.py
new file mode 100644
index 00000000..61fdd8a3
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/basic_widgets/__init__.py b/python/pykde/examples/pykde-sampler/basic_widgets/__init__.py
new file mode 100644
index 00000000..2442375d
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/basic_widgets/datepicker.py b/python/pykde/examples/pykde-sampler/basic_widgets/datepicker.py
new file mode 100644
index 00000000..aa36de52
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/basic_widgets/historycombo.py b/python/pykde/examples/pykde-sampler/basic_widgets/historycombo.py
new file mode 100644
index 00000000..aa35b53f
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/contributors.txt b/python/pykde/examples/pykde-sampler/contributors.txt
new file mode 100644
index 00000000..18b9a81f
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/__init__.py b/python/pykde/examples/pykde-sampler/dialogs/__init__.py
new file mode 100644
index 00000000..c6f70f9c
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/about/__init__.py b/python/pykde/examples/pykde-sampler/dialogs/about/__init__.py
new file mode 100644
index 00000000..4c40da7b
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/about/aboutapp.py b/python/pykde/examples/pykde-sampler/dialogs/about/aboutapp.py
new file mode 100644
index 00000000..afdd71a9
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/about/aboutkde.py b/python/pykde/examples/pykde-sampler/dialogs/about/aboutkde.py
new file mode 100644
index 00000000..9c73f9d4
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/bugreport.py b/python/pykde/examples/pykde-sampler/dialogs/bugreport.py
new file mode 100644
index 00000000..6c411650
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/color.py b/python/pykde/examples/pykde-sampler/dialogs/color.py
new file mode 100644
index 00000000..b749cce4
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/config.py b/python/pykde/examples/pykde-sampler/dialogs/config.py
new file mode 100644
index 00000000..74454ab0
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/edfind.py b/python/pykde/examples/pykde-sampler/dialogs/edfind.py
new file mode 100644
index 00000000..685902e0
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/edreplace.py b/python/pykde/examples/pykde-sampler/dialogs/edreplace.py
new file mode 100644
index 00000000..df956141
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/font.py b/python/pykde/examples/pykde-sampler/dialogs/font.py
new file mode 100644
index 00000000..ae2189e5
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/input.py b/python/pykde/examples/pykde-sampler/dialogs/input.py
new file mode 100644
index 00000000..30edc6fb
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/key.py b/python/pykde/examples/pykde-sampler/dialogs/key.py
new file mode 100644
index 00000000..4c437da2
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/msgbox.py b/python/pykde/examples/pykde-sampler/dialogs/msgbox.py
new file mode 100644
index 00000000..a0b3c9a3
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/passwd.py b/python/pykde/examples/pykde-sampler/dialogs/passwd.py
new file mode 100644
index 00000000..554093b9
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/progress.py b/python/pykde/examples/pykde-sampler/dialogs/progress.py
new file mode 100644
index 00000000..ba85b8eb
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/tip.py b/python/pykde/examples/pykde-sampler/dialogs/tip.py
new file mode 100644
index 00000000..29ac66b7
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/dialogs/tips b/python/pykde/examples/pykde-sampler/dialogs/tips
new file mode 100644
index 00000000..9f24457a
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/gen_todo.py b/python/pykde/examples/pykde-sampler/gen_todo.py
new file mode 100644
index 00000000..02d73dec
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/icon_handling/__init__.py b/python/pykde/examples/pykde-sampler/icon_handling/__init__.py
new file mode 100644
index 00000000..f25a8f09
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/icon_handling/misc.py b/python/pykde/examples/pykde-sampler/icon_handling/misc.py
new file mode 100644
index 00000000..4c7f4259
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/icon_handling/sizes.py b/python/pykde/examples/pykde-sampler/icon_handling/sizes.py
new file mode 100644
index 00000000..b3f5e1c2
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/lib.py b/python/pykde/examples/pykde-sampler/lib.py
new file mode 100644
index 00000000..875ae1ab
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/misc/__init__.py b/python/pykde/examples/pykde-sampler/misc/__init__.py
new file mode 100644
index 00000000..b0c92086
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/misc/gradientselect.py b/python/pykde/examples/pykde-sampler/misc/gradientselect.py
new file mode 100644
index 00000000..724dd52f
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/misc/passivepop.py b/python/pykde/examples/pykde-sampler/misc/passivepop.py
new file mode 100644
index 00000000..81d383af
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/misc/window_info.py b/python/pykde/examples/pykde-sampler/misc/window_info.py
new file mode 100644
index 00000000..08bff224
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/qt_widgets/CONTRIB b/python/pykde/examples/pykde-sampler/qt_widgets/CONTRIB
new file mode 100644
index 00000000..e814d1ec
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/qt_widgets/__init__.py b/python/pykde/examples/pykde-sampler/qt_widgets/__init__.py
new file mode 100644
index 00000000..ffe7bed6
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/qt_widgets/table.py b/python/pykde/examples/pykde-sampler/qt_widgets/table.py
new file mode 100644
index 00000000..d6b6e3ed
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/runner.py b/python/pykde/examples/pykde-sampler/runner.py
new file mode 100644
index 00000000..8b1ad2c5
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/sampler.py b/python/pykde/examples/pykde-sampler/sampler.py
new file mode 100644
index 00000000..bacf6346
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/sampler.rc b/python/pykde/examples/pykde-sampler/sampler.rc
new file mode 100644
index 00000000..fc068caf
--- /dev/null
+++ b/python/pykde/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/python/pykde/examples/pykde-sampler/wizards/__init__.py b/python/pykde/examples/pykde-sampler/wizards/__init__.py
new file mode 100644
index 00000000..63472b4e
--- /dev/null
+++ b/python/pykde/examples/pykde-sampler/wizards/__init__.py
@@ -0,0 +1,2 @@
+iconName = 'wizard'
+labelText = 'Wizards'
diff --git a/python/pykde/examples/pykde-sampler/wizards/wiz.py b/python/pykde/examples/pykde-sampler/wizards/wiz.py
new file mode 100644
index 00000000..1cb5544e
--- /dev/null
+++ b/python/pykde/examples/pykde-sampler/wizards/wiz.py
@@ -0,0 +1,2 @@
+iconName = 'wizard'
+labelText = 'Wizard'
diff --git a/python/pykde/examples/pykde-sampler/xwin/__init__.py b/python/pykde/examples/pykde-sampler/xwin/__init__.py
new file mode 100644
index 00000000..f9ff0b10
--- /dev/null
+++ b/python/pykde/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)
+
+
+
+