You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.0 KiB
54 lines
2.0 KiB
13 years ago
|
from qt import TQt, TQFrame, TQHBoxLayout, TQVBoxLayout, TQStringList, TQLabel, \
|
||
13 years ago
|
SIGNAL, SLOT
|
||
13 years ago
|
from tdeui import KHistoryCombo, KTextEdit
|
||
13 years ago
|
|
||
|
|
||
|
iconName = 'history'
|
||
|
labelText = 'KHistoryCombo'
|
||
13 years ago
|
docParts = ('tdeui', 'KHistoryCombo')
|
||
13 years ago
|
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.')
|
||
|
|
||
|
|
||
13 years ago
|
historyText = 'a tquick brown fox jumps over the lazy dog'
|
||
13 years ago
|
|
||
|
|
||
13 years ago
|
class MainFrame(TQFrame):
|
||
13 years ago
|
def __init__(self, parent=None):
|
||
13 years ago
|
TQFrame.__init__(self, parent)
|
||
13 years ago
|
self.help = KTextEdit(helpText, '', self)
|
||
|
self.historyCombo = KHistoryCombo(self)
|
||
|
|
||
13 years ago
|
self.historySelectionLabel = TQLabel('Selected value: ', self)
|
||
|
self.historySelection = TQLabel('(none)', self)
|
||
13 years ago
|
|
||
13 years ago
|
items = TQStringList()
|
||
13 years ago
|
for item in historyText.split():
|
||
|
items.append(item)
|
||
|
self.historyCombo.setHistoryItems(items, True)
|
||
|
|
||
13 years ago
|
layout = TQVBoxLayout(self, 4)
|
||
13 years ago
|
layout.addWidget(self.help, 3)
|
||
|
layout.addStretch(1)
|
||
13 years ago
|
selectionLayout = TQHBoxLayout(layout, 4)
|
||
13 years ago
|
selectionLayout.addWidget(self.historySelectionLabel, 1)
|
||
13 years ago
|
selectionLayout.addWidget(self.historySelection, 10, TQt.AlignLeft)
|
||
13 years ago
|
layout.addWidget(self.historyCombo, 0)
|
||
|
layout.addStretch(10)
|
||
|
|
||
13 years ago
|
self.connect(self.historyCombo, SIGNAL('activated(const TQString& )'),
|
||
|
self.historyCombo, SLOT('addToHistory(const TQString&)'))
|
||
13 years ago
|
self.connect(self.historyCombo, SIGNAL('cleared()'),
|
||
|
self.historyCleared)
|
||
13 years ago
|
self.connect(self.historyCombo, SIGNAL('activated(const TQString &)'),
|
||
13 years ago
|
self.historySelection.setText)
|
||
|
|
||
|
def historyCleared(self):
|
||
|
print 'History combo cleared.'
|
||
|
|