|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
Here is it.
|
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
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
|
|
#6
|
||||
|
||||
|
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. |
|
#7
|
|||
|
|||
|
it does has a attribute value. i can see it on the constructor tab.
|
|
#8
|
||||
|
||||
|
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. |
|
#9
|
|||
|
|||
|
Can anyone else help me?
|
|
#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. |
|
#11
|
|||
|
|||
|
Solved! Thanks for code.
This is the solution that i used: Code:
self.Label.SetLabel(self.Text.GetValue()) And it worked correctly. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Strange error. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|