summaryrefslogtreecommitdiffstats
path: root/examples/pykde-sampler/dialogs
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/pykde-sampler/dialogs
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/pykde-sampler/dialogs')
-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
17 files changed, 768 insertions, 0 deletions
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>