Python wx.WXK_LEFT Examples

The following are 16 code examples of wx.WXK_LEFT(). 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: refinement.py    From DeepLabCut with GNU Lesser General Public License v3.0 6 votes vote down vote up
def OnKeyPressed(self, event=None):
        if event.GetKeyCode() == wx.WXK_RIGHT:
            self.nextImage(event=None)
        elif event.GetKeyCode() == wx.WXK_LEFT:
            self.prevImage(event=None)
        elif event.GetKeyCode() == wx.WXK_BACK:
            pos_abs = event.GetPosition()
            inv = self.axes.transData.inverted()
            pos_rel = list(inv.transform(pos_abs))
            pos_rel[1] = (
                self.axes.get_ylim()[0] - pos_rel[1]
            )  # Recall y-axis is inverted
            i = np.nanargmin(
                [self.calc_distance(*dp.point.center, *pos_rel) for dp in self.drs]
            )
            closest_dp = self.drs[i]
            msg = wx.MessageBox(
                "Do you want to remove the label %s ?" % closest_dp.bodyParts,
                "Remove!",
                wx.YES_NO | wx.ICON_WARNING,
            )
            if msg == 2:
                closest_dp.delete_data() 
Example #2
Source File: multiple_individuals_refinement_toolbox.py    From DeepLabCut with GNU Lesser General Public License v3.0 6 votes vote down vote up
def OnKeyPressed(self, event=None):
        if event.GetKeyCode() == wx.WXK_RIGHT:
            self.nextImage(event=None)
        elif event.GetKeyCode() == wx.WXK_LEFT:
            self.prevImage(event=None)
        elif event.GetKeyCode() == wx.WXK_BACK:
            pos_abs = event.GetPosition()
            inv = self.axes.transData.inverted()
            pos_rel = list(inv.transform(pos_abs))
            pos_rel[1] = (
                self.axes.get_ylim()[0] - pos_rel[1]
            )  # Recall y-axis is inverted
            i = np.nanargmin(
                [self.calc_distance(*dp.point.center, *pos_rel) for dp in self.drs]
            )
            closest_dp = self.drs[i]
            msg = wx.MessageBox(
                f"Do you want to remove the label {closest_dp.individual_name}:{closest_dp.bodyParts}?",
                "Remove!",
                wx.YES_NO | wx.ICON_WARNING,
            )
            if msg == 2:
                closest_dp.delete_data() 
Example #3
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def onFrameCharHook(self, event):
        keyCode = event.GetKeyCode()
        if keyCode == wx.WXK_F4:
            if event.AltDown():
                self.destroyMenu()
        elif keyCode == wx.WXK_RETURN or keyCode == wx.WXK_NUMPAD_ENTER:
            self.GoTo()
        elif keyCode == wx.WXK_RIGHT or keyCode == wx.WXK_NUMPAD_RIGHT:
            self.MoveCursor(1)
        elif keyCode == wx.WXK_ESCAPE:
            self.destroyMenu()
        elif keyCode == wx.WXK_UP or keyCode == wx.WXK_NUMPAD_UP:
            self.Turn(1)
        elif keyCode == wx.WXK_DOWN or keyCode == wx.WXK_NUMPAD_DOWN:
            self.Turn(-1)
        elif keyCode == wx.WXK_LEFT or keyCode == wx.WXK_NUMPAD_LEFT:
            self.MoveCursor(-1)
        else:
            event.Skip() 
Example #4
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def onFrameCharHook(self, event):
        keyCode = event.GetKeyCode()
        if keyCode == wx.WXK_F4:
            if event.AltDown():
                self.destroyMenu()
        elif keyCode == wx.WXK_RETURN or keyCode == wx.WXK_NUMPAD_ENTER:
            self.DefaultAction()
        elif keyCode == wx.WXK_RIGHT or keyCode == wx.WXK_NUMPAD_RIGHT:
            self.DefaultAction()
        elif keyCode == wx.WXK_ESCAPE:
            self.destroyMenu()
        elif keyCode == wx.WXK_UP or keyCode == wx.WXK_NUMPAD_UP:
            self.menuGridCtrl.MoveCursor(-1)
        elif keyCode == wx.WXK_DOWN or keyCode == wx.WXK_NUMPAD_DOWN:
            self.menuGridCtrl.MoveCursor(1)
        elif keyCode == wx.WXK_LEFT or keyCode == wx.WXK_NUMPAD_LEFT:
            if len(self.oldMenu) > 0:
                self.menu, ix = self.oldMenu.pop()
                wx.CallAfter(self.UpdateMenu,ix)
            else:
                self.destroyMenu()
        else:
            event.Skip() 
