Hello all,<br><br>I would like to have my app flash matching brackets in a QTextEdit. But I am having problems locking out key events while the flashing happens. I have tried all the obvious things. For example, in the my code (see the Post Script), w is a QTextEdit, and the calls to<br>
<br> w.blockSignals(False)<br>
w.setDisabled(False)<br><br>don't do the job. Alas, key events during the flashing can replace the selected text (a bracket) with the incoming key. <br><br>Is there native support for flashing that I am overlooking?<br>
<br>Is there example code somewhere that would show how to lock out key strokes until flashing is complete?<br><br>Is there some other recommended approach other than the code below?<br><br>Thanks.<br><br>Edward<br><br>P.S. Here is my present code::<br>
<br>def flashCharacter(self,i,bg='white',fg='red',flashes=3,delay=75):<br><br> w = self.widget<br><br> def after(func):<br> QtCore.QTimer.singleShot(delay,func)<br><br> def addFlashCallback(self=self,w=w):<br>
n,i = self.flashCount,self.flashIndex<br> self.setSelectionRange(i,i+1) # = w.setSelection(i,i+1)<br> self.flashCount -= 1<br> after(removeFlashCallback)<br><br> def removeFlashCallback(self=self,w=w):<br>
n,i = self.flashCount,self.flashIndex<br><br> if n > 0:<br> self.setSelectionRange(i,i)<br> after(addFlashCallback)<br> else:<br> w.blockSignals(False)<br> w.setDisabled(False)<br>
i = self.afterFlashIndex<br> self.setSelectionRange(i,i,insert=i) # = w.textCursor().setPosition(i)<br> w.setFocus()<br><br> self.flashCount = flashes<br> self.flashIndex = i<br> self.afterFlashIndex = self.getInsertPoint()<br>
w.setDisabled(True)<br> w.blockSignals(True)<br> addFlashCallback()<br><br>EKR<br>--------------------------------------------------------------------<br>Edward K. Ream email: <a href="mailto:edreamleo@gmail.com">edreamleo@gmail.com</a><br>
Leo: <a href="http://webpages.charter.net/edreamleo/front.html">http://webpages.charter.net/edreamleo/front.html</a><br>--------------------------------------------------------------------<br><br>