I'd like to get text input from wxTextCtrl and assign it to a variable
(make a pointer, I'd guess) for use later in the program...
...
Traceback (most recent call last):
File "Address2.py", line 27, in OnFindButton1
win = self.FindWindowById(self.editname)
File "I:\Python21\wxPython\windows.py", line 170, in FindWindowById
val = apply(windowsc.wxWindow_FindWindowById,(self,) + _args,
_kwargs)
AttributeError: wxTextCtrl instance has no attribute '__int__'
I'm just extracting the important parts of the code.
#Logging for niceness................
self.logger = wxTextCtrl(self,5, "",wxPoint(300,20),
wxSize(200,300),wxTE_MULTILINE | wxTE_READONLY)self.lblname = wxStaticText(self, -1, "Name :",wxPoint(20,y))
#I want to capture text in this window.................
self.editname = wxTextCtrl(self, 20, "", wxPoint(100, y),
wxSize(200,-1))
Now, you have a window with an id of "20". The window is wrapped by a
wxTextCtrl object that you have stored in self.editname.
#Capture text when button is pushed..................
self.btn1 = wxButton(self,BTN1,"Push",wxPoint(210,y+20))EVT_TEXT(self, 20, self.EvtText)
EVT_BUTTON(self,BTN1,self.OnFindButton1)def EvtText(self, event):
self.logger.AppendText('EvtText: %s\n' % event.GetString())def OnFindButton1(self,event):
win = self.FindWindowById(self.editname)
if win is None:
self.logger.write("*******Name not found")
return
if win is self.editname:
#Dump captured text into logger.........
self.logger.AppendText('Found %s\n' % event.GetString())
else:
self.logger.AppendText('Not the same')
OnFindButton1 will get called when your "self.btn1" is triggered. You don't
need to "look up" the window object for self.editname in order to fetch its
contents, because you already HAVE the window object. Further,
"event.GetString()" contains a string that relates to this specific event.
In this functions, we are handling the pushing of btn1, not the changing of
the text box. GetString() won't help you. Instead, just fetch the value of
the text control, which you can do because you saved the wrapper object in
self.editname.
You should be able to replace that entire procedure with:
def OnFindButton1(self,event):
self.logger.AppendText('Found %s\n' % self.editname.GetValue())
···
On Thu, 02 May 2002 18:10:08 -0400, Charles Bowman <bowman@acsu.buffalo.edu> wrote:
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.