From: Riaan B. <riaan@e.co.za> - 2001-08-21 20:03:28
|
Hi Lynndon, "Harnell, Lynndon" wrote: > > >FROM: Riaan Booysen > >DATE: 08/20/2001 10:43:42 > >SUBJECT: RE: [Boa Constr] wxGrid in Boa > >Hi Lynndon, please send plain text mail to the mailing list! > > Will do. Is this OK? Perfect, > > >Luckily there is support already built into Boa to do what you want. > > >It's called 'custom classes'. The first change you need to make, is to > >change your dbGrid class to have the same constructor as the original > >wxGrid class. > > By this do you mean the line?: > wxGrid.__init__(self,parent,-1, style= wxSIMPLE_BORDER|wxSUNKEN_BORDER) The line above it would be the class constructor. def __init__(... You defined a new class called dbGrid. Boa will generate source using your class name, but with the same constructor signature as the class we defined your class equivalent to with the line: _custom_classes = {'wxGrid': ['dbGrid']} I don't exactly know how you expect this dbGrid class to behave in the Designer. For the Designer it will be a wxGrid, not your class, so you won't see any new properties or behaviour. I need you to understand what happens here, trying to do what I recommend without really understanding will cause problems later, so if this is still unclear, please ask. > Boa inserts code like this: > self.grid1 = wxGrid(id = wxID_WXFRAME1GRID1, name = 'grid1', parent = > self.panel1, pos = wxPoint(104, 24), size = wxSize(136, 80), style= 0) > > So that I should change the first to something like?: > > wxGrid.__init__(ID, self,parent,-1, pos, size, style= > wxSIMPLE_BORDER|wxSUNKEN_BORDER) See above, There are 2 routes I usually consider: One, to copy the definition from the docs: def __init__(self, parent, id=-1, pos=wxDefaultPosition, size=wxDefaultSize, style=wxWANTS_CHARS, name='grid') wxGrid.__init__(self, parent, id, pos, size, style, name) Two, to copy the wxPython (SWIG) signature: def __init__(self, *_args, **_kwargs): apply(wxGrid.__init__, _args, _kwargs) # access parameters from the _kwargs, e.g. _kwargs['style'] I usually use the second form when using _custom_classes. It's ugly, but it's short and it only passes on the args that are defined. > self.grid1 = wxGrid(id = wxID_WXFRAME1GRID1, name = 'grid1', parent = > self.panel1, pos = wxPoint(104, 24), size = wxSize(136, 80), style= 0) > > >Then uncomment the line > ># self.grid1 = wxGrid ... > > > >and delete the line you added > > > > self.grid1 = dbGrid ... > > OK understood > > >Now add the following _custom_classes line to the top of the wxFrame1 > >definition as a class attribute: > > >class wxFrame1(wxFrame): > > > _custom_classes = {'wxGrid': ['dbGrid']} > > > def _init_utils(self): > > Got that. > > >Now open the Designer, select the Grid and change the Class property > >from wxGrid to dbGrid. > > That too. > > >You will notice that the constructor you defined takes 1 parameter, > >yet it is called with 5 keyword parameters in the source. > > Is this the line you mean in referring to the constructor definition, and is > the one parameter the style? I refered to: def __init__(self,parent): > > wxGrid.__init__(self,parent,-1, style= wxSIMPLE_BORDER|wxSUNKEN_BORDER) Just to clear up terminology, your line above is not the constructor definition/declaration, but where the base class's constructor is called within the constructor's code block. > > and is this the line you mean with 5 keywords in the source? There are 6 > parameters within the wxGrid brackets (ID,NAME,PARENT,POS,SIZE,STYLE) or is > one ignored? Sorry I did not count correctly, but this is beside the point. The point I tried to make was that it was more than the one parameter you had in your __init__ method ;) > > self.grid1 = wxGrid(id = wxID_WXFRAME1GRID1, name = 'grid1', parent = > self.panel1, pos = wxPoint(104, 24), size = wxSize(136, 80), style= 0) > > Thanks for all your help. Hope this is all starting to make sense. > > Lynndon > > _______________________________________________ > Boa-constructor-users mailing list > Boa...@li... > http://lists.sourceforge.net/lists/listinfo/boa-constructor-users -- Riaan Booysen ___________________________________________________ Boa Constructor - RAD GUI building IDE for wxPython http://boa-constructor.sourceforge.net |