Python wx.EVT_KEY_DOWN Examples
The following are 27
code examples of wx.EVT_KEY_DOWN().
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: viewer.py From dials with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, parent, id, title, size, settings=None, *args, **kwds): wx.Frame.__init__(self, parent, id, title, size=size, *args, **kwds) Render3d.__init__(self, settings=settings) self.parent = self.GetParent() self.statusbar = self.CreateStatusBar() self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.create_settings_panel() self.sizer.Add(self.settings_panel, 0, wx.EXPAND) self.create_viewer_panel() self.sizer.Add(self.viewer, 1, wx.EXPAND | wx.ALL) self.SetSizerAndFit(self.sizer) self.SetMinSize(self.settings_panel.GetSize()) self.Bind(wx.EVT_CLOSE, self.OnClose, self) self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy, self) self.Bind(wx.EVT_ACTIVATE, self.OnActive) self.viewer.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) self.viewer.SetFocus()
Example #2
Source File: CustomEditableListBox.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def __init__(self, *args, **kwargs): wx.gizmos.EditableListBox.__init__(self, *args, **kwargs) listbox = self.GetListCtrl() listbox.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) listbox.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnLabelBeginEdit) listbox.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnLabelEndEdit) for button, tooltip, call_function in [ (self.GetEditButton(), _("Edit item"), "_OnEditButton"), (self.GetNewButton(), _("New item"), "_OnNewButton"), (self.GetDelButton(), _("Delete item"), "_OnDelButton"), (self.GetUpButton(), _("Move up"), "_OnUpButton"), (self.GetDownButton(), _("Move down"), "_OnDownButton")]: button.SetToolTipString(tooltip) button.Bind(wx.EVT_BUTTON, self.GetButtonPressedFunction(call_function)) self.Editing = False
Example #3
Source File: DurationCellEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent): wx.PyControl.__init__(self, parent) main_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) main_sizer.AddGrowableCol(0) main_sizer.AddGrowableRow(0) # create location text control self.Duration = wx.TextCtrl(self, size=wx.Size(0, -1), style=wx.TE_PROCESS_ENTER) self.Duration.Bind(wx.EVT_KEY_DOWN, self.OnDurationChar) main_sizer.AddWindow(self.Duration, flag=wx.GROW) # create browse button self.EditButton = wx.Button(self, label='...', size=wx.Size(30, -1)) self.Bind(wx.EVT_BUTTON, self.OnEditButtonClick, self.EditButton) main_sizer.AddWindow(self.EditButton, flag=wx.GROW) self.Bind(wx.EVT_SIZE, self.OnSize) self.SetSizer(main_sizer) self.Default = None
Example #4
Source File: CustomGrid.py From OpenPLC_Editor with GNU General Public License v3.0 | 6 votes |
def __init__(self, *args, **kwargs): wx.grid.Grid.__init__(self, *args, **kwargs) self.Editable = True self.AddButton = None self.DeleteButton = None self.UpButton = None self.DownButton = None self.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, 'Sans')) self.SetLabelFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, 'Sans')) self.SetSelectionBackground(wx.WHITE) self.SetSelectionForeground(wx.BLACK) self.DisableDragRowSize() self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell) self.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnEditorHidden) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
Example #5
Source File: Keymap.py From meerk40t with MIT License | 6 votes |
def __init__(self, *args, **kwds): # begin wxGlade: Keymap.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP wx.Frame.__init__(self, *args, **kwds) Module.__init__(self) self.SetSize((500, 530)) self.list_keymap = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_HRULES | wx.LC_REPORT | wx.LC_VRULES) self.button_add = wx.Button(self, wx.ID_ANY, _("Add Hotkey")) self.text_key_name = wx.TextCtrl(self, wx.ID_ANY, "") self.text_command_name = wx.TextCtrl(self, wx.ID_ANY, "") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_BUTTON, self.on_button_add_hotkey, self.button_add) # end wxGlade self.Bind(wx.EVT_CLOSE, self.on_close, self) self.text_key_name.Bind(wx.EVT_KEY_DOWN, self.on_key_press) self.SetFocus()
Example #6
Source File: edit_base.py From wxGlade with MIT License | 6 votes |
def destroy_widget(self, level): if self.widget is None: return if misc.currently_under_mouse is self.widget: misc.currently_under_mouse = None self.widget.Hide() if wx.VERSION_STRING!="2.8.12.0": # unbind events to prevent new created (and queued) events self.widget.Bind(wx.EVT_PAINT, None) self.widget.Bind(wx.EVT_RIGHT_DOWN, None) self.widget.Bind(wx.EVT_LEFT_DOWN, None) self.widget.Bind(wx.EVT_MIDDLE_DOWN, None) self.widget.Bind(wx.EVT_ENTER_WINDOW, None) self.widget.Bind(wx.EVT_LEAVE_WINDOW, None) self.widget.Bind(wx.EVT_KEY_DOWN, None) compat.DestroyLater(self.widget) self.widget = None if misc.focused_widget is self: misc.set_focused_widget(None)
Example #7
Source File: LapGUI.py From laplacian-meshes with GNU General Public License v3.0 | 6 votes |
def __init__(self, parent): super(MeshViewerCanvas, self).__init__(parent) self.GUIState = STATE_NORMAL self.GUISubstate = SUBSTATE_NONE self.clearAllSelections() #State variables for heat, etc (self.eigvalues, self.eigvectors) = (np.array([]), np.array([])) self.heatIdx = 0 self.heat_ts = np.linspace(0, 1000, 100) #State variables for color picking self.colorPickTexID = None self.colorPosVBO = None self.colorColorVBO = None self.Bind(wx.EVT_KEY_DOWN, self.onKeyPress) self.Bind(wx.EVT_KEY_UP, self.onKeyRelease) self.pressingC = False
Example #8
Source File: edit_sizers.py From wxGlade with MIT License | 5 votes |
def __init__(self, parent, id, sizer): GenButton.__init__(self, parent.widget, id, '', size=(5, 5)) self.sizer = sizer self.SetUseFocusIndicator(False) self.Bind(wx.EVT_RIGHT_DOWN, self.sizer.popup_menu ) #self.Bind(wx.EVT_KEY_DOWN, misc.on_key_down_event) color = compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) self.SetBackgroundColour(color)
Example #9
Source File: geometry_viewer.py From dials with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, *args, **kwds): wx.Frame.__init__(self, *args, **kwds) render_3d.__init__(self) self.parent = self.GetParent() self.statusbar = self.CreateStatusBar() self.sizer = wx.BoxSizer(wx.HORIZONTAL) app = wx.GetApp() if getattr(app, "settings", None) is not None: # XXX copying the initial settings avoids awkward interactions when # multiple viewer windows are opened self.settings = copy.deepcopy(app.settings) else: self.settings = settings() self.create_settings_panel() self.sizer.Add(self.settings_panel, 0, wx.EXPAND) self.create_viewer_panel() self.sizer.Add(self.viewer, 1, wx.EXPAND | wx.ALL) self.SetSizer(self.sizer) self.sizer.SetSizeHints(self) self.Bind(wx.EVT_CLOSE, self.OnClose, self) self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy, self) self.Bind(wx.EVT_ACTIVATE, self.OnActive) self.viewer.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) self.viewer.SetFocus()
Example #10
Source File: viafence_action.py From RF-tools-KiCAD with GNU General Public License v3.0 | 5 votes |
def selfToMainDialog(self): self.mainDlg.lstLayer.SetItems(list(self.layerMap.values())) #maui self.mainDlg.lstLayer.SetSelection(self.layerId) self.mainDlg.txtNetFilter.SetItems(self.netFilterList) self.mainDlg.txtNetFilter.SetSelection(self.netFilterList.index(self.netFilter)) self.mainDlg.txtViaOffset.SetValue(str(pcbnew.ToMM(self.viaOffset))) self.mainDlg.txtViaPitch.SetValue(str(pcbnew.ToMM(self.viaPitch))) self.mainDlg.txtViaDrill.SetValue(str(pcbnew.ToMM(self.viaDrill))) self.mainDlg.txtViaSize.SetValue(str(pcbnew.ToMM(self.viaSize))) self.mainDlg.txtViaOffset.Bind(wx.EVT_KEY_DOWN, self.DoKeyPress) #self.mainDlg.txtViaOffset.Bind(wx.EVT_TEXT_ENTER, self.mainDlg.EndModal(wx.ID_OK)) self.mainDlg.txtViaPitch.Bind(wx.EVT_KEY_DOWN, self.DoKeyPress) self.mainDlg.txtViaDrill.Bind(wx.EVT_KEY_DOWN, self.DoKeyPress) self.mainDlg.txtViaSize.Bind(wx.EVT_KEY_DOWN, self.DoKeyPress) self.mainDlg.lstViaNet.SetItems([item.GetNetname() for item in self.netMap.values()]) for i, item in enumerate (self.netMap.values()): if self.mainDlg.lstViaNet.GetString(i) in ["GND", "/GND"]: self.mainDlg.lstViaNet.SetSelection(i) break self.mainDlg.chkNetFilter.SetValue(self.isNetFilterChecked) self.mainDlg.txtNetFilter.Enable(self.isNetFilterChecked) self.mainDlg.chkLayer.SetValue(self.isLayerChecked) self.mainDlg.lstLayer.Enable(self.isLayerChecked) self.mainDlg.chkIncludeDrawing.SetValue(self.isIncludeDrawingChecked) self.mainDlg.chkIncludeSelection.SetValue(self.isIncludeSelectionChecked) self.mainDlg.chkDebugDump.SetValue(self.isDebugDumpChecked) self.mainDlg.chkRemoveViasWithClearanceViolation.SetValue(self.isRemoveViasWithClearanceViolationChecked) self.mainDlg.chkSameNetZoneViasOnly.SetValue(self.isSameNetZoneViasOnlyChecked) self.mainDlg.m_buttonDelete.Bind(wx.EVT_BUTTON, self.onDeleteClick) # hiding unimplemented controls #self.mainDlg.chkRemoveViasWithClearanceViolation.Hide() self.mainDlg.chkSameNetZoneViasOnly.Hide()
Example #11
Source File: PouInstanceVariablesPanel.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def ShowInstanceChoicePopup(self): self.InstanceChoice.SetFocusFromKbd() size = self.InstanceChoice.GetSize() event = wx.MouseEvent(wx.EVT_LEFT_DOWN._getEvtType()) event.x = size.width // 2 event.y = size.height // 2 event.SetEventObject(self.InstanceChoice) # event = wx.KeyEvent(wx.EVT_KEY_DOWN._getEvtType()) # event.m_keyCode = wx.WXK_SPACE self.InstanceChoice.GetEventHandler().ProcessEvent(event)
Example #12
Source File: TextCtrlAutoComplete.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent, choices=None, dropDownClick=True, element_path=None, **therest): """ Constructor works just like wx.TextCtrl except you can pass in a list of choices. You can also change the choice list at any time by calling setChoices. """ therest['style'] = wx.TE_PROCESS_ENTER | therest.get('style', 0) wx.TextCtrl.__init__(self, parent, **therest) # Some variables self._dropDownClick = dropDownClick self._lastinsertionpoint = None self._hasfocus = False self._screenheight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y) self.element_path = element_path self.listbox = None self.SetChoices(choices) # gp = self # while ( gp != None ) : # gp.Bind ( wx.EVT_MOVE , self.onControlChanged, gp ) # gp.Bind ( wx.EVT_SIZE , self.onControlChanged, gp ) # gp = gp.GetParent() self.Bind(wx.EVT_KILL_FOCUS, self.OnControlChanged) self.Bind(wx.EVT_TEXT_ENTER, self.OnControlChanged) self.Bind(wx.EVT_TEXT, self.OnEnteredText) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) # If need drop down on left click if dropDownClick: self.Bind(wx.EVT_LEFT_DOWN, self.OnClickToggleDown) self.Bind(wx.EVT_LEFT_UP, self.OnClickToggleUp)
Example #13
Source File: __init__.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def __init__(self, parent=None): wx.Frame.__init__( self, parent, style=wx.NO_BORDER|wx.FRAME_NO_TASKBAR|wx.CLIP_CHILDREN ) self.drawing = None self.displayNum = 0 self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_LEFT_DCLICK, self.LeftDblClick) self.Bind(wx.EVT_KEY_DOWN, self.OnChar) self.Bind(wx.EVT_MOTION, self.ShowCursor) self.timer = None self.SetBackgroundColour((0, 0, 0))
Example #14
Source File: tree.py From wxGlade with MIT License | 5 votes |
def __init__(self, parent, application): style = wx.TR_DEFAULT_STYLE|wx.TR_HAS_VARIABLE_ROW_HEIGHT style |= wx.TR_EDIT_LABELS if wx.Platform == '__WXGTK__': style |= wx.TR_NO_LINES|wx.TR_FULL_ROW_HIGHLIGHT elif wx.Platform == '__WXMAC__': style &= ~wx.TR_ROW_LINES wx.TreeCtrl.__init__(self, parent, -1, style=style) self.cur_widget = None # reference to the selected widget self.root = application image_list = wx.ImageList(21, 21) image_list.Add(wx.Bitmap(os.path.join(config.icons_path, 'application.xpm'), wx.BITMAP_TYPE_XPM)) for w in WidgetTree.images: WidgetTree.images[w] = image_list.Add(misc.get_xpm_bitmap(WidgetTree.images[w])) self.AssignImageList(image_list) application.item = self.AddRoot(_('Application'), 0) self._SetItemData(application.item, application) self.skip_select = 0 # avoid an infinite loop on win32, as SelectItem fires an EVT_TREE_SEL_CHANGED event self.drop_target = clipboard.DropTarget(self, toplevel=True) self.SetDropTarget(self.drop_target) self._drag_ongoing = False self.auto_expand = True # this control the automatic expansion of nodes: it is set to False during xml loading self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_change_selection) self.Bind(wx.EVT_RIGHT_DOWN, self.popup_menu) self.Bind(wx.EVT_LEFT_DCLICK, self.on_left_dclick) self.Bind(wx.EVT_LEFT_DOWN, self.on_left_click) # allow direct placement of widgets self.Bind(wx.EVT_MENU, self.on_menu) # for handling the selection of the first item self._popup_menu_widget = None # the widget for the popup menu self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.begin_drag) self.Bind(wx.EVT_LEAVE_WINDOW, self.on_leave_window) self.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse_events) self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.begin_edit_label) self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.end_edit_label) #self.Bind(wx.EVT_KEY_DOWN, misc.on_key_down_event) self.Bind(wx.EVT_KEY_DOWN, self.on_key_down_event) #self.Bind(wx.EVT_CHAR_HOOK, self.on_char) # on wx 2.8 the event will not be delivered to the child self.Bind(wx.EVT_TREE_DELETE_ITEM, self.on_delete_item)
Example #15
Source File: __init__.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def __init__(self, *a, **k): wx.Dialog.__init__(self, *a, **k) if sys.platform == 'darwin': self.CenterOnParent() self.SetIcon(wx.the_app.icon) self.Bind(wx.EVT_KEY_DOWN, self.key)
Example #16
Source File: widgets.py From youtube-dl-gui with The Unlicense | 5 votes |
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, choices=[], style=0, validator=wx.DefaultValidator, name=NAME): super(ListBoxWithHeaders, self).__init__(parent, id, pos, size, [], style, validator, name) self.__headers = set() # Ignore all key events i'm bored to handle the header selection self.Bind(wx.EVT_KEY_DOWN, lambda event: None) # Make sure that a header is never selected self.Bind(wx.EVT_LISTBOX, self._on_listbox) for event in self.EVENTS: self.Bind(event, self._disable_header_selection) # Append the items in our own way in order to add the TEXT_PREFIX self.AppendItems(choices)
Example #17
Source File: recipe-577951.py From code with MIT License | 5 votes |
def OnKeyDown(self, event): """ Handles the ``wx.EVT_KEY_DOWN`` event for L{RoundButton}. :param `event`: a `wx.KeyEvent` event to be processed. """ if self._hasFocus and event.GetKeyCode() == ord(" "): self._mouseAction = HOVER self.Refresh() event.Skip()
Example #18
Source File: recipe-577951.py From code with MIT License | 5 votes |
def __init__(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator, name="roundbutton"): """ Default class constructor. :param `parent`: the L{RoundButton} parent; :param `id`: window identifier. A value of -1 indicates a default value; :param `label`: the button text label; :param `pos`: the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform; :param `size`: the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform; :param `style`: the button style (unused); :param `validator`: the validator associated to the button; :param `name`: the button name. """ wx.PyControl.__init__(self, parent, id, pos, size, style, validator, name) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_ERASE_BACKGROUND, lambda event: None) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave) self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter) self.Bind(wx.EVT_SET_FOCUS, self.OnGainFocus) self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown) self._mouseAction = None self._hasFocus = False self._buttonRadius = 0 self.SetLabel(label) self.InheritAttributes() self.SetInitialSize(size)
Example #19
Source File: wm_core.py From wafer_map with GNU General Public License v3.0 | 5 votes |
def _on_key_down(self, event): """ Event Handler for Keyboard Shortcuts. This is used when the panel is integrated into a Frame and the Frame does not define the KB Shortcuts already. If inside a frame, the wx.EVT_KEY_DOWN event is sent to the toplevel Frame which handles the event (if defined). At least I think that's how that works... See http://wxpython.org/Phoenix/docs/html/events_overview.html for more info. Shortcuts: HOME: Zoom to fill window O: Toggle wafer outline C: Toggle wafer crosshairs L: Toggle the legend D: Toggle die centers """ # TODO: Decide if I want to move this to a class attribute keycodes = {wx.WXK_HOME: self.zoom_fill, # "Home 79: self.toggle_outline, # "O" 67: self.toggle_crosshairs, # "C" 76: self.toggle_legend, # "L" 68: self.toggle_die_centers, # "D" } # print("panel event!") key = event.GetKeyCode() if key in keycodes.keys(): keycodes[key]() else: # print("KeyCode: {}".format(key)) pass
Example #20
Source File: wm_core.py From wafer_map with GNU General Public License v3.0 | 5 votes |
def _bind_events(self): """ Bind panel and canvas events. Note that key-down is bound again - this allws hotkeys to work even if the main Frame, which defines hotkeys in menus, is not present. wx sents the EVT_KEY_DOWN up the chain and, if the Frame and hotkeys are present, executes those instead. At least I think that's how that works... See http://wxpython.org/Phoenix/docs/html/events_overview.html for more info. """ # Canvas Events self.canvas.Bind(FloatCanvas.EVT_MOTION, self.on_mouse_move) self.canvas.Bind(FloatCanvas.EVT_MOUSEWHEEL, self.on_mouse_wheel) self.canvas.Bind(FloatCanvas.EVT_MIDDLE_DOWN, self.on_mouse_middle_down) self.canvas.Bind(FloatCanvas.EVT_MIDDLE_UP, self.on_mouse_middle_up) self.canvas.Bind(wx.EVT_PAINT, self._on_first_paint) # XXX: Binding the EVT_LEFT_DOWN seems to cause Issue #24. # What seems to happen is: If I bind EVT_LEFT_DOWN, then the # parent panel or application can't set focus to this # panel, which prevents the EVT_MOUSEWHEEL event from firing # properly. # self.canvas.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_left_down) # self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.on_mouse_right_down) # self.canvas.Bind(wx.EVT_LEFT_UP, self.on_mouse_left_up) # self.canvas.Bind(wx.EVT_KEY_DOWN, self._on_key_down) # This is supposed to fix flicker on mouse move, but it doesn't work. # self.Bind(wx.EVT_ERASE_BACKGROUND, None) # Panel Events self.Bind(csel.EVT_COLOURSELECT, self.on_color_change)
Example #21
Source File: backend_wx.py From coffeegrindsize with MIT License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)
Example #22
Source File: backend_wx.py From CogAlg with MIT License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)
Example #23
Source File: AboutDialog.py From EventGhost with GNU General Public License v2.0 | 4 votes |
def __init__(self, parent): from eg.WinApi.SystemInformation import GetWindowsVersionString buildTime = time.strftime( Text.CreationDate, time.gmtime(eg.Version.buildTime) ).decode(eg.systemEncoding) totalMemory = GetRam()[0] pythonVersion = "%d.%d.%d %s %d" % tuple(sys.version_info) if is_stackless: pythonVersion = "Stackless Python " + pythonVersion self.sysInfos = [ "Software", ("Program Version", eg.Version.string), ("Build Time", buildTime), ("Python Version", pythonVersion), ("wxPython Version", wx.VERSION_STRING), "\nSystem", ("Operating System", GetWindowsVersionString()), ("CPU", GetCpuName()), ("RAM", "%s GB" % totalMemory), "\nUSB-Devices", ] devices = eg.WinUsb.ListDevices() for hardwareId in sorted(devices.keys()): device = devices[hardwareId] self.sysInfos.append((device.name, device.hardwareId)) lines = [] for line in self.sysInfos: if isinstance(line, tuple): lines.append('<tr><td>%s:</td><td>%s</td></tr>' % line) else: lines.append('</table><p><b>%s</b><br><table>' % line) lines.append('</table>') page = "\n".join(lines) HtmlPanel.__init__(self, parent, page) self.htmlWindow.Bind(wx.EVT_RIGHT_DOWN, self.OnRightClick) self.htmlWindow.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) contextMenu = wx.Menu() contextMenu.Append(wx.ID_COPY, eg.text.MainFrame.Menu.Copy) self.Bind(wx.EVT_MENU, self.OnCmdCopy, id=wx.ID_COPY) self.contextMenu = contextMenu
Example #24
Source File: PDFoutline.py From PyMuPDF-Utilities with GNU General Public License v3.0 | 4 votes |
def __init__(self, parent): gridlib.Grid.__init__(self, parent, -1) table = PDFTable() # initialize table self.Bind(wx.EVT_IDLE, self.OnIdle) self.do_title = False # idling event: autosize title column self.bookmark_page = 0 # idling event: redisplay PDF image self.bookmark = -1 # idling event: bookmark position change self.bookmark_row = 0 # idling event: row number #============================================================================== # announce table to Grid # 'True' = enable Grid to manage the table (destroy, etc.) #============================================================================== self.SetTable(table, True) #============================================================================== # set font, width, alignment in the grid #============================================================================== self.SetDefaultCellFont(wx.Font(wx.NORMAL_FONT.GetPointSize(), 70, 90, 90, False, "DejaVu Sans Mono")) # center columns (indent level) ct_al1 = gridlib.GridCellAttr() ct_al1.SetAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER) self.SetColAttr(0, ct_al1) self.SetColAttr(3, ct_al1) # page number right aligned re_al1 = gridlib.GridCellAttr() re_al1.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER) self.SetColAttr(2, re_al1) #============================================================================== # Enable Row moving #============================================================================== gridmovers.GridRowMover(self) self.Bind(gridmovers.EVT_GRID_ROW_MOVE, self.OnRowMove) self.Bind(gridlib.EVT_GRID_LABEL_LEFT_DCLICK, self.OnRowDup) self.Bind(gridlib.EVT_GRID_LABEL_LEFT_CLICK, self.OnRowDel) self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnCellDClick) self.Bind(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnCellClick) self.Bind(gridlib.EVT_GRID_CELL_CHANGING, self.OnCellChanging) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) #============================================================================== # Event Method: handle key press events - only navigation tasks performed #==============================================================================
Example #25
Source File: backend_wx.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)
Example #26
Source File: backend_wx.py From GraphicDesignPatternByPython with MIT License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)
Example #27
Source File: backend_wx.py From Mastering-Elasticsearch-7.0 with MIT License | 4 votes |
def __init__(self, parent, id, figure): """ Initialise a FigureWx instance. - Initialise the FigureCanvasBase and wxPanel parents. - Set event handlers for: EVT_SIZE (Resize event) EVT_PAINT (Paint event) """ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) l, b, w, h = figure.bbox.bounds w = math.ceil(w) h = math.ceil(h) wx.Panel.__init__(self, parent, id, size=wx.Size(w, h)) # Create the drawing bitmap self.bitmap = wx.Bitmap(w, h) DEBUG_MSG("__init__() - bitmap w:%d h:%d" % (w, h), 2, self) # TODO: Add support for 'point' inspection and plot navigation. self._isDrawn = False self.Bind(wx.EVT_SIZE, self._onSize) self.Bind(wx.EVT_PAINT, self._onPaint) self.Bind(wx.EVT_KEY_DOWN, self._onKeyDown) self.Bind(wx.EVT_KEY_UP, self._onKeyUp) self.Bind(wx.EVT_RIGHT_DOWN, self._onRightButtonDown) self.Bind(wx.EVT_RIGHT_DCLICK, self._onRightButtonDClick) self.Bind(wx.EVT_RIGHT_UP, self._onRightButtonUp) self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) self.Bind(wx.EVT_LEFT_DOWN, self._onLeftButtonDown) self.Bind(wx.EVT_LEFT_DCLICK, self._onLeftButtonDClick) self.Bind(wx.EVT_LEFT_UP, self._onLeftButtonUp) self.Bind(wx.EVT_MOTION, self._onMotion) self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeave) self.Bind(wx.EVT_ENTER_WINDOW, self._onEnter) # Add middle button events self.Bind(wx.EVT_MIDDLE_DOWN, self._onMiddleButtonDown) self.Bind(wx.EVT_MIDDLE_DCLICK, self._onMiddleButtonDClick) self.Bind(wx.EVT_MIDDLE_UP, self._onMiddleButtonUp) self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, self._onCaptureLost) self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self._onCaptureLost) self.SetBackgroundStyle(wx.BG_STYLE_PAINT) # Reduce flicker. self.SetBackgroundColour(wx.WHITE)