def __add_bindings(self): # file_save_ctrl self.fsc = control.FileChooserCtrl(self) self.Bind(wx.EVT_BUTTON, self.fsc.load_file, self.file_open_button) self.Bind(wx.EVT_BUTTON, self.fsc.save_file, self.save_button) # record_button_ctrl self.rbc = control.RecordCtrl() self.Bind(wx.EVT_TOGGLEBUTTON, self.rbc.action, self.record_button) # play_button_ctrl pbc = control.PlayCtrl() self.Bind(wx.EVT_TOGGLEBUTTON, pbc.action, self.play_button) # compile_button_ctrl self.Bind(wx.EVT_BUTTON, control.CompileCtrl.compile, self.compile_button) # help_button_ctrl self.Bind(wx.EVT_BUTTON, control.HelpCtrl.action, self.help_button) # settings_button_ctrl self.Bind(wx.EVT_BUTTON, self.on_settings_click, self.settings_button) self.Bind(wx.EVT_CLOSE, self.on_close_dialog) self.panel.Bind(wx.EVT_KEY_UP, self.on_key_press)
def __add_bindings(self): # file_save_ctrl self.fsc = control.FileChooserCtrl(self) self.Bind(wx.EVT_BUTTON, self.fsc.load_file, self.file_open_button) self.Bind(wx.EVT_BUTTON, self.fsc.save_file, self.save_button) # record_button_ctrl self.rbc = control.RecordCtrl() self.Bind(wx.EVT_TOGGLEBUTTON, self.rbc.action, self.record_button) # play_button_ctrl self.pbc = control.PlayCtrl() self.Bind(wx.EVT_TOGGLEBUTTON, self.pbc.action, self.play_button) # Handle the event returned after a playback has completed self.Bind(self.pbc.EVT_THREAD_END, self.on_thread_end) # compile_button_ctrl self.Bind(wx.EVT_BUTTON, control.CompileCtrl.compile, self.compile_button) # help_button_ctrl self.Bind(wx.EVT_BUTTON, control.HelpCtrl.action, self.help_button) # settings_button_ctrl self.Bind(wx.EVT_BUTTON, self.on_settings_click, self.settings_button) self.sc = control.SettingsCtrl(self) self.Bind(wx.EVT_CLOSE, self.on_close_dialog) # Handle keyboard shortcuts self.panel.Bind(wx.EVT_KEY_UP, self.on_key_press) self.panel.SetFocus()
def on_key_press(self, event): """ Create manually the event when the correct key is pressed.""" keycode = event.GetKeyCode() if keycode == wx.WXK_F1: control.HelpCtrl.action(wx.PyCommandEvent(wx.wxEVT_BUTTON)) elif keycode == settings.CONFIG.getint('DEFAULT', 'Recording Hotkey'): btnEvent = wx.CommandEvent(wx.wxEVT_TOGGLEBUTTON) btnEvent.EventObject = self.record_button if not self.record_button.Value: self.record_button.Value = True self.rbc.action(btnEvent) else: self.record_button.Value = False self.rbc.action(btnEvent) elif keycode == settings.CONFIG.getint('DEFAULT', 'Playback Hotkey'): if not self.play_button.Value: self.play_button.Value = True btnEvent = wx.CommandEvent(wx.wxEVT_TOGGLEBUTTON) btnEvent.EventObject = self.play_button control.PlayCtrl().action(btnEvent) elif keycode == ord("R") and event.CmdDown(): menu_event = wx.CommandEvent(wx.wxEVT_MENU) control.SettingsCtrl.repeat_count(menu_event) event.Skip()
def on_key_press(self, event): keycode = event.GetKeyCode() if keycode == wx.WXK_F1: control.HelpCtrl.action(wx.PyCommandEvent(wx.wxEVT_BUTTON)) elif keycode == settings.CONFIG.getint('DEFAULT', 'Recording Hotkey'): btnEvent = wx.CommandEvent(wx.wxEVT_TOGGLEBUTTON) btnEvent.EventObject = self.record_button if not self.record_button.Value: self.record_button.Value = True self.rbc.action(btnEvent) else: self.record_button.Value = False self.rbc.action(btnEvent) elif keycode == settings.CONFIG.getint('DEFAULT', 'Playback Hotkey'): if not self.play_button.Value: self.play_button.Value = True btnEvent = wx.CommandEvent(wx.wxEVT_TOGGLEBUTTON) btnEvent.EventObject = self.play_button control.PlayCtrl().action(btnEvent) else: event.Skip()