stc.StyledTextCtrl FindNext issue

Hello,

I am using he following code for searching Findnext and find previous in a stc.StyledTextCtrl. Find previous is working fine bu Find next is not working. it seems to be stuck only a first occurrence.

import wx

from wx import stc

import wx.lib.agw.aui as aui

class MyStyledTextCtrl(stc.StyledTextCtrl):

def init(self, parent, app, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.SIMPLE_BORDER):

stc.StyledTextCtrl.init(self, parent)

self.app = app

self.SetCaretForeground(wx.RED)

def FindNext(self,searchedText):

self.SearchAnchor()

print "FindNext "

print self.SearchNext(stc.STC_FIND_WHOLEWORD,searchedText)

self.EnsureCaretVisible()

def FindPrevious(self,searchedText):

self.SearchAnchor()

print "FindPrevious "

print self.SearchPrev( stc.STC_FIND_WHOLEWORD,searchedText)

self.EnsureCaretVisible()

Main program window

class MainFrame(wx.Frame):

Initialization functions

def init(self, app, parent=None, id=wx.ID_ANY, title="try ", pos=wx.DefaultPosition, size=(700, 550), style=wx.DEFAULT_FRAME_STYLE):

wx.Frame.init(self, parent, id, pos=pos, size=size, style=style)

self.name = title

self.version = ‘1.0’

self.text = MyStyledTextCtrl(self,app)

self.search = wx.TextCtrl(self)

self.buttonPrev = wx.Button(self,1,“Prev”)

self.buttonPrev.Bind(wx.EVT_BUTTON,self.OnPrev)

self.buttonNext = wx.Button(self,2,“Next”)

self.buttonNext.Bind(wx.EVT_BUTTON,self.OnNext)

self.panel = wx.Panel(self, -1)

hbox = wx.BoxSizer(wx.HORIZONTAL)

hbox.Add(self.buttonPrev )

hbox.Add(self.buttonNext )

hbox.Add(self.search )

self.panel.SetSizer(hbox)

Create an AUI Manager and tell it to manage this Frame

self._manager = aui.AuiManager()

self._manager.SetManagedWindow(self)

text_info = aui.AuiPaneInfo().Name(‘text’).Caption(‘text’).Bottom()

search_info = aui.AuiPaneInfo().Name(‘ribbon’).Caption(‘Can I get rid of this gray bar’).Top()

self._manager.AddPane(self.text, text_info)

self._manager.AddPane(self.panel, search_info)

self._manager.Update()

self.Show()

def OnPrev(self,event):

text = self.search.GetValue()

self.text.FindPrevious(text)

def OnNext(self,event):

text = self.search.GetValue()

self.text.FindNext(text)

class MainApp(wx.App):

def OnInit(self):

self.frame = MainFrame(self)

self.SetTopWindow(self.frame)

return True

def main():

try:

redirect_flag = not debug

app = MainApp(redirect_flag)

app.MainLoop()

except SystemExit:

sys.exit(0)

if name == ‘main’:

main()

Any suggestion ?

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/stc-StyledTextCtrl-FindNext-issue-tp5723398p5723403.html
Sent from the wxPython-users mailing list archive at Nabble.com.