Wxpython,如何使用给定的密钥代码创建wx.KeyEvent?

Wxpython,如何使用给定的密钥代码创建wx.KeyEvent?,python,events,key,wxpython,Python,Events,Key,Wxpython,我正在尝试创建wx.KeyEvent对象,我需要它模拟wx.TextCtrl中的按键。我不想传播事件(如果可能的话),只需要创建一个对象。有办法做到这一点吗 我查看了wxpython.org上的wx.KeyEvent页面,但没有找到任何有用的信息。我唯一的提示是,也许我可以创建一个wx.Event对象并给它我想要的参数 编辑:我尝试过用eventType=wx.EVT_KEY_DOWN实例化一个事件对象,但是我得到一个异常,说它不能被子类化/实例化。难怪,因为我甚至会如何向它传递参数。您可以使用

我正在尝试创建wx.KeyEvent对象,我需要它模拟wx.TextCtrl中的按键。我不想传播事件(如果可能的话),只需要创建一个对象。有办法做到这一点吗

我查看了wxpython.org上的wx.KeyEvent页面,但没有找到任何有用的信息。我唯一的提示是,也许我可以创建一个wx.Event对象并给它我想要的参数


编辑:我尝试过用
eventType=wx.EVT_KEY_DOWN
实例化一个事件对象,但是我得到一个异常,说它不能被子类化/实例化。难怪,因为我甚至会如何向它传递参数。

您可以使用
wx.UIActionSimulator

i、 e

将模拟后跟选项卡的“z”

可采取的行动包括:

> Char  Press and release a key.
> KeyDown   Press a key.
> KeyUp Release a key.
> MouseClick    Click a mouse button.
> MouseDblClick Double-click a mouse button.
> MouseDown Press a mouse button.
> MouseDragDrop Perform a drag and drop operation.
> MouseMove Move the mouse to the specified coordinates.
> MouseUp   Release a mouse button.
> Text  Emulate typing in the keys representing the given string.

创建低级活动不是一个好主意。描述一下你想做什么,我们可能会找到更好的方法。您可以设置插入点、选择、编辑等等。我正在尝试在
wx.RichTextCtrl
中实现自动完成,如果我没有记错的话,
SetInsertionPoint
也帮不了我,因为我还在根据内容设置文本样式。例如,数字的颜色与关键字或论文的颜色不同。我发现只有
EmulateKeyPress
对我有效。其他形式只能部分起作用。谢谢!这正是我需要的。
> Char  Press and release a key.
> KeyDown   Press a key.
> KeyUp Release a key.
> MouseClick    Click a mouse button.
> MouseDblClick Double-click a mouse button.
> MouseDown Press a mouse button.
> MouseDragDrop Perform a drag and drop operation.
> MouseMove Move the mouse to the specified coordinates.
> MouseUp   Release a mouse button.
> Text  Emulate typing in the keys representing the given string.