###
class Window(QtGui.QDialog):

    def __init__(self):
        super(Window, self).__init__()

        self.resize(800,600)

        self.text = QtGui.QTextEdit(self)
        self.text.setText("All your key press are belong to us")

        layout = QtGui.QVBoxLayout(self)
        layout.addWidget(self.text)
        layout.addWidget(QtGui.QRadioButton("A Radio", self))
        layout.addWidget(QtGui.QPushButton("A Button", self))

    def keyPressEvent(self, event):
        self.text.keyPressEvent(event)

        # Comment this out, if you want, to prevent
        # the default key press event from also reaching the dialog
        super(Window, self).keyPressEvent(event)

###

If you click on the button or the radio, and the text area loses focus, you
should still be able to type and have it be forwarded to the text entry.
There is also the option of calling  myWindow.text.grabKeyboard()  ,
instead of using the keypress event. This will give the text entry absolute
control of the keyboard until it is released or another widget calls
grabKeyboard()




On Sun, Jul 21, 2013 at 6:00 PM, iMath <[email protected]> wrote:

> I don't know how to  catch the keyPress events ,can you show some code ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to