Python wx.CommandEvent() Examples
The following are 14
code examples of wx.CommandEvent().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
wx
, or try the search function
.
Example #1
Source File: gui.py From atbswp with GNU General Public License v3.0 | 6 votes |
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) else: event.Skip()
Example #2
Source File: xrced.py From admin4 with Apache License 2.0 | 6 votes |
def AskSave(self): if not (self.modified or panel.IsModified()): return True flags = wx.ICON_EXCLAMATION | wx.YES_NO | wx.CANCEL | wx.CENTRE dlg = wx.MessageDialog( self, 'File is modified. Save before exit?', 'Save before too late?', flags ) say = dlg.ShowModal() dlg.Destroy() wx.Yield() if say == wx.ID_YES: self.OnSaveOrSaveAs(wx.CommandEvent(wx.ID_SAVE)) # If save was successful, modified flag is unset if not self.modified: return True elif say == wx.ID_NO: self.SetModified(False) panel.SetModified(False) return True return False
Example #3
Source File: ActionSelectButton.py From EventGhost with GNU General Public License v2.0 | 6 votes |
def OnButton(self, dummyEvent): result = eg.TreeItemBrowseDialog.GetModalResult( self.title, self.mesg, self.action, (eg.ActionItem,), filterClasses = (eg.FolderItem, eg.MacroItem, eg.ActionItem), parent=self ) if result: action = result[0] self.textBox.SetLabel(result[0].GetLabel()) self.action = action self.ProcessEvent( wx.CommandEvent(wx.EVT_TEXT.evtType[0], self.GetId()) )
Example #4
Source File: CustomEditableListBox.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def OnKeyDown(self, event): button = None keycode = event.GetKeyCode() if keycode in (wx.WXK_ADD, wx.WXK_NUMPAD_ADD): button = self.GetNewButton() elif keycode in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE): button = self.GetDelButton() elif keycode == wx.WXK_UP and event.ShiftDown(): button = self.GetUpButton() elif keycode == wx.WXK_DOWN and event.ShiftDown(): button = self.GetDownButton() elif keycode == wx.WXK_SPACE: button = self.GetEditButton() if button is not None and button.IsEnabled(): button.ProcessEvent(wx.CommandEvent(wx.EVT_BUTTON.typeId, button.GetId())) else: event.Skip()
Example #5
Source File: misc.py From trelby with GNU General Public License v2.0 | 5 votes |
def OnMouseDown(self, event): clickEvent = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, self.GetId()) clickEvent.SetEventObject(self) self.GetEventHandler().ProcessEvent(clickEvent) # custom status control
Example #6
Source File: test_radiogroup.py From Gooey with MIT License | 5 votes |
def test_optional_radiogroup_click_behavior(self): """ Testing that select/deselect behaves as expected """ testcases = [ self.click_scenarios_optional_widget(), self.click_scenarios_required_widget(), self.click_scenarios_initial_selection() ] for testcase in testcases: with self.subTest(testcase['name']): # wire up the parse with our test case options parser = self.mutext_group(testcase['input']) with instrumentGooey(parser) as (app, gooeyApp): radioGroup = gooeyApp.configs[0].reifiedWidgets[0] for scenario in testcase['scenario']: targetButton = scenario['clickButton'] event = wx.CommandEvent(wx.wxEVT_LEFT_DOWN, wx.Window.NewControlId()) event.SetEventObject(radioGroup.radioButtons[targetButton]) radioGroup.radioButtons[targetButton].ProcessEvent(event) expectedEnabled, expectedDisabled = scenario['postState'] for index in expectedEnabled: self.assertEqual(radioGroup.selected, radioGroup.radioButtons[index]) self.assertTrue(radioGroup.widgets[index].IsEnabled()) for index in expectedDisabled: self.assertNotEqual(radioGroup.selected, radioGroup.radioButtons[index]) self.assertFalse(radioGroup.widgets[index].IsEnabled())
Example #7
Source File: widgets.py From youtube-dl-gui with The Unlicense | 5 votes |
def crt_command_event(event_type, event_id=0): """Shortcut to create command events.""" return wx.CommandEvent(event_type.typeId, event_id)
Example #8
Source File: DialogUtils.py From kicad_mmccoo with Apache License 2.0 | 5 votes |
def SendSelectorEvent(self, box): if (isinstance(box, wx.CheckBox)): # I have the feeling that this is the wrong way to trigger # an event. newevent = wx.CommandEvent(wx.EVT_CHECKBOX.evtType[0]) newevent.SetEventObject(box) wx.PostEvent(box, newevent) if (isinstance(box, wx.RadioButton)): newevent = wx.CommandEvent(wx.EVT_RADIOBUTTON.evtType[0]) newevent.SetEventObject(box) wx.PostEvent(box, newevent)
Example #9
Source File: xrced.py From admin4 with Apache License 2.0 | 5 votes |
def Save(self, path): try: import codecs # Apply changes if tree.selection and panel.IsModified(): self.OnRefresh(wx.CommandEvent()) if g.currentEncoding: f = codecs.open(path, 'wt', g.currentEncoding) else: f = codecs.open(path, 'wt') # Make temporary copy for formatting it # !!! We can't clone dom node, it works only once #self.domCopy = tree.dom.cloneNode(True) self.domCopy = MyDocument() mainNode = self.domCopy.appendChild(tree.mainNode.cloneNode(True)) # Remove first child (test element) testElem = mainNode.firstChild mainNode.removeChild(testElem) testElem.unlink() self.Indent(mainNode) self.domCopy.writexml(f, encoding = g.currentEncoding) f.close() self.domCopy.unlink() self.domCopy = None self.SetModified(False) panel.SetModified(False) conf.localconf.Flush() except: inf = sys.exc_info() wx.LogError(traceback.format_exception(inf[0], inf[1], None)[-1]) wx.LogError('Error writing file: %s' % path) raise
Example #10
Source File: RadioBox.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def OnSelect(self, event): self.value = event.GetId() newEvent = wx.CommandEvent(wx.EVT_RADIOBOX.evtType[0], self.GetId()) newEvent.SetInt(self.value) self.ProcessEvent(newEvent)
Example #11
Source File: MacroSelectButton.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def OnButton(self, dummyEvent): result = eg.TreeItemBrowseDialog.GetModalResult( self.title, self.mesg, self.macro, (eg.MacroItem,), parent=self ) if result: macro = result[0] self.textBox.SetLabel(macro.name) self.macro = macro self.ProcessEvent( wx.CommandEvent(wx.EVT_TEXT.evtType[0], self.GetId()) )
Example #12
Source File: AddPluginDialog.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def OnItemActivated(self, event): item = self.treeCtrl.GetSelection() info = self.treeCtrl.GetPyData(item) if info is not None: #self.SetResult("huhu") self.OnOK(wx.CommandEvent()) return event.Skip()
Example #13
Source File: AddActionDialog.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def OnActivated(self, event): """ Process wx.EVT_TREE_ITEM_ACTIVATED events. """ treeItem = self.tree.GetSelection() itemData = self.tree.GetPyData(treeItem) if isinstance(itemData, eg.ActionGroup): event.Skip() else: self.OnOK(wx.CommandEvent())
Example #14
Source File: Registry.py From EventGhost with GNU General Public License v2.0 | 4 votes |
def __init__( self, parent, id=-1, key = _winreg.HKEY_CURRENT_USER, subkey = "Software", valueName = None, pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.TR_HAS_BUTTONS, validator = wx.DefaultValidator, name="RegistryLazyTree", text = None ): self.text = text wx.TreeCtrl.__init__( self, parent, id, pos, size, style, validator, name ) self.imageList = imageList = wx.ImageList(16, 16) rootIcon = imageList.Add(eg.Icons.GetInternalBitmap("root")) self.folderIcon = imageList.Add(eg.Icons.GetInternalBitmap("folder")) self.valueIcon = imageList.Add(eg.Icons.GetInternalBitmap("action")) self.SetImageList(imageList) self.SetMinSize((-1, 200)) self.treeRoot = self.AddRoot( "Registry", image = rootIcon, data = wx.TreeItemData((True, None, None, None)) ) #Adding keys for item in regKeys: #a tupel of 4 values is assigned to every item #1) stores if the key has yet to be queried for subkey, when # selected #2) _winreg.hkey constant #3) name of the key #4) value name, None if just a key, empty string for default value tmp = self.AppendItem( self.treeRoot, item[1], image = self.folderIcon, data =wx.TreeItemData((False, item[0], "", None)) ) self.SetItemHasChildren(tmp, True) if item[0] == key: self.SelectItem(tmp) #select old value in tree self.OnTreeChange(wx.CommandEvent(), key, subkey, valueName) self.EnsureVisible(self.GetSelection()) self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTreeChange) self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnExpandNode)