Hello all,<br><br>I would like to have my app flash matching brackets in a QTextEdit.&nbsp; But I am having problems locking out key events while the flashing happens. I have tried all the obvious things.&nbsp; For example, in the my code (see the Post Script), w is a QTextEdit, and the calls to<br>
<br>&nbsp;&nbsp;&nbsp; w.blockSignals(False)<br>
&nbsp;&nbsp;&nbsp; w.setDisabled(False)<br><br>don&#39;t do the job. Alas, key events during the flashing can replace the selected text (a bracket) with the incoming key.&nbsp; <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.&nbsp; Here is my present code::<br>
<br>def flashCharacter(self,i,bg=&#39;white&#39;,fg=&#39;red&#39;,flashes=3,delay=75):<br><br>&nbsp;&nbsp;&nbsp; w = self.widget<br><br>&nbsp;&nbsp;&nbsp; def after(func):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QtCore.QTimer.singleShot(delay,func)<br><br>&nbsp;&nbsp;&nbsp; def addFlashCallback(self=self,w=w):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n,i = self.flashCount,self.flashIndex<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.setSelectionRange(i,i+1)&nbsp; # = w.setSelection(i,i+1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.flashCount -= 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; after(removeFlashCallback)<br><br>&nbsp;&nbsp;&nbsp; def removeFlashCallback(self=self,w=w):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n,i = self.flashCount,self.flashIndex<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if n &gt; 0:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.setSelectionRange(i,i)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; after(addFlashCallback)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; w.blockSignals(False)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; w.setDisabled(False)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = self.afterFlashIndex<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.setSelectionRange(i,i,insert=i) # = w.textCursor().setPosition(i)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; w.setFocus()<br><br>&nbsp;&nbsp;&nbsp; self.flashCount = flashes<br>&nbsp;&nbsp;&nbsp; self.flashIndex = i<br>&nbsp;&nbsp;&nbsp; self.afterFlashIndex = self.getInsertPoint()<br>
&nbsp;&nbsp;&nbsp; w.setDisabled(True)<br>&nbsp;&nbsp;&nbsp; w.blockSignals(True)<br>&nbsp;&nbsp;&nbsp; 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>