Python wx.NOT_FOUND Examples

The following are 30 code examples of wx.NOT_FOUND(). 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: subindextable.py    From CANFestivino with GNU Lesser General Public License v2.1 6 votes vote down vote up
def OnModifyIndexMenu(self, event):
        if self.Editable:
            selected = self.IndexList.GetSelection()
            if selected != wx.NOT_FOUND:
                index = self.ListIndex[selected]
                if self.Manager.IsCurrentEntry(index) and index < 0x260:
                    values, valuetype = self.Manager.GetCustomisedTypeValues(index)
                    dialog = UserTypeDialog(self)
                    dialog.SetTypeList(self.Manager.GetCustomisableTypes(), values[1])
                    if valuetype == 0:
                        dialog.SetValues(min = values[2], max = values[3])
                    elif valuetype == 1:
                        dialog.SetValues(length = values[2])
                    if dialog.ShowModal() == wx.ID_OK:
                        type, min, max, length = dialog.GetValues()
                        self.Manager.SetCurrentUserType(index, type, min, max, length)
                        self.ParentWindow.RefreshBufferState()
                        self.RefreshIndexList() 
Example #2
Source File: subindextable.py    From CANFestivino with GNU Lesser General Public License v2.1 6 votes vote down vote up
def OnAddToDCFSubindexMenu(self, event):
        if not self.Editable:
            selected = self.IndexList.GetSelection()
            if selected != wx.NOT_FOUND:
                index = self.ListIndex[selected]
                subindex = self.SubindexGrid.GetGridCursorRow()
                entry_infos = self.Manager.GetEntryInfos(index)
                if not entry_infos["struct"] & OD_MultipleSubindexes or subindex != 0:
                    subentry_infos = self.Manager.GetSubentryInfos(index, subindex)
                    typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"])
                    if typeinfos:
                        node_id = self.ParentWindow.GetCurrentNodeId()
                        value = self.Table.GetValueByName(subindex, "value")
                        if value == "True":
                            value = 1
                        elif value == "False":
                            value = 0
                        elif value.isdigit():
                            value = int(value)
                        elif value.startswith("0x"):
                            value = int(value, 16)
                        else:
                            value = int(value.encode("hex_codec"), 16)
                        self.Manager.AddToMasterDCF(node_id, index, subindex, max(1, typeinfos["size"] / 8), value)    
                        self.ParentWindow.OpenMasterDCFDialog(node_id) 
Example #3
Source File: subindextable.py    From CANFestivino with GNU Lesser General Public License v2.1 6 votes vote down vote up
def OnDeleteSubindexMenu(self, event):
        if self.Editable:
            selected = self.IndexList.GetSelection()
            if selected != wx.NOT_FOUND:
                index = self.ListIndex[selected]
                if self.Manager.IsCurrentEntry(index):
                    dialog = wx.TextEntryDialog(self, _("Number of subindexes to delete:"),
                                 _("Delete subindexes"), "1", wx.OK|wx.CANCEL)
                    if dialog.ShowModal() == wx.ID_OK:
                        try:
                            number = int(dialog.GetValue())
                            self.Manager.RemoveSubentriesFromCurrent(index, number)
                            self.ParentWindow.RefreshBufferState()
                            self.RefreshIndexList()
                        except:
                            message = wx.MessageDialog(self, _("An integer is required!"), _("ERROR"), wx.OK|wx.ICON_ERROR)
                            message.ShowModal()
                            message.Destroy()
                    dialog.Destroy() 
Example #4
Source File: dfgui.py    From PandasDataFrameGUI with MIT License 6 votes vote down vote up
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() 
Example #5
Source File: PDFLinkMaint.py    From PyMuPDF-Utilities with GNU General Public License v3.0 6 votes vote down vote up
def clear_link_details(self):
        self.linkType.SetSelection(wx.NOT_FOUND)
        self.fromLeft.SetValue("")
        self.fromTop.SetValue("")
        self.fromHeight.SetValue("")
        self.fromWidth.SetValue("")
        self.toFile.ChangeValue("")
        self.toPage.ChangeValue("")
        self.toHeight.ChangeValue("")
        self.toLeft.ChangeValue("")
        self.toURI.ChangeValue("")
        self.toName.ChangeValue("")
        self.toName.Disable()
        self.btn_Update.Disable()
        self.t_Update.Label = ""
        self.toFile.Disable()
        self.toLeft.Disable()
        self.toHeight.Disable()
        self.toURI.Disable()
        self.toPage.Disable()
        self.adding_link = False
        self.resize_rect = False
        
        return 
