PYLbc: option to set first button in band as default

  • From: Alex Hall <mehgcap@xxxxxxxxx>
  • To: programmingblind <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 17 Jun 2011 12:27:31 -0400

Hi all,
Using PYLbc, I have run into an annoyance. I set a button to be
default in my dialog, but that button was not in the list of buttons
when I call Complete() on the dialog. Lbc, though, automatically sets
the first button in a band to be default, and Complete() calls
AddBand(), so the first button in the band passed when you call
Complete() gets set to default. This, of course, undoes my manual
setting of a default button. I propose the following function instead,
which has a flag that will only make the first button default if set
to true (the default):

        def AddButtonBand(self, buttons=[], handler=None, setDefault=True):
                self.CustomHandler = handler
                self.AddBand()
                for i in range(len(buttons)):
                        sButton = buttons[i]
                        btn = self.AddButton(label=sButton)
                        if i == 0 and setDefault: btn.SetDefault()
                # end for
        # end def

I used this change in my copy of lbc and it seems to work, with my
default button being triggered instead of the Close button. It took me
a while to figure out why the dialog was closing when I pressed enter,
but that is why, and this fix eliminates the problem.


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts:

  • » PYLbc: option to set first button in band as default - Alex Hall