Thread: Strange error.

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    11
    Rep Power
    0

    Arrow 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.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    11
    Rep Power
    0
    Here is it.
    Attached Files
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    11
    Rep 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
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    11
    Rep Power
    0
    it does has a attribute value. i can see it on the constructor tab.
  14. #8
  15. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    11
    Rep Power
    0
    Can anyone else help me?
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    133
    Rep Power
    12
    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.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    11
    Rep Power
    0
    Solved! Thanks for code.

    This is the solution that i used:

    Code:
    self.Label.SetLabel(self.Text.GetValue())
    And it worked correctly.

IMN logo majestic logo threadwatch logo seochat tools logo