Example #6
Source File: dnd_list.py    From PandasDataFrameGUI with MIT License 6 votes vote down vote up
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) 
Example #7
Source File: FBDVariableDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def RefreshNameList(self):
        """
        Called to refresh names in name list box
        """
        # Get variable class to select POU variable applicable
        var_class = self.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) 
Example #8
Source File: subindextable.py    From CANFestivino with GNU Lesser General Public License v2.1 6 votes vote down vote up
def RefreshTable(self):
        selected = self.IndexList.GetSelection()
        if selected != wx.NOT_FOUND:
            index = self.ListIndex[selected]
            if index > 0x260 and self.Editable:
                self.CallbackCheck.Enable()
                self.CallbackCheck.SetValue(self.Manager.HasCurrentEntryCallbacks(index))
            result = self.Manager.GetCurrentEntryValues(index)
            if result != None:
                self.Table.SetCurrentIndex(index)
                data, editors = result
                self.Table.SetData(data)
                self.Table.SetEditors(editors)
                self.Table.ResetView(self.SubindexGrid)
        self.ParentWindow.RefreshStatusBar()

#-------------------------------------------------------------------------------
#                        Editing Table value function
#------------------------------------------------------------------------------- 
Example #9
Source File: relay_board_gui.py    From R421A08-rs485-8ch-relay-board with MIT License 5 votes vote down vote up
def OnBoardRemoveClick(self, event=None):
        if self.m_notebook.GetPageCount() > 1:
            current_tab = self.m_notebook.GetSelection()
            if current_tab != wx.NOT_FOUND:
                self.m_notebook.RemovePage(current_tab)
                self.m_panel_changed = True
            self.m_statusBar.SetStatusText('Relay board removed.')
        else:
            self.m_statusBar.SetStatusText('Cannot remove board.') 
Example #10
Source File: rstbx_frame.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def OnNext(self, event):
        n = self.image_chooser.GetSelection()
        if n != wx.NOT_FOUND and n + 1 < self.image_chooser.GetCount():
            self.load_image(self.image_chooser.GetClientData(n + 1)) 
Example #11
Source File: rstbx_frame.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def OnPrevious(self, event):
        n = self.image_chooser.GetSelection()
        if n != wx.NOT_FOUND and n - 1 >= 0:
            self.load_image(self.image_chooser.GetClientData(n - 1)) 
Example #12
Source File: subindextable.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def OnSubindexGridRightClick(self, event):
        self.SubindexGrid.SetGridCursor(event.GetRow(), event.GetCol())
        if self.Editable:
            selected = self.IndexList.GetSelection()
            if selected != wx.NOT_FOUND:
                index = self.ListIndex[selected]
                if self.Manager.IsCurrentEntry(index):
                    showpopup = False
                    infos = self.Manager.GetEntryInfos(index)
                    if 0x2000 <= index <= 0x5FFF and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes:
                        showpopup = True
                        self.SubindexGridMenu.FindItemByPosition(0).Enable(True)
                        self.SubindexGridMenu.FindItemByPosition(1).Enable(True)
                    else:
                        self.SubindexGridMenu.FindItemByPosition(0).Enable(False)
                        self.SubindexGridMenu.FindItemByPosition(1).Enable(False)
                    if self.Table.GetColLabelValue(event.GetCol(), False) == "value":
                        showpopup = True
                        self.SubindexGridMenu.FindItemByPosition(3).Enable(True)
                    else:
                        self.SubindexGridMenu.FindItemByPosition(3).Enable(False)
                    if showpopup:
                        self.PopupMenu(self.SubindexGridMenu)
        elif self.Table.GetColLabelValue(event.GetCol(), False) == "value" and self.ParentWindow.GetCurrentNodeId() is not None:
            selected = self.IndexList.GetSelection()
            if selected != wx.NOT_FOUND:
                index = self.ListIndex[selected]
                if self.Manager.IsCurrentEntry(index):
                    infos = self.Manager.GetEntryInfos(index)
                    if not infos["struct"] & OD_MultipleSubindexes or event.GetRow() > 0:
                        self.SubindexGridMenu.FindItemByPosition(0).Enable(False)
                        self.SubindexGridMenu.FindItemByPosition(1).Enable(False)
                        self.SubindexGridMenu.FindItemByPosition(3).Enable(False)
                        self.SubindexGridMenu.FindItemByPosition(4).Enable(True)
                        self.PopupMenu(self.SubindexGridMenu)
        event.Skip() 