Example #5
Source File: TextCtrlAutoComplete.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def OnKeyDown(self, event):
        """ Do some work when the user press on the keys:
            up and down: move the cursor
        """
        keycode = event.GetKeyCode()
        if keycode in [wx.WXK_DOWN, wx.WXK_UP]:
            self.PopupListBox()
            if keycode == wx.WXK_DOWN:
                self.listbox.MoveSelection(1)
            else:
                self.listbox.MoveSelection(-1)
        elif keycode in [wx.WXK_LEFT, wx.WXK_RIGHT, wx.WXK_RETURN] and self.listbox is not None:
            selected = self.listbox.GetSelection()
            if selected != "":
                self.SetValueFromSelected(selected)
            else:
                event.Skip()
        elif event.GetKeyCode() == wx.WXK_ESCAPE:
            self.DismissListBox()
        else:
            event.Skip() 
Example #6
Source File: multiple_individuals_labeling_toolbox.py    From DeepLabCut with GNU Lesser General Public License v3.0 5 votes vote down vote up
def OnKeyPressed(self, event=None):
        if event.GetKeyCode() == wx.WXK_RIGHT:
            self.nextImage(event=None)
        elif event.GetKeyCode() == wx.WXK_LEFT:
            self.prevImage(event=None)
        elif event.GetKeyCode() == wx.WXK_DOWN:
            self.nextLabel(event=None)
        elif event.GetKeyCode() == wx.WXK_UP:
            self.previousLabel(event=None)
        elif event.GetKeyCode() == wx.WXK_BACK:
            pos_abs = event.GetPosition()
            inv = self.axes.transData.inverted()
            pos_rel = list(inv.transform(pos_abs))
            pos_rel[1] = (
                self.axes.get_ylim()[0] - pos_rel[1]
            )  # Recall y-axis is inverted
            i = np.nanargmin(
                [self.calc_distance(*dp.point.center, *pos_rel) for dp in self.drs]
            )
            closest_dp = self.drs[i]
            msg = wx.MessageBox(
                f"Do you want to remove the label {closest_dp.individual_names}:{closest_dp.bodyParts}?",
                "Remove!",
                wx.YES_NO | wx.ICON_WARNING,
            )
            if msg == 2:
                closest_dp.delete_data()
                self.buttonCounter[closest_dp.individual_names].remove(
                    closest_dp.bodyParts
                ) 
Example #7
Source File: labeling_toolbox.py    From DeepLabCut with GNU Lesser General Public License v3.0 5 votes vote down vote up
def OnKeyPressed(self, event=None):
        if event.GetKeyCode() == wx.WXK_RIGHT:
            self.nextImage(event=None)
        elif event.GetKeyCode() == wx.WXK_LEFT:
            self.prevImage(event=None)
        elif event.GetKeyCode() == wx.WXK_DOWN:
            self.nextLabel(event=None)
        elif event.GetKeyCode() == wx.WXK_UP:
            self.previousLabel(event=None)
        elif event.GetKeyCode() == wx.WXK_BACK:
            pos_abs = event.GetPosition()
            inv = self.axes.transData.inverted()
            pos_rel = list(inv.transform(pos_abs))
            pos_rel[1] = (
                self.axes.get_ylim()[0] - pos_rel[1]
            )  # Recall y-axis is inverted
            i = np.nanargmin(
                [self.calc_distance(*dp.point.center, *pos_rel) for dp in self.drs]
            )
            closest_dp = self.drs[i]
            msg = wx.MessageBox(
                "Do you want to remove the label %s ?" % closest_dp.bodyParts,
                "Remove!",
                wx.YES_NO | wx.ICON_WARNING,
            )
            if msg == 2:
                closest_dp.delete_data()
                self.buttonCounter.remove(
                    self.bodyparts.index(closest_dp.bodyParts)
                ) 
