當前位置: 首頁>>代碼示例>>Python>>正文


Python wx.CommandEvent方法代碼示例

本文整理匯總了Python中wx.CommandEvent方法的典型用法代碼示例。如果您正苦於以下問題:Python wx.CommandEvent方法的具體用法?Python wx.CommandEvent怎麽用?Python wx.CommandEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wx的用法示例。


在下文中一共展示了wx.CommandEvent方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: on_key_press

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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() 
開發者ID:RMPR,項目名稱:atbswp,代碼行數:24,代碼來源:gui.py

示例2: AskSave

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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 
開發者ID:andreas-p,項目名稱:admin4,代碼行數:19,代碼來源:xrced.py

示例3: OnButton

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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())
            ) 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:18,代碼來源:ActionSelectButton.py

示例4: OnKeyDown

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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() 
開發者ID:thiagoralves,項目名稱:OpenPLC_Editor,代碼行數:19,代碼來源:CustomEditableListBox.py

示例5: OnMouseDown

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
def OnMouseDown(self, event):
        clickEvent = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, self.GetId())
        clickEvent.SetEventObject(self)
        self.GetEventHandler().ProcessEvent(clickEvent)

# custom status control 
開發者ID:trelby,項目名稱:trelby,代碼行數:8,代碼來源:misc.py

示例6: test_optional_radiogroup_click_behavior

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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()) 
開發者ID:chriskiehl,項目名稱:Gooey,代碼行數:37,代碼來源:test_radiogroup.py

示例7: crt_command_event

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
def crt_command_event(event_type, event_id=0):
    """Shortcut to create command events."""
    return wx.CommandEvent(event_type.typeId, event_id) 
開發者ID:MrS0m30n3,項目名稱:youtube-dl-gui,代碼行數:5,代碼來源:widgets.py

示例8: SendSelectorEvent

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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) 
開發者ID:mmccoo,項目名稱:kicad_mmccoo,代碼行數:14,代碼來源:DialogUtils.py

示例9: Save

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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 
開發者ID:andreas-p,項目名稱:admin4,代碼行數:34,代碼來源:xrced.py

示例10: OnSelect

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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) 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:7,代碼來源:RadioBox.py

示例11: OnButton

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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())
            ) 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:17,代碼來源:MacroSelectButton.py

示例12: OnItemActivated

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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() 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:10,代碼來源:AddPluginDialog.py

示例13: OnActivated

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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()) 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:12,代碼來源:AddActionDialog.py

示例14: __init__

# 需要導入模塊: import wx [as 別名]
# 或者: from wx import CommandEvent [as 別名]
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) 
開發者ID:EventGhost,項目名稱:EventGhost,代碼行數:56,代碼來源:Registry.py


注:本文中的wx.CommandEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。