summaryrefslogtreecommitdiffstats
path: root/examples/pykde-sampler/basic_widgets/historycombo.py
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/basic_widgets/historycombo.py
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/basic_widgets/historycombo.py')
-rw-r--r--examples/pykde-sampler/basic_widgets/historycombo.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/examples/pykde-sampler/basic_widgets/historycombo.py b/examples/pykde-sampler/basic_widgets/historycombo.py
new file mode 100644
index 0000000..aa35b53
--- /dev/null
+++ b/examples/pykde-sampler/basic_widgets/historycombo.py
@@ -0,0 +1,53 @@
+from qt import Qt, QFrame, QHBoxLayout, QVBoxLayout, QStringList, QLabel, \
+ SIGNAL, SLOT
+from kdeui import KHistoryCombo, KTextEdit
+
+
+iconName = 'history'
+labelText = 'KHistoryCombo'
+docParts = ('kdeui', 'KHistoryCombo')
+helpText = ('An example of the KHistoryCombo widget.'
+ '\n\n'
+ 'Completion is enabled via the setHistoryItems call; when the second '
+ 'parameter is True, matching items from the list appear as you type.'
+ '\n\n'
+ 'The activated signal is connected to the addToHistory '
+ 'slot to automatically add new items.')
+
+
+historyText = 'a quick brown fox jumps over the lazy dog'
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+ self.historyCombo = KHistoryCombo(self)
+
+ self.historySelectionLabel = QLabel('Selected value: ', self)
+ self.historySelection = QLabel('(none)', self)
+
+ items = QStringList()
+ for item in historyText.split():
+ items.append(item)
+ self.historyCombo.setHistoryItems(items, True)
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help, 3)
+ layout.addStretch(1)
+ selectionLayout = QHBoxLayout(layout, 4)
+ selectionLayout.addWidget(self.historySelectionLabel, 1)
+ selectionLayout.addWidget(self.historySelection, 10, Qt.AlignLeft)
+ layout.addWidget(self.historyCombo, 0)
+ layout.addStretch(10)
+
+ self.connect(self.historyCombo, SIGNAL('activated(const QString& )'),
+ self.historyCombo, SLOT('addToHistory(const QString&)'))
+ self.connect(self.historyCombo, SIGNAL('cleared()'),
+ self.historyCleared)
+ self.connect(self.historyCombo, SIGNAL('activated(const QString &)'),
+ self.historySelection.setText)
+
+ def historyCleared(self):
+ print 'History combo cleared.'
+