import wx


# 快捷键。
class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        super().__init__(parent, title=title, size=(300, 200))

        panel = wx.Panel(self)
        self.text = wx.TextCtrl(panel)

        self.text.Bind(wx.EVT_KEY_DOWN, self.on_key_down)

        self.Show(True)

    def on_key_down(self, event):
        keycode = event.GetKeyCode()
        control_down = event.ControlDown()

        if control_down and keycode == ord('S'):
            wx.MessageBox("Ctrl+S Pressed!", "Info")
        event.Skip()  # 如果没有这一句，那么在textctrl内，按键就没有效果。


app = wx.App()
frame = MyFrame(None, "wxPython Keyboard Event Example")
app.MainLoop()
