On Jan 7, 4:50 pm, "Edward K. Ream" <[email protected]> wrote: > Part 1: letting Qt help
Good progress to report. Here is a script in test.leo. It generates key events and sends them to various places: QQQ import PyQt4.QtCore as QtCore import PyQt4.QtGui as QtGui Qt = QtCore.Qt noMod = Qt.NoModifier shift = Qt.ShiftModifier ctrl = Qt.ControlModifier alt = Qt.AltModifier meta = Qt.MetaModifier # For a list of official key symbols, see # http://doc.trolltech.com/4.4/qt.html#Key-enum table = ( (ord('a'),noMod,'a'), (Qt.Key_Up,shift,''), ) # Put new characters at end. w = c.frame.body.bodyCtrl w.setInsertPoint('end') for key,mod,text in table: key = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,key,mod,text) for w in ( # c.frame.top, # a DynamicWindow. Nothing happens. c.frame.body.bodyCtrl.widget, # c.frame.log.logCtrl.widget, # works ): QtCore.QCoreApplication.sendEvent(w,key) # a QQQ The important thing to note is that Qt has standard key values for arrow keys. This means that the code is portable, regardless of keyboard or platform. The plan will be to define method in qtQui.py that will override (monkeypatch) Leo's commands such a next-line, next-line-extend- selection, etc. The new methods will simply generate a key event. For example, the following code will be the basis for the override of next-line-extend-selection: w = event.widget key = QtGui.QKeyEvent (QtCore.QEvent.KeyPress,Qt.Key_Down,Qt.ShiftModifier,'') QtCore.QCoreApplication.sendEvent(w,key) The essential advantage of monkey-patching Leo's core commands is that all the gui-dependent stuff will remain in qtGui.py. I'll define one or two helper methods to make overriding Leo's commands as painless as possible. This will probably happen today... 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.
