WxButton

M.E.Farmer mefjr75 at hotmail.com
Mon Dec 27 00:45:10 EST 2004


LutherRevisited wrote:
> Yes I have actually, I still can't figure out how to have my
application detect
> if a control has focus.  If I could, I could just use the keydown
event with an
> if statement to push my button when it has focus and enter is
pressed.

I am gonna try and explain how to fish ;)
Lets start with what we want to know :
What methods does wx.Button have, how do I find out?
0) Do a search for wx.Button on Google.
1) Consult the very extensive documentation available from
wxPython.org
if it didn't come with your distro.
2) Consult the Demo that comes with wxPython ( I see you have
tried )
3) Open an interpreter and try print dir(mybutton)
and see what it gives you......very informative!
Actually find out what it your object really supports,
even better than out of date docs.
4) Search a newsgroup for wx.Button or wxButton
5) Ask a newsgroup

Now on to some hints into the workings of wx.
Just about everything in wx inherits from something ( usually window ).
That means you have to look at all the bases to see what all is
available in an object. wx.Button has window as a parent, that means we
can simply use window's methods ,like SetFocus().
Always look at the bases to figure out what you have available you can
be surprised what an object is capable of.
I still dont know what you are trying to achieve.
Are you using regular buttons or toggles or bitmaps or who knows, it
matters.
I am going to mention this if you just want to activate the button that
has focus using the return key than it already works like that just tab
to the button and press return.
If you want to make a button focused by default you can use
SetDefault()
Sounds like you are trying to hard to do something simple, try less.
Hth,
M.E.Farmer




More information about the Python-list mailing list