Re: [Boa Constr] wxSpinButton Bug (feature request)
Status: Beta
Brought to you by:
riaan
From: Riaan B. <riaan@e.co.za> - 2001-08-06 17:50:27
|
Hi Lynndon, Lynndon Harnell wrote: > > Hi there > > I think I found a bug in the wxSpinButton control. I was attempting to > emulate the wxSpinButton in Boa just as a learning exercise. The > following is my wxFrame1 code: > > #Boa:Frame:wxFrame1 > from wxPython.wx import * > def create(parent): > return wxFrame1(parent) > [wxID_WXFRAME1, wxID_WXFRAME1PANEL1, wxID_WXFRAME1SPINBUTTON1, > wxID_WXFRAME1TEXTCTRL1] = map(lambda _init_ctrls: wxNewId(), range(4)) > class wxFrame1(wxFrame): > def _init_utils(self): > pass > def _init_ctrls(self, prnt): > wxFrame.__init__(self, id = wxID_WXFRAME1, name = '', parent = > prnt, pos = wxPoint(196, 141), size = wxSize(326, 222), style = > wxDEFAULT_FRAME_STYLE, title = 'wxFrame1') > self._init_utils() > self.panel1 = wxPanel(id = wxID_WXFRAME1PANEL1, name = > 'panel1', parent = self, pos = wxPoint(0, 0), size = wxSize(318, 192), > style = wxTAB_TRAVERSAL) > self.textCtrl1 = wxTextCtrl(id = wxID_WXFRAME1TEXTCTRL1, name > = 'textCtrl1', parent = self.panel1, pos = wxPoint(120, 72), size = > wxSize(100, 21), style = 0, value = '12') > v = int(self.textCtrl1.GetValue()) > self.spinButton1 = wxSpinButton(id = wxID_WXFRAME1SPINBUTTON1, > name = 'spinButton1', parent = self.panel1, pos = wxPoint(224, 72), > size = wxSize(16, 24), style = wxSP_ARROW_KEYS | wxWANTS_CHARS | > wxSP_VERTICAL) > self.spinButton1.SetValue(v) > EVT_SPIN(self.spinButton1, wxID_WXFRAME1SPINBUTTON1, > self.OnSpinbutton1Spin) > def __init__(self, parent): > self._init_ctrls(parent) > def OnSpinbutton1Spin(self, event): > self.textCtrl1.SetValue(str(event.GetPosition())) > # self.spinButton1.SetRange(1, 24) > #-----------------------------------------end of code > Firstly, I could not find the SetRange on either the Constructor or > the Properties tab of the Inspector. wxSpinButton does not yet have a Range property in Boa for the reason that it does not look like a standard setter method, it takes three parameters instead of the usual two. I'm counting the self parameter here so the explanation later on may be less confusing. This means I have to write a custom property editor for this property, please add this as a feature request not a bug request ;) > > Not withstanding this, I attempted to insert the last line of this > code (using the wxPython demo code just after the > "self.spinButton1.SetValue(v) line" (I previously just had a number > rather then the "v" as shown above. > > It ran all right but the Frame Designer insisted that this property > needed 3 parameter. A check in the wx docs states only 2. It was wxPython not Boa insisting about the parameters. The SetRange method does take 3 parameters : self, min, max. Remember, when calling a method the instance is implicitly passed as the first parameter. Boa successfully parsed the SetRange method you added to _init_ctrls but it only took and used the first two parameters; self, min (That's how standard boa properties work) Boa automatically displays 'standard' properties which can be handled by default. Chances are if the property does not appear in the Inspector, adding it to _init_ctrls will fail. > > The next thing was that Boa does not like the code > "v = int(self.textCtrl1.GetValue())" > > and I get a error message NameError: Name 'v' is not defined. I know > we are not supposed to put manual code into the def statements but I > could not work how else to do it. I'm glad it works exactly as it should. The Designer gave an error message and cancelled the session. You are not allowed to add arbitrary code like that to _init_* methods and Boa complained. As the docs recommend you may just add the code: v = int(self.textCtrl1.GetValue()) self.spinButton1.SetValue(v) self.spinButton1.SetRange(1, 24) to your __init__ method underneath self._init_ctrls(parent) A second option would be to use the more advanced feature of special frame attributes. Please read the section 'Mixing your code with generated code' in the Boa Documentation. > > The next thing is that I attempted to use the Boa "Bug Reporting" > option on the web pages, but SF did not seem to respond at all. > > Cheers, beers and more beers > > Lynndon Harnell -- Riaan Booysen ___________________________________________________ Boa Constructor - RAD GUI building IDE for wxPython http://boa-constructor.sourceforge.net |