The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Strange error.
Discuss Strange error. in the Python Programming forum on Dev Shed. Strange error. Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

August 2nd, 2003, 05:51 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 11
Time spent in forums: 4 h 35 m 51 sec
Reputation Power: 0
|
|
Strange error.
I have made a simple app in wxPython with Boa, when the user pressess a button, a text is copied from an TextCtrl to a Label.
The following code stands in the button event:
Code:
Label.label = Text.value
Label is the Label
Text is the TextCtrl
They both exist, but it says that they do not exist.
|

August 2nd, 2003, 06:21 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Yo yo old bean,
Your gonna have to give us a little more info. Can you post the actual error message or attach the code so those with wxPython and or Boa can see whats going on for themselves. It's just a tad hard to see whats happening from two lines of code  #
Tata,
Mark.
|

August 2nd, 2003, 06:36 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 11
Time spent in forums: 4 h 35 m 51 sec
Reputation Power: 0
|
|
|
Here is it.
|

August 2nd, 2003, 06:58 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
Ok, my mistake, you appear to need the Boa to run this, I thought it was just a program? ah well sorry cant really help to much, you could post the error message though.
Mark.
|

August 2nd, 2003, 07:18 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 11
Time spent in forums: 4 h 35 m 51 sec
Reputation Power: 0
|
|
errors:
Code:
Traceback (most recent call last):
File "C:\aery5\wxFrame1.py", line 41, in OnButton1Button
Label.label = Text.value
NameError: global name 'Text' is not defined
|

August 2nd, 2003, 07:28 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Problem solved, The error was being caused because "gloabl Text does not exist" and it doesn't, you do have self.Text though. I changed the line..
Label.label = Text.value
to..
Label.label = self.Text.value
and it works fine.  Hope this helps!
EDIT: closer examination and it isnt accessing the value. But the window shows up. Apparently wxTextCtrl has no attrabute value
Have fun,
Mark.
Last edited by netytan : August 2nd, 2003 at 07:30 AM.
|

August 2nd, 2003, 10:33 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 11
Time spent in forums: 4 h 35 m 51 sec
Reputation Power: 0
|
|
|
it does has a attribute value. i can see it on the constructor tab.
|

August 2nd, 2003, 12:38 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
We'll thats just the error i was getting, i have very little exp with GUI programming. The fact was, Python was complaining that it has no value attrabute which means it couldn't find one!  Sorry dude I don't know. If I'm getting this right all your trying to do is get input from the entry box and display it, obviously there is an error in the way your trying to do this..
Mark.
|

August 3rd, 2003, 05:55 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 11
Time spent in forums: 4 h 35 m 51 sec
Reputation Power: 0
|
|
|
Can anyone else help me?
|

August 3rd, 2003, 08:30 AM
|
|
Contributing User
|
|
Join Date: Jul 2003
Posts: 133
Time spent in forums: < 1 sec
Reputation Power: 10
|
|
Not knowing wxPython, not having looked at the documentation, I can offer you little qualified help in ultimately solving your problem. On the other hand, I know what you are doing wrong.
It is true that there is no 'Text' attribute in the global namespace. On the other hand, there is a 'Text' attribute in the instance namespace. The same goes for the 'Label' attribute, btw. You have to access all instance data objects by explicitly prefixing 'self.'
Code:
def OnButton1Button(self, event):
self.Label = wxStaticText(id=wxID_WXFRAME1LABEL,
label=self.Text.GetValue(), name='Label', parent=self,
pos=wxPoint(8, 40), size=wxSize(95, 13), style=0)
self.Validate()
The above piece of code will paint what you write on top of the previous text. As I said, not much help, but perhaps it'll get you moving.
|

August 3rd, 2003, 10:28 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 11
Time spent in forums: 4 h 35 m 51 sec
Reputation Power: 0
|
|
Solved! Thanks for code.
This is the solution that i used:
Code:
self.Label.SetLabel(self.Text.GetValue())
And it worked correctly.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|