[wxPython] Re: button.py -- Great!!

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Re: button.py -- Great!!

Gordon Williams


----------

> From: Robin Dunn <[hidden email]>
> To: [hidden email]; [hidden email]
> Subject: Re: button.py -- Great!!
> Date: December 13, 1999 5:45 PM
>
> >
> > I have some suggestions before you put it into production (sorry about
> > messing with your code):
> >
> > 1) Add some button active colour so the button is lighter in the
depressed
> > state using wxSYS_COLOUR_3DLIGHT
>
> Yep.  I had thought too of that but hadn't gotten to it yet.  I'd also
like
> to figure out a way to recalulate this color as well as the shadow and
> highlight edge colors if the programmer changes the background color.
For
> example if I call SetBackgroundColour(wxBLUE) then currently the extra
colors
> stay the same as the system defaults.
>
I tried to set the background colour to blue with
SetBackgroundColour(wxBLUE) but it had no effect.  I guess upFaceClr and
downFaceClr need to be modified.



> >
> > 2) Currently the default size of the wxGenButton is different from the
> > wxButton, both in height and width.  If you supply text that is too
large,
> > it spills out of the button.  It would be nice if the default size
would be
> > the same and expand to allow for the length of the text.  How do they
> > calculate default size for a normal wxButton?
> >
>
> Already done in my working copy.  The one issue remaining is that the
default
> size is calculated in the __init__ method but the programmer may change
the
> size of the bezel later with SetBezelWidth, which can make the default
size
> really stupid looking...
>
I think with the larger button default size a bezel of say 2 to 5 pixels
will look ok.  If a person really wants something more then they can set
the size.  Therefore I would not worry about it.



> > And a question:  When you use SetUseFocusIndicator(FALSE) it removes
the
> > focus indicator but it still accepts a focus.  Therefore the button
will
> > change if a key hit. Is there a way so the button will not have any
focus
> > at all.  Therefore, when you hit the tab key it will by-pass the button
> > altogether?
> >
>
> Use the wxWindow.Enable method.  The button classes check IsEnabled()
before
> doing anything, and the wxDialog and wxPanel check it before tabing to
the
> subwindows.
>
I thought Enable was for enabling and disabling the button totally and not
just the focus part.




I have another request.  Can we attach the button object to the event in
the Notify method

    def Notify(self):
        evt = wxGenButtonEvent(wxEVT_COMMAND_BUTTON_CLICKED, self.GetId())
        evt.SetIsDown(not self.up)
        evt.buttonObject= self       #gw added
        self.GetEventHandler().ProcessEvent(evt)

so in the button event handler we can find which button in a group was
modified.  One button event handler would then be used for a group of
radio/check/regular buttons.  My button event would look like:

    def myEvent(self, event):
        change= ('Button now up ', 'Button now down ')
        print change[event.isDown], event.buttonObject.GetLabel()

Also, if we do this, event.buttonObject.up can be used and we dont need the
two isDown methods in wxGenButtonEvent.

Button ids could be used using event.GetId() but this gets a bit messy
relating this back to the button name if the ids are assigned automatically
using wxNewId() in another class.  Maybe there is another way of doing this
that I dont know about.

 Regards,

Gordon Williams


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Re: button.py -- Great!!

Robin Dunn
> >
> I tried to set the background colour to blue with
> SetBackgroundColour(wxBLUE) but it had no effect.  I guess upFaceClr and
> downFaceClr need to be modified.
>

You'll need to change it back to the way it originaly was for that to happen.
You changes ignore the window background settings


> >
> I think with the larger button default size a bezel of say 2 to 5 pixels
> will look ok.  If a person really wants something more then they can set
> the size.  Therefore I would not worry about it.
>
>

I've just moved it into a separate method, SetBestSize() that the programmer
can call after setting the bezel and/or the font.  It also works with bitmap
buttons, with the best size being a bit larger than the bitmap plus room for
the bezel.


>
> > > And a question:  When you use SetUseFocusIndicator(FALSE) it removes
> the
> > > focus indicator but it still accepts a focus.  Therefore the button
> will
> > > change if a key hit. Is there a way so the button will not have any
> focus
> > > at all.  Therefore, when you hit the tab key it will by-pass the button
> > > altogether?
> > >
> >
> > Use the wxWindow.Enable method.  The button classes check IsEnabled()
> before
> > doing anything, and the wxDialog and wxPanel check it before tabing to
> the
> > subwindows.
> >
> I thought Enable was for enabling and disabling the button totally and not
> just the focus part.
>

As far as wxWindows is concerned it is the same thing.  If a button can't get
the focus then it can't be acitvated to it is the same as disabled.


> I have another request.  Can we attach the button object to the event in
> the Notify method
>
>     def Notify(self):
>         evt = wxGenButtonEvent(wxEVT_COMMAND_BUTTON_CLICKED, self.GetId())
>         evt.SetIsDown(not self.up)
>         evt.buttonObject= self       #gw added
>         self.GetEventHandler().ProcessEvent(evt)
>

Yes, I was going to do this, guess I forgot...  It's there now (in CVS.)

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Re: button.py -- Great!!

Gordon Williams
In reply to this post by Gordon Williams
Hi All/ Robin,

I have a demo/example made up that uses your general buttons and puts them
into a buttonbox with types push, radio and check using labels or bitmaps.
Shows different bezel, gap sizes, etc.

Are you interested in this for your demo program?  If so, then you will
need to send me your current copy of button.py because I will need to
update my code.

Regards,

Gordon Williams


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Re: button.py -- Great!!

Robin Dunn
> I have a demo/example made up that uses your general buttons and puts them
> into a buttonbox with types push, radio and check using labels or bitmaps.
> Shows different bezel, gap sizes, etc.
>
> Are you interested in this for your demo program?  If so, then you will
> need to send me your current copy of button.py because I will need to
> update my code.
>

Yes, I am but unfortunatly I've used a few more things that are only
available in my current version of wxPython so it may be more trouble than
it's worth.

On the other hand, I am working on something like an automated almost-daily
build of wxPython for MSW so I can more easily get some of this new stuff out
to you guys.  (Those of you using GTK will have to wait a bit longer, though
I want to do something like this for you eventually too.  In the meantime you
can get current sources from CVS.)

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users