I just sent the following to [email protected] list

QQQ
Hello all,

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

    w.blockSignals(False)
    w.setDisabled(False)

don't do the job. Alas, key events during the flashing can replace the
selected text (a bracket) with the incoming key.

Is there native support for flashing that I am overlooking?

Is there example code somewhere that would show how to lock out key
strokes until flashing is complete?

Is there some other recommended approach other than the code below?

Thanks.

Edward

P.S.  Here is my present code::

def flashCharacter(self,i,bg='white',fg='red',flashes=3,delay=75):

    w = self.widget

    def after(func):
        QtCore.QTimer.singleShot(delay,func)

    def addFlashCallback(self=self,w=w):
        n,i = self.flashCount,self.flashIndex
        self.setSelectionRange(i,i+1)  # = w.setSelection(i,i+1)
        self.flashCount -= 1
        after(removeFlashCallback)

    def removeFlashCallback(self=self,w=w):
        n,i = self.flashCount,self.flashIndex

        if n > 0:
            self.setSelectionRange(i,i)
            after(addFlashCallback)
        else:
            w.blockSignals(False)
            w.setDisabled(False)
            i = self.afterFlashIndex
            self.setSelectionRange(i,i,insert=i) # = w.textCursor
().setPosition(i)
            w.setFocus()

    self.flashCount = flashes
    self.flashIndex = i
    self.afterFlashIndex = self.getInsertPoint()
    w.setDisabled(True)
    w.blockSignals(True)
    addFlashCallback()

EKR
QQQ

Edward
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to