Hello. I am new to GUI and object oriented programming. I am using
Wx Python 3 with Python 2.7.1. Inside a frame, I have a multiline text
control. I added the Find and Replace dialog to my menu bar and
binded it to a function like:
self.Bind(wx.EVT_MENU,self.OnFind,menu_find)
The OnFind function is:
def OnFind(self,e):
self.finddata=wx.FindReplaceData()
dialog=wx.FindReplaceDialog(self,self.finddata,"Find Text")
dialog.Show(True)
The find dialog comes up when I hit Control F, but it doesn't seem to
find anything. For example, I type in the multiline edit box "the
cat meowed. The dog barked. Then I bring up the Find dialog by hitting
Control f. I type "barked" in the dialog box. Then I close the box.
The cursor doesn't go to the word barked. I'm blind and using a
screen reader if that makes any difference. I'm not sure how much
code is needed to help with this. I will attach my .py file if that
wasn't enough code.
Ryan Mann wrote:
The find dialog comes up when I hit Control F, but it doesn't seem to
find anything. For example, I type in the multiline edit box "the
cat meowed. The dog barked. Then I bring up the Find dialog by
hitting Control f. I type "barked" in the dialog box. Then I close
the box. The cursor doesn't go to the word barked.
The find/replace dialog included with wxPython is just that, a dialog.
It's provided as a convenience, to save you having to write a lot of
boilerplate code to set up one of your own. It also fires certain
events to let you know when a user is trying to use it and what they're
doing. But it absolutely doesn't contain any logic for finding text in
a control.
You have to bind its events like any other and handle that yourself.
For instance, finding the text, moving the cursor, highlighting what's
been found or presenting an error if nothing has. All those things need
to be implemented separately. If it provided that logic out of the box,
it wouldn't be very useful for anything outside of searching through a
wxTextCtrl.
···
--
James Scholes
http://twitter.com/JamesScholes