Example #8
Source File: main.py    From wxGlade with MIT License 5 votes vote down vote up
def on_char(self, event):
        key = (event.GetKeyCode(), event.GetModifiers())    # modifiers: 1,2,4 for Alt, Ctrl, Shift

        focused = self.FindFocus()
        if not focused or not focused.Id in self._id_to_coordinate:
            return event.Skip()

        row, col = self._id_to_coordinate[focused.Id]
        new_row = new_col = None
        if key[0]==wx.WXK_UP:
            if row>0: new_row = row-1
        elif key[0]==wx.WXK_DOWN:
            if row < len(self._ids_by_row)-1: new_row = row+1
        elif key[0]==wx.WXK_LEFT:
            if col>0: new_col = col-1
        elif key[0]==wx.WXK_RIGHT:
            if col < len(self._ids_by_row[row])-1: new_col = col+1
        elif key[0]==wx.WXK_HOME:
            new_col = 0
        elif key[0]==wx.WXK_END:
            new_col = len(self._ids_by_row[row])-1
        elif key[0]==wx.WXK_PAGEUP:
            new_row = 0
        elif key[0]==wx.WXK_PAGEDOWN:
            new_row = len(self._ids_by_row)-1
        elif (ord("A") <= key[0] <= ord("Z")) and chr(key[0]) in misc.palette_hotkeys:
            section = misc.palette_hotkeys[chr(key[0])]
            new_row = self._section_to_row[section]
            new_col = 0
        else:
            return event.Skip()

        if new_row is None and new_col is None:
            # limits hit
            wx.Bell()
        else:
            if new_col is None: new_col = min(col, len(self._ids_by_row[new_row])-1)
            if new_row is None: new_row = row
            focus = self.FindWindowById(self._ids_by_row[new_row][new_col])
            if focus: focus.SetFocus() 
Example #9
Source File: tree.py    From wxGlade with MIT License 5 votes vote down vote up
def on_char(self, event):
        "called from main: start label editing on F2; skip events while editing"
        keycode = event.GetKeyCode()
        if keycode==wx.WXK_F2 and self.cur_widget and self.cur_widget._label_editable():
            # start label editing
            self.EditLabel( self.cur_widget.item )
            return True
        if isinstance(self.FindFocus(), wx.TextCtrl):
            # currently editing
            event.Skip()
            return True
        if keycode in (wx.WXK_UP, wx.WXK_DOWN, wx.WXK_LEFT, wx.WXK_RIGHT):
            event.Skip()
            return True
        return False 
Example #10
Source File: PouInstanceVariablesPanel.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def OnVariablesListKeyDown(self, event):
        keycode = event.GetKeyCode()
        if keycode != wx.WXK_LEFT:
            event.Skip() 
Example #11
Source File: CellEditor.py    From bookhub with MIT License 5 votes vote down vote up
def __init__(self, acceptableChars="0123456789+-"):
        wx.PyValidator.__init__(self)
        self.Bind(wx.EVT_CHAR, self._OnChar)
        self.acceptableChars = acceptableChars
        self.acceptableCodes = [ord(x) for x in self.acceptableChars]
        stdEditKeys = [wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER, wx.WXK_ESCAPE, wx.WXK_CANCEL,
                       wx.WXK_TAB, wx.WXK_BACK, wx.WXK_DELETE, wx.WXK_HOME, wx.WXK_END,
                       wx.WXK_LEFT, wx.WXK_RIGHT]
        self.acceptableCodes.extend(stdEditKeys) 
Example #12
Source File: ObjectListView.py    From bookhub with MIT License 5 votes vote down vote up
def _HandleChar(self, evt):

        if not self.IsCellEditing() and self.handleStandardKeys:
            if (evt.GetKeyCode() == wx.WXK_LEFT):
                self.CollapseAll(self.GetSelectedGroups())
                return
            if (evt.GetKeyCode() == wx.WXK_RIGHT):
                self.ExpandAll(self.GetSelectedGroups())
                return

        FastObjectListView._HandleChar(self, evt) 
Example #13
Source File: geometry_viewer.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def OnKeyDown(self, event):
        key = event.GetUnicodeKey()
        if key == wx.WXK_NONE:
            key = event.GetKeyCode()
        dxs = {wx.WXK_LEFT: -1, wx.WXK_RIGHT: +1, wx.WXK_UP: 0, wx.WXK_DOWN: 0}
        dys = {wx.WXK_LEFT: 0, wx.WXK_RIGHT: 0, wx.WXK_UP: +1, wx.WXK_DOWN: -1}

        if key in dxs:
            dx = dxs[key]
            dy = dys[key]
            if event.ShiftDown():
                scale = 0.1
            else:
                scale = 1.0
            self.do_Step(dx, dy, scale) 
