Python wx 模块,EVT_CHAR_HOOK 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用wx.EVT_CHAR_HOOK

项目:code    作者:ActiveState    | 项目源码 | 文件源码
def buildDialog(filePath, resourceName, mayCancel, **defaults):
    """Return a configured wx.Dialog.
    Assumes that the OK and Cancel buttons are named ID_OK & ID_CANCEL.
    """
    res = loadXrc(filePath)
    insureWxApp()
    dlg = res.LoadDialog(None, resourceName)
    assert isinstance(dlg, wx.Dialog)
    dlg.Fit()
    fetchWidget = dlg.FindWindowByName
    bOk     = dlg.FindWindowByName('ID_OK')
    bCancel = dlg.FindWindowByName('ID_CANCEL')
    bOk.SetId(wx.ID_OK)
    bCancel.SetId(wx.ID_CANCEL)
    if not mayCancel:
        bCancel.Disable()
        bCancel.Hide()
    for name, value in defaults.items():
        dlg.FindWindowByName(name).SetValue(value)
    if not mayCancel:
        dlg.Bind(wx.EVT_CHAR_HOOK, escapeSuppressor)
    return dlg
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def escapeSuppressor(evt):
    """wx.EVT_CHAR_HOOK handler that suppresses processing ESC.
    By default, if you don't have a Cancel button, wx will trigger the
    OK button when you press ESC. Binding this to a dialog will deactivate
    the ESC key. We need this when there is no Cancel button.
    """
    evt.Skip(evt.GetKeyCode() != wx.WXK_ESCAPE)
项目:stopgo    作者:notklaatu    | 项目源码 | 文件源码
def __init__(self, parent, id, title, style, clargs):
        if _plat.startswith('win'):
            HANDLER = logging.handlers.WatchedFileHandler(os.environ.get("LOGFILE", os.path.join(os.path.expanduser('~'), 'stopgo.log')))
        else:
            HANDLER = logging.handlers.WatchedFileHandler(os.environ.get("LOGFILE", os.path.join('/','tmp','stopgo.log')))

        FORMATTER = logging.Formatter(logging.BASIC_FORMAT)
        HANDLER.setFormatter(FORMATTER)

        if not clargs.has_key('verbose'):
            root = logging.getLogger()
            root.setLevel(os.environ.get("LOGLEVEL", "INFO"))
            root.addHandler(HANDLER)

        logging.exception("Debugging on.")
        #First retrieve the screen size of the device
        self.screenSize = wx.DisplaySize()
        self.framlog = 0
        self.thumbsize = 180
        self.camset = 0
        self.prefdate = 0
        prefstr = pref.PrefProbe().PrefGet()
        logging.exception(prefstr)
        logging.exception(type(prefstr))
        self.myprefs = prefstr
        #self.myprefs = json.dumps(prefstr, sort_keys=True)
        #self.screenSize = [ 786, 768 ]
        self.screenWidth = int(self.screenSize[0])
        self.screenHeight = int(self.screenSize[1])
        #self.screenWidth = int(self.screenSize[0] / 3)
        #self.screenHeight = int(self.screenSize[1] / 1.5)
        self.hasSelected = False
        self.previous = 0
        #fontsy = wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT).GetPixelSize()        
        wx.Frame.__init__(self, parent, id, title, size=(self.screenWidth, self.screenHeight), style=wx.DEFAULT_FRAME_STYLE)
        self.timer = wx.Timer(self, ID_TIMER)
        self.blick = 0
        self.Bind(wx.EVT_TIMER, self.OnTimer, id=ID_TIMER)
        self.Bind(wx.EVT_CHAR_HOOK, lambda event, args=(True, ):self.OnKeyDown(event, args))
        self.clargs = clargs
        logging.exception(prefstr)
        self.InitUI()
项目:Turrican2Editor    作者:GitExl    | 项目源码 | 文件源码
def __init__(self):
        FrameMainBase.__init__(self, None)

        self.SetIcon(wx.Icon(u'res/icon-diamond.ico'))

        self.Enable(False)
        self.Status.SetFieldsCount(1)

        self._edit_mode_dialogs = {
            ui.dialogs.EDIT_TILES: EditMode.TILES,
            ui.dialogs.EDIT_ENTITIES: EditMode.ENTITIES,
            ui.dialogs.EDIT_START: EditMode.START
        }

        self._edit_mode_panels = {
            EditMode.TILES: self.PanelModeTiles,
            EditMode.ENTITIES: self.PanelModeEntities,
            EditMode.START: self.PanelModeStart
        }

        self._edit_modes = {
            EditMode.TILES: EditModeTiles(self),
            EditMode.ENTITIES: EditModeEntities(self),
            EditMode.START: EditModeStart(self),
        }
        self._edit_mode = None

        self._game_dir = None

        self._mouse_state = MouseState.NONE
        self._move_last_pos = 0

        self._graphics = None
        self._worlds = None
        self._world = None
        self._level = None

        self._presenter = None
        self._camera = None

        self._draw_tile_collision = False
        self._always_draw_entities = True
        self._draw_blockmap = False

        self._font = Font.from_png('fonts/zepto.png')

        self.set_mode(EditMode.TILES)
        self.update_menu_state()

        self.Tiles.Bind(ui.tileselector.TileSelector.EVT_SELECT_EVENT, self.selection_tile)
        self.Entities.Bind(ui.entitypicker.EntityPicker.EVT_ENTITY_PICK_EVENT, self.selection_entity)
        self.Bind(wx.EVT_CHAR_HOOK, self.char_hook)

        self.Maximize()
        self.Show()

        self.Enable(True)