| | |
Another PyQt Question (Easier this time)
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Dec 2006
Posts: 1,071
Reputation:
Solved Threads: 299
A Google codesearch came up with only the do it yourself, the gist of which used textChanged. This snippet was in one of the hits
Python Syntax (Toggle Plain Text)
searchLabel = QtGui.QLabel(" Search", self) hLayout.addWidget(searchLabel) self.searchText = QtGui.QLineEdit() searchLabel.setBuddy(self.searchText) hLayout.addWidget(self.searchText) self.treeWidget = self.createTreeWidget() vLayout.addWidget(self.treeWidget) self.connect(self.searchText, QtCore.SIGNAL('textChanged(QString)'), self.treeWidget.searchItemName)
Last edited by woooee; Aug 28th, 2008 at 4:56 pm.
•
•
Join Date: Aug 2008
Posts: 19
Reputation:
Solved Threads: 2
Hmm well it turned out a little harder than I was expecting, I am using a QListWidget, I am trying to search for items in the list, but I have a problem, I plan on clearing the list and showing the ones that match, but If i clear the list I'll delete the existing entries, should I put them in a list, dictionary, etc...?
•
•
Join Date: Dec 2006
Posts: 1,071
Reputation:
Solved Threads: 299
In pseudo-code it would be something like this assuming a class format (ignoring case for now) I thought that someone would have posted code to do this, but coding this could become so funky that no one wants to put it out there on the internet I guess.
Python Syntax (Toggle Plain Text)
def __init__(self): self.orig_list=[ "Original", "words", "you", "want", "to", "test"] self.new_list = orig_list[:] ## first pass - to be used by test_list def compare_when_text_changed(): test_list=self.new_list[:] self.new_list=[] for word in test_list: if word.startswith(self.entered_in_qt_edit_box): self.new_list.append(word) ## self.new_list now contains the words that match so far ## update list box from self.new_list ## not necessary to return anything since self. is used.
Last edited by woooee; Aug 29th, 2008 at 9:33 pm.
![]() |
Other Threads in the Python Forum
- Previous Thread: help with file reading
- Next Thread: reading in multiple arrays from a single file
Views: 626 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Python
advanced assignment beginner bluetooth chmod cmd code convert count csv data decimals dictionary dynamic dynamically enter examples excel external file float format frange ftp function gnu gui heads hints homework import input jaunty java leftmouse line linux list lists loan loop module mouse multiple newb number numbers output parsing path pointer port prime program programming projects push py2exe pygame pyglet pyopengl pyqt python random raw_input recursion recursive scrolledtext slicenotation software ssh stderr string strings table tennis terminal text thread threading time tkinter tlapse tooltip tuple tutorial ubuntu unicode unix urllib urllib2 variable variables ventrilo web webservice windows wx.wizard wxpython xlib