Example #14
Source File: viewer.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def OnKeyDown(self, event):
        key = event.GetUnicodeKey()
        if key == wx.WXK_NONE:
            key = event.GetKeyCode()
        dxs = {wx.WXK_LEFT: -1, wx.WXK_RIGHT: +1, wx.WXK_UP: 0, wx.WXK_DOWN: 0}
        dys = {wx.WXK_LEFT: 0, wx.WXK_RIGHT: 0, wx.WXK_UP: +1, wx.WXK_DOWN: -1}

        if key in dxs:
            dx = dxs[key]
            dy = dys[key]
            if event.ShiftDown():
                scale = 0.1
            else:
                scale = 1.0
            self.do_Step(dx, dy, scale) 
Example #15
Source File: menubar.py    From wxGlade with MIT License 4 votes vote down vote up
def on_char(self, event):
        # keyboard navigation: up/down arrows
        focus = self.FindFocus()
        k = event.GetKeyCode()
        if k==wx.WXK_TAB:
            if focus is self.type:
                self.label.SetFocus()
            else:
                event.Skip()
            return

        if k in (wx.WXK_DOWN, wx.WXK_UP) and focus is self.type:
            event.Skip()
            return

        if event.AltDown():
            if k==wx.WXK_RETURN or k==ord("O"):
                self.EndModal(wx.ID_OK)
                return
            if k==ord("C"):
                self.EndModal(wx.ID_CANCEL)
                return

        if event.ControlDown() and k==wx.WXK_RETURN:
            self.EndModal(wx.ID_OK)
            return

        if k==wx.WXK_RETURN:  # ignore Enter key
            return
        if k==wx.WXK_DOWN:
            if event.AltDown():
                self.move_item_down(event)
            else:
                if self.selected_index+1 < self.items.GetItemCount():
                    self._select_item(self.selected_index+1)
                else:
                    wx.Bell()
            return
        if k==wx.WXK_UP:
            if event.AltDown():
                self.move_item_up(event)
            else:
                if self.selected_index>0:
                    self._select_item(self.selected_index-1)
                else:
                    wx.Bell()
            return
        if k==wx.WXK_RIGHT and event.AltDown():
            self.move_item_right(event)
            return
        if k==wx.WXK_LEFT and event.AltDown():
            self.move_item_left(event)
            return
        event.Skip() 
Example #16
Source File: LDViewer.py    From OpenPLC_Editor with GNU General Public License v3.0 4 votes vote down vote up
def OnChar(self, event):
        if self.GetDrawingMode() == FREEDRAWING_MODE:
            Viewer.OnChar(self, event)
        else:
            xpos, ypos = self.GetScrollPos(wx.HORIZONTAL), self.GetScrollPos(wx.VERTICAL)
            xmax = self.GetScrollRange(wx.HORIZONTAL) - self.GetScrollThumb(wx.HORIZONTAL)
            ymax = self.GetScrollRange(wx.VERTICAL) - self.GetScrollThumb(wx.VERTICAL)
            keycode = event.GetKeyCode()
            if keycode == wx.WXK_DELETE and self.SelectedElement:
                if self.IsBlock(self.SelectedElement):
                    self.SelectedElement.Delete()
                elif self.IsWire(self.SelectedElement):
                    self.DeleteWire(self.SelectedElement)
                elif isinstance(self.SelectedElement, Graphic_Group):
                    all_wires = True
                    for element in self.SelectedElement.GetElements():
                        all_wires &= self.IsWire(element)
                    if all_wires:
                        self.DeleteWire(self.SelectedElement)
                    else:
                        self.SelectedElement.Delete()
                self.RefreshBuffer()
                self.RefreshScrollBars()
                self.Refresh(False)
            elif keycode == wx.WXK_LEFT:
                if event.ControlDown() and event.ShiftDown():
                    self.Scroll(0, ypos)
                elif event.ControlDown():
                    self.Scroll(max(0, xpos - 1), ypos)
            elif keycode == wx.WXK_RIGHT:
                if event.ControlDown() and event.ShiftDown():
                    self.Scroll(xmax, ypos)
                elif event.ControlDown():
                    self.Scroll(min(xpos + 1, xmax), ypos)
            elif keycode == wx.WXK_UP:
                if event.ControlDown() and event.ShiftDown():
                    self.Scroll(xpos, 0)
                elif event.ControlDown():
                    self.Scroll(xpos, max(0, ypos - 1))
            elif keycode == wx.WXK_DOWN:
                if event.ControlDown() and event.ShiftDown():
                    self.Scroll(xpos, ymax)
                elif event.ControlDown():
                    self.Scroll(xpos, min(ypos + 1, ymax))
            else:
                event.Skip()

    # -------------------------------------------------------------------------------
    #                  Model adding functions from Drop Target
    # -------------------------------------------------------------------------------