Example #13
Source File: IDEFrame.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
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
    # ------------------------------------------------------------------------------- 
Example #14
Source File: TextCtrlAutoComplete.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #15
Source File: FBDVariableDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #16
Source File: FBDVariableDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
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(self.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() 
Example #17
Source File: subindextable.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def OnDefaultValueSubindexMenu(self, event):
        if self.Editable:
            selected = self.IndexList.GetSelection()
            if selected != wx.NOT_FOUND:
                index = self.ListIndex[selected]
                if self.Manager.IsCurrentEntry(index):
                    row = self.SubindexGrid.GetGridCursorRow()
                    self.Manager.SetCurrentEntryToDefault(index, row)
                    self.ParentWindow.RefreshBufferState()
                    self.RefreshIndexList() 
Example #18
Source File: commondialogs.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def RefreshEDSFile(self):
        selection = self.EDSFile.GetStringSelection()
        self.EDSFile.Clear()
        for option in self.NodeList.EDSNodes.keys():
            self.EDSFile.Append(option)
        if self.EDSFile.FindString(selection) != wx.NOT_FOUND:
            self.EDSFile.SetStringSelection(selection) 
Example #19
Source File: controlcontainer.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def _setattr(self, name, value):
    if isinstance(name, wx.Window):
      ctl=name
    else:
      ctl=self.ctl(name)
    if ctl:
      if ctl.validator:
        return ctl.validator.SetValue(value)
      elif isinstance(ctl, xmlres.getControlClass("whComboBox")):
        if value == None:
          pass
        else:
          ctl.SetKeySelection(value)
      elif isinstance(ctl, wx.ComboBox):
        if value == None:
          ctl.SetSelection(wx.NOT_FOUND)
        else:
          ctl.SetStringSelection(value)
          if ctl.GetValue() != value:
            ctl.SetValue(value)
      elif isinstance(ctl, wx.StaticText):
        if value == None:
          ctl.SetLabel("")
        else:
          ctl.SetLabel(unicode(value))
      elif isinstance(ctl, wx.RadioBox):
        if value != None:
          ctl.SetSelection(value)
      else:
        if value == None:
          return ctl.SetValue("")
        return ctl.SetValue(value)
    else:
      try:
        return object.__setattr__(self, name, value)
      except AttributeError as _e:
        if not name.startswith('_'):
          raise AttributeError("%s has no attribute '%s'" % (str(self.__class__), name))
    return None 
Example #20
Source File: PouDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
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 self.POU_TYPES_DICT[self.PouType.GetStringSelection()] != "function":
                self.Language.Append(_(language))
        if self.Language.FindString(_(selection)) != wx.NOT_FOUND:
            self.Language.SetStringSelection(_(selection)) 
Example #21
Source File: subindextable.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def OnDeleteIndexMenu(self, event):
        if self.Editable:
            selected = self.IndexList.GetSelection()
            if selected != wx.NOT_FOUND:
                index = self.ListIndex[selected]
                if self.Manager.IsCurrentEntry(index):
                    self.Manager.ManageEntriesOfCurrent([],[index])
                    self.ParentWindow.RefreshBufferState()
                    self.RefreshIndexList() 
Example #22
Source File: subindextable.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def ShowDCFEntryDialog(self, row, col):
        if self.Editable or self.ParentWindow.GetCurrentNodeId() is None:
            selected = self.IndexList.GetSelection()
            if selected != wx.NOT_FOUND:
                index = self.ListIndex[selected]
                if self.Manager.IsCurrentEntry(index):
                    dialog = DCFEntryValuesDialog(self, self.Editable)
                    dialog.SetValues(self.Table.GetValue(row, col).decode("hex_codec"))
                    if dialog.ShowModal() == wx.ID_OK and self.Editable:
                        value = dialog.GetValues()
                        self.Manager.SetCurrentEntry(index, row, value, "value", "dcf")
                        self.ParentWindow.RefreshBufferState()
                        wx.CallAfter(self.RefreshTable) 
Example #23
Source File: subindextable.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def GetSelection(self):
        selected = self.IndexList.GetSelection()
        if selected != wx.NOT_FOUND:
            index = self.ListIndex[selected]
            subIndex = self.SubindexGrid.GetGridCursorRow()
            return index, subIndex
        return None 
Example #24
Source File: mainframe.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def Append(self, new_value):
        if self.FindString(new_value) == wx.NOT_FOUND:
            super(ExtComboBox, self).Append(new_value)

            if self.max_items != -1 and self.GetCount() > self.max_items:
                self.SetItems(self.GetStrings()[1:]) 
Example #25
Source File: mainframe.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def _update_videoformat_combobox(self):
        self._videoformat_combobox.Clear()

        self._videoformat_combobox.add_items(list(DEFAULT_FORMATS.values()), False)

        vformats = []
        for vformat in self.opt_manager.options["selected_video_formats"]:
            vformats.append(FORMATS[vformat])

        aformats = []
        for aformat in self.opt_manager.options["selected_audio_formats"]:
            aformats.append(FORMATS[aformat])

        if vformats:
            self._videoformat_combobox.add_header(_("Video"))
            self._videoformat_combobox.add_items(vformats)

        if aformats:
            self._videoformat_combobox.add_header(_("Audio"))
            self._videoformat_combobox.add_items(aformats)

        current_index = self._videoformat_combobox.FindString(FORMATS[self.opt_manager.options["selected_format"]])

        if current_index == wx.NOT_FOUND:
            self._videoformat_combobox.SetSelection(0)
        else:
            self._videoformat_combobox.SetSelection(current_index)

        self._update_videoformat(None) 
Example #26
Source File: widgets.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def SetStringSelection(self, string):
        index = self.listbox.GetControl().FindString(string)
        self.listbox.GetControl().SetSelection(index)

        if index != wx.NOT_FOUND and self.listbox.GetControl().GetSelection() == index:
            self.listbox.value = index
            self.textctrl.SetValue(string) 
Example #27
Source File: widgets.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def _on_motion(self, event):
        row = self.__listbox.HitTest(event.GetPosition())

        if row != wx.NOT_FOUND:
            self.__listbox.SetSelection(row)

            if self.__listbox.IsSelected(row):
                self.curitem = row 
Example #28
Source File: widgets.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def SetSelection(self, index):
        if index == wx.NOT_FOUND:
            self.Deselect(self.GetSelection())
        elif self.GetString(index) not in self.__headers:
            super(ListBoxWithHeaders, self).SetSelection(index) 
Example #29
Source File: widgets.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def _disable_header_selection(self, event):
        """Stop event propagation if the selected item is a header."""
        row = self.HitTest(event.GetPosition())
        event_skip = True

        if row != wx.NOT_FOUND and self.GetString(row) in self.__headers:
            event_skip = False

        event.Skip(event_skip) 
Example #30
Source File: dialog_gps.py    From RF-Monitor with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent, gps):
        self._gps = gps

        pre = wx.PreDialog()
        self._ui = load_ui('DialogGps.xrc')
        self._ui.LoadOnDialog(pre, parent, 'DialogGps')
        self.PostCreate(pre)

        self._checkEnable = xrc.XRCCTRL(pre, 'checkEnable')
        self._choicePort = xrc.XRCCTRL(pre, 'choicePort')
        self._choiceBaud = xrc.XRCCTRL(pre, 'choiceBaud')
        self._buttonOk = xrc.XRCCTRL(pre, 'wxID_OK')

        self._checkEnable.SetValue(gps.enabled)
        self._choicePort.AppendItems(gps.get_ports())
        port = self._choicePort.FindString(gps.port)
        if port == wx.NOT_FOUND:
            port = 0
        self._choicePort.SetSelection(port)
        self._choiceBaud.AppendItems(map(str, gps.get_bauds()))
        baud = self._choiceBaud.FindString(str(gps.baud))
        if baud == wx.NOT_FOUND:
            baud = 0
        self._choiceBaud.SetSelection(baud)

        self.Bind(wx.EVT_BUTTON, self.__on_ok, self._buttonOk)