def __init__(self, *args, **kwargs): super(FindReplaceEditorFrame, self).__init__(*args, **kwargs) # Attributes self.finddlg = None self.finddata = wx.FindReplaceData() # Setup menub = self.GetMenuBar() editmenu = wx.Menu() editmenu.Append(wx.ID_FIND, "Find\tCtrl+F") editmenu.Append(wx.ID_REPLACE, "Replace\tCtrl+R") menub.Append(editmenu, "Edit") # Event Handlers self.Bind(wx.EVT_MENU, self.OnFindMenu, id=wx.ID_FIND) self.Bind(wx.EVT_MENU, self.OnFindMenu, id=wx.ID_REPLACE) self.Bind(wx.EVT_FIND, self.OnFind) self.Bind(wx.EVT_FIND_NEXT, self.OnFind) self.Bind(wx.EVT_FIND_REPLACE, self.OnReplace) self.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnReplaceAll) self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
def __init__(self): self.MainTitle = u"我的记事本-" self.DefaultFileName = u"无标题" #self.ID_Main = wx.NewId() wx.Frame.__init__(self, None, -1, title=self.MainTitle + self.DefaultFileName, size=(800, 600)) self.panel = panel = wx.Panel(self, -1) self.TextContentChanaged = False self.stext1 = u"文件的保存状态: " #self.kc_list = "324 325 326 327 328 329 330 331 332 333 370 387 388 390 391 392".split() logo_icon = wx.EmptyIcon() img = wx.Bitmap("ico\small1.ico", wx.BITMAP_TYPE_ANY) logo_icon.CopyFromBitmap(img) self.SetIcon(logo_icon) self.BookMenuBar() self.BookToolBar() self.BookText() self.BookMenuBar() self.statusOther = self.BookStatusBar() self.finddlg = None self.finddata = wx.FindReplaceData() self.Centre()
def __init__(self, owner, getstc): """Create the controller @param owner: View that owns this controller @param getstc: Callable to get the current buffer with """ object.__init__(self) # Attributes self._parent = owner self._stc = getstc self._finddlg = None self._posinfo = dict(scroll=0, start=0, found=0, ldir=None) self._data = wx.FindReplaceData(eclib.AFR_RECURSIVE) self._li_choices = list() self._li_sel = 0 self._filters = None self._clients = list() self._engine = EdSearchEngine(u"") # For incremental searches # Setup self._engine.SetResultFormatter(FormatResult) # Event handlers self._parent.Bind(eclib.EVT_FIND, self.OnFind) self._parent.Bind(eclib.EVT_FIND_NEXT, self.OnFind) self._parent.Bind(eclib.EVT_FIND_ALL, self.OnFindAll) self._parent.Bind(eclib.EVT_COUNT, self.OnCount) self._parent.Bind(eclib.EVT_REPLACE, self.OnReplace) self._parent.Bind(eclib.EVT_REPLACE_ALL, self.OnReplaceAll) self._parent.Bind(eclib.EVT_FIND_CLOSE, self.OnFindClose) self._parent.Bind(eclib.EVT_OPTION_CHANGED, self.OnOptionChanged) # Editra message handlers ed_msg.Subscribe(self._OnShowFindMsg, ed_msg.EDMSG_FIND_SHOW_DLG)
def __init__(self, parent, control=None, title="", replace=0): style = 0 if replace: style = wx.FR_REPLACEDIALOG self.data = wx.FindReplaceData() self.data.SetFlags(wx.FR_DOWN) # search down by default wx.FindReplaceDialog.__init__(self, parent, self.data, title, style) self.parent = parent self.control = control self.nl_error_fix = False if isinstance(self.control, wx.TextCtrl): self.nl_error_fix = True for attrname in SPECIAL_ATTRS: setattr(self, 'f' + attrname, None) if control: for attrname in SPECIAL_ATTRS: f = getattr(control, attrname, None) setattr(self, 'f' + attrname, f) # Depending on what functions we got, we can handle certain events # so this is where check and set the events appropriately if self.fGetSelection and self.fSetSelection and self.fGetValue: if self.fGetStringSelection and self.fReplace: self.OnFindReplace = self._OnFindReplace self.OnFindReplaceAll = self._OnFindReplaceAll self.OnFind = self._OnFind self.OnFindNext = self._OnFindNext self.BindEvents()
def __init__(self, parent): wx.FindReplaceDialog.__init__(self, parent, wx.FindReplaceData(1), "Search within nodes and cells", wx.FR_NOWHOLEWORD) self.resultList = [ ] # triple list (node,idx in sheet = -1 if node is the interest) self.idx = -1
def replace_button(self, e): self.data = wx.FindReplaceData() dlg = wx.FindReplaceDialog(self.Text, self.data, 'Find & Replace', style=wx.FR_REPLACEDIALOG) dlg.Show()
def OnShowFindReplace(self, evt): self.DisableButtons() data = wx.FindReplaceData() dlg = wx.FindReplaceDialog(self, data, "Find & Replace", wx.FR_REPLACEDIALOG) dlg.data = data # save a reference to it... dlg.Show(True)
def OnFindDialog(self, e) -> None: if e.GetKeyCode() == wx.WXK_CONTROL_F: finddata = wx.FindReplaceData(flags=wx.FR_DOWN) finddata.SetFindString(self._editor.GetSelectedText()) dlg = wx.FindReplaceDialog(self._editor, finddata, "Find") dlg.Show() else: e.Skip()
def __init__(self, parent, iD): self.parent = parent editor.Editor.__init__(self, parent, iD, style=wx.SUNKEN_BORDER) self.findData = wx.FindReplaceData() self.findData.SetFlags(0x01) self.cx = 0 self.cy = 0
def OnShowFind(self, evt): self.html.Find("") findData = wx.FindReplaceData() dlg = wx.FindReplaceDialog(self, findData, "Find") dlg.findData = findData dlg.Bind(wx.EVT_FIND, self.OnFind) dlg.Bind(wx.EVT_FIND_NEXT, self.OnFind) dlg.Show(True)
def test_fdrepdlgDlg(self): data = wx.FindReplaceData() data.SetFindString('find string') data.SetReplaceString('replace') self.assertEqual(data.FindString, 'find string') dlg = wx.FindReplaceDialog(self.frame, data, 'Find Stuff') dlg.GetData() dlg.Destroy()
def OnShowFind(self, e): """ Find|Something event """ data = wx.FindReplaceData() data.SetFlags(wx.FR_DOWN) # search down by default # # #data.SetReplaceString(self._replaceString) dlg = wx.FindReplaceDialog(self, data, "Find") dlg.data = data # save a reference to it... dlg.Show(True)
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log self.findData = wx.FindReplaceData() self.fbtn = wx.Button(self, -1, "Show Find Dialog", (25, 50)) self.Bind(wx.EVT_BUTTON, self.OnShowFind, self.fbtn) self.frbtn = wx.Button(self, -1, "Show Find && Replace Dialog", (25, 90)) self.Bind(wx.EVT_BUTTON, self.OnShowFindReplace, self.frbtn)
def OnTextPopupMenuItemFind(self, event): self.TextFindStart = None data = wx.FindReplaceData() start, end = self.textView.getSelection() if start is not None and end is not None: size = min(100, end - start + 1) data.SetFindString(codecs.escape_encode(self.textView.model.bin.read(start, size))[0]) dlg = wx.FindReplaceDialog(self, data, "Find", wx.FR_NOUPDOWN|wx.FR_NOWHOLEWORD) dlg.data = data # save a reference to it... dlg.Show(True) event.Skip()
def ShowFindDialog(self, code, index, text, flags): readPanel = self._readPanel if code is None else self._comparePanel[ utils.MakeKey(code, index)] data = wx.FindReplaceData() data.SetFlags(flags) data.SetFindString(text) dlg = wx.FindReplaceDialog(readPanel, data, "Find", style=wx.FR_NOMATCHCASE | wx.FR_NOWHOLEWORD) dlg.data = data dlg.Show(True)
def onFindShortCut(self, evt): # print("onFindShortCut") if self.IsShown(): self.findData = wx.FindReplaceData() dlg = wx.FindReplaceDialog(self, self.findData, "Find & Replace", wx.FR_REPLACEDIALOG) dlg.Bind(wx.EVT_FIND, self.onFindNext) dlg.Bind(wx.EVT_FIND_NEXT, self.onFindNext) dlg.Bind(wx.EVT_FIND_REPLACE, self.onReplace) dlg.Bind(wx.EVT_FIND_REPLACE_ALL, self.onReplaceAll) dlg.Bind(wx.EVT_FIND_CLOSE, self.onFindClose) dlg.Show(True)
def DoFind(self, evt=None, title="Find", style=0): if not self.finddlg: # store find data (reference to prevent SEGV) self.finddata = wx.FindReplaceData() self.finddata.SetFlags(wx.FR_DOWN) # use selected text as initial search string if self.GetSelectedText(): self.finddata.SetFindString(self.GetSelectedText()) self.finddata.SetReplaceString(self.GetSelectedText()) self.finddlg = wx.FindReplaceDialog(self, self.finddata, title, style) self.finddlg.style = style self.finddlg.Show(True)
def initUI(self): ################Notebook的调用########################## self.myNoteBook = MyNoteBook(parent=self, id=-1) ################查找和替换############################### self.find_dlg = None self.find_data = wx.FindReplaceData() self.Bind(wx.EVT_FIND, self.doFind) self.Bind(wx.EVT_FIND_NEXT, self.doFind) self.Bind(wx.EVT_FIND_REPLACE, self.doReplace) self.Bind(wx.EVT_FIND_REPLACE_ALL, self.doReplaceAll) self.Bind(wx.EVT_FIND_CLOSE, self.doFindClose) self.Bind(wx.EVT_CLOSE, self.doQuit)
def __init__(self, parent, getstc): """Initializes the Text Finding Service, the getstc argument needs to be a function that returns reference to stc to perform the search in. @param getstc: callable function that will return an stc """ object.__init__(self) self._parent = parent self._find_dlg = None self._posinfo = dict(scroll=0, start=0, found=0) self.FetchPool = getstc self._data = wx.FindReplaceData() self._data.SetFlags(wx.FR_DOWN)
def __init__(self, parent: wx.Window, id: int = wx.ID_ANY, pos: wx.Point = wx.DefaultPosition, size: wx.Size = wx.DefaultSize, style: int = wx.CLIP_CHILDREN | wx.SUNKEN_BORDER, name: str = "Log"): stc.StyledTextCtrl.__init__(self, parent, id, pos, size, style, name) self._FACES = generate_faces() self._keyMap = gen_keymap() self._config() self.default_zoom = self.GetZoom() self._styles: List[Optional[str]] = [None] * 32 self._free = 1 # dispatcher.connect(receiver=self._fontsizer, signal='FontIncrease') # dispatcher.connect(receiver=self._fontsizer, signal='FontDecrease') # dispatcher.connect(receiver=self._fontsizer, signal='FontDefault') self.findDlg = None self.findData = wx.FindReplaceData() self.findData.SetFlags(wx.FR_DOWN) self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose) self.Bind(wx.EVT_KEY_DOWN, self.onKeyPress) self.Bind(wx.EVT_MENU, lambda event: self.Copy(), id=wx.ID_COPY) self.Bind(wx.EVT_MENU, lambda event: self.SelectAll(), id=wx.ID_SELECTALL) self.Bind(wx.EVT_MENU, self.OnFindText, id=wx.ID_FIND) # self.Bind(wx.EVT_MENU, self.OnWrap, id=ID_WRAP) self.Bind(wx.EVT_MENU, self.ToggleWrap, id=ID_WRAP) # self.Bind(wx.EVT_MENU, self.OnShowLineNumbers, id=ID_SHOW_LINENUMBERS) self.Bind(wx.EVT_MENU, self.ToggleLineNumbers, id=ID_SHOW_LINENUMBERS) self.Bind(wx.EVT_MENU, self.OnZoomIn, id=ID_ZOOM_IN) self.Bind(wx.EVT_MENU, self.OnZoomOut, id=ID_ZOOM_OUT) self.Bind(wx.EVT_MENU, self.OnZoomDefault, id=ID_ZOOM_DEFAULT) # TODO: Default Zoom and Set Zoom # Display the introductory banner information. self.AppendText('''Click "▶ Run Comparison" to start Right click for options ''') # TODO: Make this not specific to GSMatch wx.CallAfter(self.ScrollToLine, 0)
def OnKeyEvt(self, event): event.Skip() needReturn = False searchFrom = "" searchText = "" if event.GetEventObject() == self.lList: searchFrom = "list" elif event.GetEventObject() == self.rText: searchFrom = "text" fromPos, toPos = self.rText.GetSelection() searchText = self.rText.GetValue()[fromPos:toPos] # Ctrl+F if searchFrom != "" and event.GetKeyCode() == 70 and event.ControlDown( ): if not hasattr(self, "findData"): self.findData = wx.FindReplaceData() self.findData.SetFindString(searchText) if hasattr(self, "dlg"): self.dlg.searchObj = {"fromStr": searchFrom} self.dlg.SetFocus() self.dlg.Show() return self.dlg = wx.FindReplaceDialog(event.GetEventObject(), self.findData, u"查找", wx.FR_NOUPDOWN) self.dlg.searchObj = {"fromStr": searchFrom} self.dlg.Show() # Ctrl+O if searchFrom == "list" and event.GetKeyCode( ) == 79 and event.ControlDown(): dlg = wx.FileDialog(self, message=u"选择文件...", defaultDir="", defaultFile="", wildcard=u"数据文件(*.pickle)|*.pickle", style=wx.OPEN | wx.MULTIPLE) if dlg.ShowModal() == wx.ID_OK: self.OpenPickleFiles(*dlg.GetPaths()) dlg.Destroy() # Ctrl+A if searchFrom == "list" and event.GetKeyCode( ) == 65 and event.ControlDown(): self.canParseItemData = False count = self.lList.GetItemCount() for n in xrange(0, count): self.lList.SetItemState(n, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED) self.canParseItemData = True
def replace_text(self, event): """ Description: Search/Replace the text in the editor input_param: find/replace - Menu selection Event input_type: Event instance """ self.start_search_index = 0 self.replace_data = wx.FindReplaceData() replace_dialog = wx.FindReplaceDialog( self.frame, self.replace_data, 'Replace Text', wx.FR_REPLACEDIALOG | wx.FR_NOUPDOWN) self.find_replace_register_events(replace_dialog) return_value = replace_dialog.Show() self.frame.show_status_text(None)
def __init__(self, parent, log): wx.Panel.__init__(self, parent, -1) self.log = log self.findData = wx.FindReplaceData() self.fbtn = wx.Button(self, -1, "Show Find Dialog", (25, 50)) self.Bind(wx.EVT_BUTTON, self.OnShowFind, self.fbtn) self.frbtn = wx.Button(self, -1, "Show Find && Replace Dialog", (25, 90)) self.Bind(wx.EVT_BUTTON, self.OnShowFindReplace, self.frbtn) self.Bind(wx.EVT_FIND, self.OnFind) self.Bind(wx.EVT_FIND_NEXT, self.OnFind) self.Bind(wx.EVT_FIND_REPLACE, self.OnFind) self.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnFind) self.Bind(wx.EVT_FIND_CLOSE, self.OnFindClose)
def __init__(self, parent): """Create a Frame instance.""" self.parent = parent self.parent.CreateStatusBar() self.parent.SetStatusText('Frame') self.shellName = 'KiCad Python Editor' self.__createMenus() self.iconized = False self.findDlg = None self.findData = wx.FindReplaceData() self.findData.SetFlags(wx.FR_DOWN) self.parent.Bind(wx.EVT_CLOSE, self.OnClose) self.parent.Bind(wx.EVT_ICONIZE, self.OnIconize)
def __init__(self, parent=None, id=-1, title='Editor', pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE): """Create a Frame instance.""" wx.Frame.__init__(self, parent, id, title, pos, size, style) self.CreateStatusBar() self.SetStatusText('Frame') import images self.SetIcon(images.getPyIcon()) self.__createMenus() self.iconized = False self.findDlg = None self.findData = wx.FindReplaceData() self.findData.SetFlags(wx.FR_DOWN) self.Bind(wx.EVT_CLOSE, self.OnClose) self.Bind(wx.EVT_ICONIZE, self.OnIconize)
def __init__(self, parent, ID): PythonSTC.__init__(self, parent, ID) self.SetEdgeMode(stc.STC_EDGE_NONE) self.SetSelBackground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)) self.SetSelForeground(True, wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHTTEXT)) self.SetModEventMask(stc.STC_MOD_INSERTTEXT | stc.STC_MOD_DELETETEXT) self.Bind(wx.stc.EVT_STC_MODIFIED, self.on_code_modified) self.Bind(wx.stc.EVT_STC_UPDATEUI, self.on_change) self.bmp = wx.Bitmap(get_image_path("breakpoint2.png")) self.SetMarginMask(1, 0x0ff) self.MarkerDefineBitmap(6, self.bmp) self.bmp = wx.Bitmap(get_image_path("cursor2.png")) self.MarkerDefineBitmap(5, self.bmp) self.ignore_code_modified = False self.finddata = wx.FindReplaceData() self.Bind(wx.EVT_FIND, self.on_find) self.Bind(wx.EVT_FIND_REPLACE, self.on_replace) self.Bind(wx.EVT_FIND_REPLACE_ALL, self.on_replace_all)
def __init__(self, owner, replace=False): object.__init__(self) self.down = True self.st = '' self.data = wx.FindReplaceData(wx.FR_DOWN) self.owner = owner self.flags = 0 self.dialog = wx.FindReplaceDialog( owner.frame, self.data, _("Replace") if replace else _("Find"), wx.FR_REPLACEDIALOG if replace else 0) owner.frame.Bind(wx.EVT_FIND, self.OnFind, self.dialog) owner.frame.Bind(wx.EVT_FIND_NEXT, self.OnFind, self.dialog) owner.frame.Bind(wx.EVT_FIND_CLOSE, self.OnClose, id=wx.ID_ANY) owner.frame.Bind(wx.EVT_FIND_REPLACE, self.OnReplace, self.dialog) owner.frame.Bind(wx.EVT_FIND_REPLACE_ALL, self.OnReplaceAll, self.dialog) self.dialog.Show()
def on_doEditFindReplace_command(self, event): data = wx.FindReplaceData() flags = data.GetFlags() data.SetFindString(self.lastFind['searchText']) data.SetReplaceString(self.lastFind['replaceText']) if self.lastFind['wholeWordsOnly']: flags = flags | wx.FR_WHOLEWORD if self.lastFind['caseSensitive']: flags = flags | wx.FR_MATCHCASE data.SetFlags(flags) dlg = wx.FindReplaceDialog(self, data, "Find & Replace", wx.FR_REPLACEDIALOG) dlg.data = data # save a reference to it... # KEA 2004-04-18 # can't use visible attribute # probably need to create a wrapper for FindReplaceDialog # to make it more like PythonCard #dlg.visible = True dlg.Show()
def __init__(self, parent, title): """PYSTCChild initalization.""" wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title=title) self.filename = title + '.py' self.editor = PythonSTC(self, -1) self.editor.SetFocus() self.mgr = wx.aui.AuiManager() self.mgr.SetManagedWindow(self) self.mgr.AddPane( self.editor, wx.aui.AuiPaneInfo().Name("editor").CenterPane().PaneBorder(False)) self.mgr.Update() self.Bind(wx.EVT_MENU, self.onOpen, id=parent.ID_OPEN) self.Bind(wx.EVT_MENU, self.onSave, id=parent.ID_SAVE) self.Bind(wx.EVT_MENU, self.onSaveAs, id=parent.ID_SAVE_AS) self.Bind(wx.EVT_MENU, self.onClose, id=parent.ID_CLOSE) self.Bind(wx.EVT_MENU, self.onFindOpen, id=parent.ID_FIND) self.Bind(wx.EVT_MENU, self.onCompile, id=parent.ID_COMPILE) self.Bind(wx.EVT_MENU, self.onEmuRun, id=parent.ID_EMU_RUN) self.Bind(wx.EVT_MENU, self.onDownload, id=parent.ID_BRICK_DOWNLOAD) self.Bind(wx.EVT_MENU, self.onDownloadRun, id=parent.ID_BRICK_DOWNLOAD_RUN) self.Bind(wx.EVT_CLOSE, self.onClose) self.parent = parent self.emuproc = None self.findData = wx.FindReplaceData(wx.FR_DOWN) self.Bind(wx.EVT_FIND, self.onFind) self.Bind(wx.EVT_FIND_NEXT, self.onFind) self.Bind(wx.EVT_FIND_REPLACE, self.onReplace) self.Bind(wx.EVT_FIND_REPLACE_ALL, self.onReplaceAll) self.Bind(wx.EVT_FIND_CLOSE, self.onFindClose)
def show_find_dialog(self, title=None): if self.__mixin_find_replace_dlg is not None: return self.__mixin_find_replace_dlg self.__mixin_find_replace_last_match_end = 0 if title is None: title = _('Find text') self.__mixin_find_replace_data = wx.FindReplaceData() self.__mixin_find_replace_dlg = wx.FindReplaceDialog( self, self.__mixin_find_replace_data, title, wx.FR_NOUPDOWN | wx.FR_NOMATCHCASE | wx.FR_NOWHOLEWORD) self.__mixin_find_replace_dlg.Bind(wx.EVT_FIND, self._mixin_on_find) self.__mixin_find_replace_dlg.Bind(wx.EVT_FIND_NEXT, self._mixin_on_find) self.__mixin_find_replace_dlg.Bind(wx.EVT_FIND_CLOSE, self._mixin_on_find_close) self.__mixin_find_replace_dlg.Show() return self.__mixin_find_replace_dlg