wxPython - get text from wxTextCtrl on a seperate frame

R

Russ Phillips

I'm just starting to learn Python & wxPython. I have a frame named
frSend in a file fSend. On this frame is a wxTextCtrl named txtMsg. I
have a module named defs.py

I would like to get the value of txtMsg from within defs.py

I tried the following:

BodyText = fSend.frSend.txtMsg.GetValue ()

When I run it, I get the following error:

AttributeError: class frSend has no attribute 'txtMsg'

Any help much appreciated.

Russ
 
J

John Fabiani

Russ said:
I'm just starting to learn Python & wxPython. I have a frame named
frSend in a file fSend. On this frame is a wxTextCtrl named txtMsg. I
have a module named defs.py

I would like to get the value of txtMsg from within defs.py

I tried the following:

BodyText = fSend.frSend.txtMsg.GetValue ()

When I run it, I get the following error:

AttributeError: class frSend has no attribute 'txtMsg'

Any help much appreciated.

Russ
First it might be better to ask this question on wxPython-user group rather
than here - it may help you in the future.  
I can't follow the code so I'll provide what I'd normally do.

First I would set my var
#I assume much here
mytextVar=txtMsg.GetValue()
#next create the control
Tcontrol=wx.TextCtrl(self,10,mytextVar, size=(200,300) ....
#make sure you add what style etc to the control
John
 
P

Peter Hansen

Russ said:
I'm just starting to learn Python & wxPython. I have a frame named
frSend in a file fSend. On this frame is a wxTextCtrl named txtMsg. I
have a module named defs.py

I would like to get the value of txtMsg from within defs.py

I tried the following:

BodyText = fSend.frSend.txtMsg.GetValue ()

When I run it, I get the following error:

AttributeError: class frSend has no attribute 'txtMsg'

As stated in this error message, you are referring to
a wx.Frame *class*, not an instance, and apparently not
what you thought you were doing. Note the difference
in the error messages produced below:
.... pass
....Traceback (most recent call last):
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: class A has no attribute 'test'


-Peter
 
R

Russ Phillips

John Fabiani said:
First it might be better to ask this question on wxPython-user group rather
than here - it may help you in the future.
I can't follow the code so I'll provide what I'd normally do.

Thanks, John.

As it happened, after I posted my question, I had lunch, and when I
came back to it, I got it working! Typical :)

Thanks again for your help,

Russ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,209
Messages
2,571,088
Members
47,687
Latest member
IngridXxj

Latest Threads

Top