summaryrefslogtreecommitdiffstats
path: root/examples/pytde-sampler/basic_widgets/historycombo.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/pytde-sampler/basic_widgets/historycombo.py')
-rw-r--r--examples/pytde-sampler/basic_widgets/historycombo.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/examples/pytde-sampler/basic_widgets/historycombo.py b/examples/pytde-sampler/basic_widgets/historycombo.py
new file mode 100644
index 0000000..3b0797c
--- /dev/null
+++ b/examples/pytde-sampler/basic_widgets/historycombo.py
@@ -0,0 +1,53 @@
+from qt import TQt, TQFrame, TQHBoxLayout, TQVBoxLayout, TQStringList, TQLabel, \
+ SIGNAL, SLOT
+from tdeui import KHistoryCombo, KTextEdit
+
+
+iconName = 'history'
+labelText = 'KHistoryCombo'
+docParts = ('tdeui', '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 tquick brown fox jumps over the lazy dog'
+
+
+class MainFrame(TQFrame):
+ def __init__(self, parent=None):
+ TQFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+ self.historyCombo = KHistoryCombo(self)
+
+ self.historySelectionLabel = TQLabel('Selected value: ', self)
+ self.historySelection = TQLabel('(none)', self)
+
+ items = TQStringList()
+ for item in historyText.split():
+ items.append(item)
+ self.historyCombo.setHistoryItems(items, True)
+
+ layout = TQVBoxLayout(self, 4)
+ layout.addWidget(self.help, 3)
+ layout.addStretch(1)
+ selectionLayout = TQHBoxLayout(layout, 4)
+ selectionLayout.addWidget(self.historySelectionLabel, 1)
+ selectionLayout.addWidget(self.historySelection, 10, TQt.AlignLeft)
+ layout.addWidget(self.historyCombo, 0)
+ layout.addStretch(10)
+
+ self.connect(self.historyCombo, SIGNAL('activated(const TQString& )'),
+ self.historyCombo, SLOT('addToHistory(const TQString&)'))
+ self.connect(self.historyCombo, SIGNAL('cleared()'),
+ self.historyCleared)
+ self.connect(self.historyCombo, SIGNAL('activated(const TQString &)'),
+ self.historySelection.setText)
+
+ def historyCleared(self):
+ print 'History combo cleared.'
+