我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用wx.NOT_FOUND。
def _insert(self, x, y, text): """ Insert text at given x, y coordinates --- used with drag-and-drop. """ # Clean text. import string text = filter(lambda x: x in (string.letters + string.digits + string.punctuation + ' '), text) # Find insertion point. index, flags = self.HitTest((x, y)) if index == wx.NOT_FOUND: if flags & wx.LIST_HITTEST_NOWHERE: index = self.GetItemCount() else: return # Get bounding rectangle for the item the user is dropping over. rect = self.GetItemRect(index) # If the user is dropping into the lower half of the rect, we want to insert _after_ this item. if y > rect.y + rect.height/2: index += 1 self.InsertStringItem(index, text)
def redraw(self): column_index1 = self.combo_box1.GetSelection() if column_index1 != wx.NOT_FOUND and column_index1 != 0: # subtract one to remove the neutral selection index column_index1 -= 1 df = self.df_list_ctrl.get_filtered_df() if len(df) > 0: self.axes.clear() column = df.iloc[:, column_index1] is_string_col = column.dtype == np.object and isinstance(column.values[0], str) if is_string_col: value_counts = column.value_counts().sort_index() value_counts.plot(kind='bar', ax=self.axes) else: self.axes.hist(column.values, bins=100) self.canvas.draw()
def redraw(self): column_index1 = self.combo_box1.GetSelection() column_index2 = self.combo_box2.GetSelection() if column_index1 != wx.NOT_FOUND and column_index1 != 0 and \ column_index2 != wx.NOT_FOUND and column_index2 != 0: # subtract one to remove the neutral selection index column_index1 -= 1 column_index2 -= 1 df = self.df_list_ctrl.get_filtered_df() # It looks like using pandas dataframe.plot causes something weird to # crash in wx internally. Therefore we use plain axes.plot functionality. # column_name1 = self.columns[column_index1] # column_name2 = self.columns[column_index2] # df.plot(kind='scatter', x=column_name1, y=column_name2) if len(df) > 0: self.axes.clear() self.axes.plot(df.iloc[:, column_index1].values, df.iloc[:, column_index2].values, 'o', clip_on=False) self.canvas.draw()
def onPhoneNumberChange(self): if self.just_coutry_selected: self.just_coutry_selected = False return if not self.wxapp.phonenum: return cIndex = findCountry(self.wxapp.phonenum[:6]) if cIndex != -1: self.country_box.SetSelection(cIndex) self.wxapp.phonecountry = countries[cIndex] self.dialnumber.UpdateLabel("+%s" % self.wxapp.phonenum) else: self.country_box.SetSelection(wx.NOT_FOUND) self.wxapp.phonecountry = ('', 'null', '', '') self.dialnumber.UpdateLabel("%s" % self.wxapp.phonenum) return
def configFilter(self, event=None): filterChoiceIndex = self.chainListBox.GetSelection() if self.filterConfigPanel is not None: self.filterConfigPanel.Destroy() if filterChoiceIndex != wx.NOT_FOUND: flt = self.filterChain.getFilter(filterChoiceIndex) self.filterConfigPanel = flt.genConfigPanel(parent=self, pg=self) self.configSizer.Add(self.filterConfigPanel, proportion=1, flag=wx.EXPAND) else: self.filterConfigPanel = None self.Layout()
def RefreshNameList(self): """ Called to refresh names in name list box """ # Get variable class to select POU variable applicable var_class = VARIABLE_CLASSES_DICT_REVERSE[ self.Class.GetStringSelection()] # Refresh names in name list box by selecting variables in POU variables # list that can be applied to variable class self.VariableName.Clear() for name, (var_type, value_type) in self.VariableList.iteritems(): if var_type != "Input" or var_class == INPUT: self.VariableName.Append(name) # Get variable expression and select corresponding value in name list # box if it exists selected = self.Expression.GetValue() if selected != "" and self.VariableName.FindString(selected) != wx.NOT_FOUND: self.VariableName.SetStringSelection(selected) else: self.VariableName.SetSelection(wx.NOT_FOUND) # Disable name list box if no name present inside self.VariableName.Enable(self.VariableName.GetCount() > 0)
def OnDrawItem(self, dc, rect, item, flags): if item == wx.NOT_FOUND: # painting the control, but there is no valid item selected yet return font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, 'Segoe UI') dc.SetFont(font) if flags == 3: margin = 3 else: margin = 1 r = wx.Rect(*rect) # make a copy r.Deflate(margin, margin) tam = self.OnMeasureItem(item)-2 dc.SetPen(wx.Pen("grey", style=wx.TRANSPARENT)) color_name = self.GetString(item) color = self.colors.get(color_name) if not color: color = wx.NamedColour(color_name) dc.SetBrush(wx.Brush(color)) dc.DrawRectangle(r.x, r.y, tam, tam) dc.DrawText(self.GetString(item), r.x + tam + 2, r.y)
def _on_right_click(self, event): """ Copies a cell into clipboard on right click. Unfortunately, determining the clicked column is not straightforward. This appraoch is inspired by the TextEditMixin in: /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/lib/mixins/listctrl.py More references: - http://wxpython-users.1045709.n5.nabble.com/Getting-row-col-of-selected-cell-in-ListCtrl-td2360831.html - https://groups.google.com/forum/#!topic/wxpython-users/7BNl9TA5Y5U - https://groups.google.com/forum/#!topic/wxpython-users/wyayJIARG8c """ if self.HitTest(event.GetPosition()) != wx.NOT_FOUND: x, y = event.GetPosition() row, flags = self.HitTest((x, y)) col_locs = [0] loc = 0 for n in range(self.GetColumnCount()): loc = loc + self.GetColumnWidth(n) col_locs.append(loc) scroll_pos = self.GetScrollPos(wx.HORIZONTAL) # this is crucial step to get the scroll pixel units unit_x, unit_y = self.GetMainWindow().GetScrollPixelsPerUnit() col = bisect(col_locs, x + scroll_pos * unit_x) - 1 value = self.df.iloc[row, col] # print(row, col, scroll_pos, value) clipdata = wx.TextDataObject() clipdata.SetText(str(value)) wx.TheClipboard.Open() wx.TheClipboard.SetData(clipdata) wx.TheClipboard.Close()
def on_left_down(self, event): if self.HitTest(event.GetPosition()) != wx.NOT_FOUND: index = self.HitTest(event.GetPosition()) self.selected_items[index] = not self.selected_items[index] # doesn't really work to update selection direclty (focus issues) # instead we wait for the EVT_LISTBOX event and fix the selection # there... # self.update_selection() # TODO: we could probably use wx.CallAfter event.Skip()
def on_right_down(self, event): if self.HitTest(event.GetPosition()) != wx.NOT_FOUND: index = self.HitTest(event.GetPosition()) self.drag_start_index = index
def on_move(self, event): if self.drag_start_index is not None: if self.HitTest(event.GetPosition()) != wx.NOT_FOUND: index = self.HitTest(event.GetPosition()) if self.drag_start_index != index: self.swap(self.drag_start_index, index) self.drag_start_index = index
def HitTest(self, pt): """ Returns the index of the tab at the specified position or ``wx.NOT_FOUND`` if ``None``, plus the flag style of :meth:`~ImageContainerBase.HitTest`. :param `pt`: an instance of :class:`Point`, to test for hits. :return: The index of the tab at the specified position plus the hit test flag, which can be one of the following bits: ====================== ======= ================================ HitTest Flags Value Description ====================== ======= ================================ ``IMG_OVER_IMG`` 0 The mouse is over the tab icon ``IMG_OVER_PIN`` 1 The mouse is over the pin button ``IMG_OVER_EW_BORDER`` 2 The mouse is over the east-west book border ``IMG_NONE`` 3 Nowhere ====================== ======= ================================ """ style = self.GetParent().GetAGWWindowStyleFlag() for i in reversed( xrange(len(self._pagesInfoVec)) ) : if self._pagesInfoVec[i].GetPosition() == wx.Point(-1, -1): break # For Web Hover style, we test the TextRect if not self.HasAGWFlag(INB_WEB_HILITE): buttonRect = wx.RectPS(self._pagesInfoVec[i].GetPosition(), self._pagesInfoVec[i].GetSize()) else: buttonRect = self._pagesInfoVec[i].GetTextRect() if buttonRect.Contains(pt): return i, IMG_OVER_IMG return -1, IMG_NONE
def pushFilter(self, event): filterChoiceIndex = self.filterListBox.GetSelection() if filterChoiceIndex == wx.NOT_FOUND: wx.LogError('Page %s: No filter selected.' % self.name) return filterChoice = self.filterListBox.GetString(filterChoiceIndex) self.chainListBox.Append(filterChoice) self.filterChain.push(filters.filterChoices[filterChoice])
def SetValues(self, values): """ Set default variable parameters @param values: Variable parameters values """ # Get class parameter value var_class = values.get("class", None) if var_class is not None: # Set class selected in class combo box self.Class.SetStringSelection(VARIABLE_CLASSES_DICT[var_class]) # Refresh names in name list box according to var class self.RefreshNameList() # For each parameters defined, set corresponding control value for name, value in values.items(): # Parameter is variable expression if name == "expression": # Set expression text control value self.Expression.ChangeValue(value) # Select corresponding text in name list box if it exists if self.VariableName.FindString(value) != wx.NOT_FOUND: self.VariableName.SetStringSelection(value) else: self.VariableName.SetSelection(wx.NOT_FOUND) # Parameter is variable execution order elif name == "executionOrder": self.ExecutionOrder.SetValue(value) # Refresh preview panel self.RefreshPreview() self.Fit()
def OnNameChanged(self, event): """ Called when name selected in name list box changed @param event: wx.ListBoxEvent """ # Change expression test control value to the value selected in name # list box if value selected is valid if self.VariableName.GetSelection() != wx.NOT_FOUND: self.Expression.ChangeValue(self.VariableName.GetStringSelection()) self.RefreshPreview() event.Skip()
def RefreshLanguage(self): selection = self.POU_LANGUAGES_DICT.get(self.Language.GetStringSelection(), "") self.Language.Clear() for language in self.POU_LANGUAGES: if language != "SFC" or POU_TYPES_DICT[self.PouType.GetStringSelection()] != "function": self.Language.Append(_(language)) if self.Language.FindString(_(selection)) != wx.NOT_FOUND: self.Language.SetStringSelection(_(selection))
def SelectTab(self, tab): for notebook in [self.LeftNoteBook, self.BottomNoteBook, self.RightNoteBook]: idx = notebook.GetPageIndex(tab) if idx != wx.NOT_FOUND and idx != notebook.GetSelection(): notebook.SetSelection(idx) return # ------------------------------------------------------------------------------- # Saving and restoring frame organization functions # -------------------------------------------------------------------------------
def OnLeftDown(self, event): selected = self.ListBox.HitTest(wx.Point(event.GetX(), event.GetY())) parent_size = self.Parent.GetSize() parent_rect = wx.Rect(0, -parent_size[1], parent_size[0], parent_size[1]) if selected != wx.NOT_FOUND: wx.CallAfter(self.Parent.SetValueFromSelected, self.ListBox.GetString(selected)) elif parent_rect.InsideXY(event.GetX(), event.GetY()): result, x, y = self.Parent.HitTest(wx.Point(event.GetX(), event.GetY() + parent_size[1])) if result != wx.TE_HT_UNKNOWN: self.Parent.SetInsertionPoint(self.Parent.XYToPosition(x, y)) else: wx.CallAfter(self.Parent.DismissListBox) event.Skip()
def set_welluid(self, welluid): self.welluid = welluid self.well_selector.SetSelection(self.iwellmap.get(welluid, wx.NOT_FOUND)) self.export_panel.set_welluid(welluid)
def set_xuid(self, xuid): self.xselector.SetSelection(self.ixmap.get(xuid, wx.NOT_FOUND))
def set_yuid(self, yuid): self.yselector.SetSelection(self.iymap.get(yuid, wx.NOT_FOUND))
def set_zuid(self, zuid): self.zselector.SetSelection(self.izmap.get(zuid, wx.NOT_FOUND))
def set_wuid(self, wuid): self.wselector.SetSelection(self.iwmap.get(wuid, wx.NOT_FOUND))
def get_yuid(self): idx = self.yselector.GetSelection() if idx is wx.NOT_FOUND: return None return self.ymap[idx]
def get_zuid(self): idx = self.zselector.GetSelection() if idx is wx.NOT_FOUND: return None return self.zmap[idx]
def get_wuid(self): idx = self.wselector.GetSelection() if idx is wx.NOT_FOUND: return None return self.wmap[idx]
def set_welluid(self, welluid): self.welluid = welluid self.wellselector.SetSelection(self.iwellmap.get(welluid, wx.NOT_FOUND)) self.crossplotselector.set_welluid(welluid)