Re: [Boa Constr] newbie question -- using Boa for creating a drawing canvas
Status: Beta
Brought to you by:
riaan
From: Riaan B. <riaan@e.co.za> - 2002-07-04 11:45:16
|
Hi John, John Boik wrote: > > Thanks for the help John. But I see (at least) one more problem. Does > anyone have a suggestion? I can build a canvas class as a derived class of > one of the container classes, maintaining the same initialisation signature > as the container class and then using it as a Custom Class, as suggested, > but it produces errors because the wxShapeCanvas widget that I need to use > does not take "name=..." in its constructor. Because all the other > containers do, they would all produce an error. Short of hand typing the > whole thing in for the widget, does anyone have a suggestion as to how to > get around the "name=..." problem in defining the new constructor? John Bell gave the correct advice, but wxShapeCanvas is unfortunately an exception to convention of supporting a 'name' keyword argument. Just for consistency I wish this could be added to wxWindows, Robin? Personally I think you should do the creation of the wxShapeCanvas manually after the generated code is called in __init__. This is what I always do with the dynamic or non supported elements of any wxFrame. If you do have compelling reasons to want the object (or it's nearest equivalent which is wxScrolledWindow) in the design time environment you may define a small adapter class which just wraps the constructor signature (untested). class wxBoaShapeCanvas(wxShapeCanvas): def __init__(self, parent=None, id=-1, pos=wxDefaultPos, size=wxDefaultSize, style=wxBORDER, name='shapecanvas'): wxShapeCanvas.__init__(parent, id, pos, size, style) self.SetName(name) with _custom_classes = {'wxScrolledWindow': ['wxBoaShapeCanvas']} > John HTH, Riaan. |