Python wx.WXK_BACK Examples
The following are 10
code examples of wx.WXK_BACK().
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 |
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 |
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: multiple_individuals_labeling_toolbox.py From DeepLabCut with GNU Lesser General Public License v3.0 | 5 votes |
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 #4
Source File: labeling_toolbox.py From DeepLabCut with GNU Lesser General Public License v3.0 | 5 votes |
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 #5
Source File: ConfigEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def OnVariablesFilterKeyDown(self, event): if self.VariablesFilterFirstCharacter: keycode = event.GetKeyCode() if keycode not in [wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER]: self.VariablesFilterFirstCharacter = False if keycode not in NAVIGATION_KEYS: self.VariablesFilter.SetValue("") if keycode not in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE, wx.WXK_BACK]: event.Skip() else: event.Skip()
Example #6
Source File: ConfigEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 5 votes |
def OnNodesFilterKeyDown(self, event): if self.NodesFilterFirstCharacter: keycode = event.GetKeyCode() if keycode not in [wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER]: self.NodesFilterFirstCharacter = False if keycode not in NAVIGATION_KEYS: self.NodesFilter.SetValue("") if keycode not in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE, wx.WXK_BACK]: event.Skip() else: event.Skip()
Example #7
Source File: CellEditor.py From bookhub with MIT License | 5 votes |
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 #8
Source File: trelby.py From trelby with GNU General Public License v2.0 | 4 votes |
def cmdSpeedTest(self, cs): import undo self.speedTestUndo = [] def testUndoFullCopy(): u = undo.FullCopy(self.sp) u.setAfter(self.sp) self.speedTestUndo.append(u) def testReformatAll(): self.sp.reformatAll() def testPaginate(): self.sp.paginate() def testUpdateScreen(): self.updateScreen() self.Update() def testAddRemoveChar(): self.OnKeyChar(util.MyKeyEvent(ord("a"))) self.OnKeyChar(util.MyKeyEvent(wx.WXK_BACK)) def testDeepcopy(): copy.deepcopy(self.sp) # contains (name, func) tuples tests = [] for name, var in locals().iteritems(): if callable(var): tests.append((name, var)) tests.sort() count = 100 print "-" * 20 for name, func in tests: t = time.time() for i in xrange(count): func() t = time.time() - t print "%.5f seconds per %s" % (t / count, name) print "-" * 20 # it's annoying having the program ask if you want to save after # running these tests, so pretend the script hasn't changed self.sp.markChanged(False)
Example #9
Source File: CodeFileEditor.py From OpenPLC_Editor with GNU General Public License v3.0 | 4 votes |
def OnKeyPressed(self, event): if self.CallTipActive(): self.CallTipCancel() key = event.GetKeyCode() current_pos = self.GetCurrentPos() selected = self.GetSelection() text_selected = selected[0] != selected[1] # Test if caret is before Windows like new line text = self.GetText() if current_pos < len(text) and ord(text[current_pos]) == 13: newline_size = 2 else: newline_size = 1 # Disable to type any character in section header lines if self.GetLineState(self.LineFromPosition(current_pos)) and \ not text_selected and \ key not in NAVIGATION_KEYS + [wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER]: return # Disable to delete line between code and header lines elif (self.GetCurLine()[0].strip() != "" and not text_selected and (key == wx.WXK_BACK and self.GetLineState(self.LineFromPosition(max(0, current_pos - 1))) or key in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE] and self.GetLineState(self.LineFromPosition(min(len(text), current_pos + newline_size))))): return elif key == 32 and event.ControlDown(): # Tips if event.ShiftDown(): pass # Code completion else: self.AutoCompSetIgnoreCase(False) # so this needs to match keywords = self.KEYWORDS + [var["Name"] for var in self.Controler.GetVariables()] keywords.sort() self.AutoCompShow(0, " ".join(keywords)) else: event.Skip()
Example #10
Source File: ObjectListView.py From bookhub with MIT License | 4 votes |
def _HandleTypingEvent(self, evt): """ """ if self.GetItemCount() == 0 or self.GetColumnCount() == 0: return False if evt.GetModifiers() != 0 and evt.GetModifiers() != wx.MOD_SHIFT: return False if evt.GetKeyCode() > wx.WXK_START: return False if evt.GetKeyCode() in (wx.WXK_BACK, wx.WXK_DELETE): self.searchPrefix = u"" return True # On which column are we going to compare values? If we should search on the # sorted column, and there is a sorted column and it is searchable, we use that # one, otherwise we fallback to the primary column if self.typingSearchesSortColumn and self.GetSortColumn() and self.GetSortColumn().isSearchable: searchColumn = self.GetSortColumn() else: searchColumn = self.GetPrimaryColumn() # On Linux, GetUnicodeKey() always returns 0 -- on my 2.8.7.1 (gtk2-unicode) if evt.GetUnicodeKey() == 0: uniChar = chr(evt.GetKeyCode()) else: uniChar = unichr(evt.GetUnicodeKey()) if uniChar not in string.printable: return False # On Linux, evt.GetTimestamp() isn't reliable so use time.time() instead timeNow = time.time() if (timeNow - self.whenLastTypingEvent) > self.SEARCH_KEYSTROKE_DELAY: self.searchPrefix = uniChar else: self.searchPrefix += uniChar self.whenLastTypingEvent = timeNow #self.__rows = 0 self._FindByTyping(searchColumn, self.searchPrefix) #print "Considered %d rows in %2f secs" % (self.__rows, time.time() - timeNow) return True