Another PyQt Question (Easier this time)

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2008
Posts: 19
Reputation: OutOfReach is an unknown quantity at this point 
Solved Threads: 2
OutOfReach OutOfReach is offline Offline
Newbie Poster

Another PyQt Question (Easier this time)

 
0
  #1
Aug 27th, 2008
Ok I'll get straight to the point, how can a create a search box? You know, you type something in and it filters out the ones that don't match. Is there a special widget for this? Or would I have to create a normal lineedit widget and do all the filtering manually?
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,071
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 299
woooee woooee is offline Offline
Veteran Poster

Re: Another PyQt Question (Easier this time)

 
0
  #2
Aug 28th, 2008
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
  1. searchLabel = QtGui.QLabel(" Search", self)
  2. hLayout.addWidget(searchLabel)
  3. self.searchText = QtGui.QLineEdit()
  4. searchLabel.setBuddy(self.searchText)
  5. hLayout.addWidget(self.searchText)
  6.  
  7. self.treeWidget = self.createTreeWidget()
  8. vLayout.addWidget(self.treeWidget)
  9.  
  10. self.connect(self.searchText,
  11. QtCore.SIGNAL('textChanged(QString)'),
  12. self.treeWidget.searchItemName)
Last edited by woooee; Aug 28th, 2008 at 4:56 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 19
Reputation: OutOfReach is an unknown quantity at this point 
Solved Threads: 2
OutOfReach OutOfReach is offline Offline
Newbie Poster

Re: Another PyQt Question (Easier this time)

 
0
  #3
Aug 28th, 2008
Ok, so I'll have to do it manually, should be easy.
Thank you
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 19
Reputation: OutOfReach is an unknown quantity at this point 
Solved Threads: 2
OutOfReach OutOfReach is offline Offline
Newbie Poster

Re: Another PyQt Question (Easier this time)

 
0
  #4
Aug 28th, 2008
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...?
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,071
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 299
woooee woooee is offline Offline
Veteran Poster

Re: Another PyQt Question (Easier this time)

 
0
  #5
Aug 29th, 2008
In pseudo-code it would be something like this assuming a class format (ignoring case for now)
  1. def __init__(self):
  2. self.orig_list=[ "Original", "words", "you", "want", "to", "test"]
  3. self.new_list = orig_list[:] ## first pass - to be used by test_list
  4.  
  5. def compare_when_text_changed():
  6. test_list=self.new_list[:]
  7. self.new_list=[]
  8. for word in test_list:
  9. if word.startswith(self.entered_in_qt_edit_box):
  10. self.new_list.append(word)
  11.  
  12. ## self.new_list now contains the words that match so far
  13. ## update list box from self.new_list
  14.  
  15. ## not necessary to return anything since self. is used.
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.
Last edited by woooee; Aug 29th, 2008 at 9:33 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 19
Reputation: OutOfReach is an unknown quantity at this point 
Solved Threads: 2
OutOfReach OutOfReach is offline Offline
Newbie Poster

Re: Another PyQt Question (Easier this time)

 
0
  #6
Aug 30th, 2008
Ahh! Man your a lifesaver! You just saved me from hours and hours of frustration! I cannot thank you enough!!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum


Views: 625 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC