SpinCtrl no SetFocus ?

I have a script that uses a spinner widget and it works as I would expect
except one error.
In a button event I want to SetFocus for a SpinCtrl.
           
        self.sc.SetValue(0) # this works as expected
        self.sc.SetFocus() #I get the error message: “ NameError:
name 'self' is not defined”

Both of the above instructions are in the same button event handler. I am
thinking that the spinner
widget doesn't have a SetFocus() method (?)

Thanks for any help. Note: I also posted on the Ubuntu site.

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/SpinCtrl-no-SetFocus-tp5721169.html
Sent from the wxPython-users mailing list archive at Nabble.com.

That sounds more like “self” is not defined rather than an AttributeError. Can you provide a small runnable sample application that demonstrates the problem (MakingSampleApps - wxPyWiki)?

Thanks,
Mike

···

On Wednesday, May 28, 2014 8:34:23 PM UTC-5, EightBits wrote:

I have a script that uses a spinner widget and it works as I would expect

except one error.

In a button event I want to SetFocus for a SpinCtrl.

    self.sc.SetValue(0)       # this works as expected

    self.sc.SetFocus()        #I get the error message: “ NameError:

name ‘self’ is not defined”

Both of the above instructions are in the same button event handler. I am

thinking that the spinner

widget doesn’t have a SetFocus() method (?)

Thanks for any help. Note: I also posted on the Ubuntu site.

eightbits wrote:

I have a script that uses a spinner widget and it works as I would expect
except one error.
In a button event I want to SetFocus for a SpinCtrl.
           
        self.sc.SetValue(0) # this works as expected
        self.sc.SetFocus() #I get the error message: “ NameError:
name 'self' is not defined”

Both of the above instructions are in the same button event handler. I am
thinking that the spinner widget doesn't have a SetFocus() method (?)

That would say that "SetFocus" was not defined.

My guess is that you have an indentation error. For example:

        def OnClick(self,evt):
            self.sc.SetValue(0)
        self.sc.SetFocus()

That would cause the results you see. Mixing spaces and tabs can also
cause this and be much harder to see.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Mike, I think it must have been tabs/space issue. I had started using SciTE
editor and the default
indent was set to use tabs. I started the script first using GEDIT and
always used space instead of the tab key. I kind of like the SciTE editor as
it behaves better than using Terminal mode or IDEL IDE when doing
multiple edits/run cycles.

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/SpinCtrl-no-SetFocus-tp5721169p5721175.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Tim, I think it must have been tabs/space issue. I had started using SciTE
editor and the default
indent was set to use tabs. I started the script first using GEDIT and
always used space instead of the tab key. I kind of like the SciTE editor as
it behaves better than using Terminal mode or IDEL IDE when doing
multiple edits/run cycles. Thanks to you and Mike for the assist.

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/SpinCtrl-no-SetFocus-tp5721169p5721176.html
Sent from the wxPython-users mailing list archive at Nabble.com.