On Tuesday 04 January 2005 9:52 pm, Gerard Vermeulen wrote: > Would it be to relax the type checking of enum parameters in SIP generated > wrappers, so that both an int argument and an enum argument are accepted? > > I have to change two PyQwt examples to make them work with the current > behaviour. Python pseudo code follows: ... > FIXME = True # Set to True when explicit casts of a 'Python int' to a > 'SIP-4.2 enum' are required. ... > # Example 1 > # Translation of C++: > # for (int c=0; c<QColorGroup::NColorRoles; c++) > # colorGroup.setColor(c, QColor()); > for c in range(QColorGroup.NColorRoles): > if FIXME: > c = QColorGroup.ColorRole(c) # SIP-4.2 needs this "cast" > :-/ colorGroup.setColor(c, QColor()) > ... > # Example 2 > # make sliders > # QwtSlider.BgSlot and QwtSlider.BgTrough are enums, and accepted as such > sldV1 = QwtSlider(self, "", Qt.Vertical, QwtSlider.Left, > QwtSlider.BgSlot) > sldV2 = QwtSlider(self, "", Qt.Vertical, QwtSlider.None, > QwtSlider.BgTrough) > if FIXME: > # Apparently QwtSlider.BgSlot | QwtSlider.BgTrough is not seen > as an enum by SIP-4.2. # Therefore a cast is required :-( > sldV3 = QwtSlider( > self, "", Qt.Vertical, QwtSlider.Right, > QwtSlider.BGSTYLE(QwtSlider.BgSlot | QwtSlider.BgTrough)) > else: > # SIP <= 4.1.1 is happy with the next statement > sldV3 = QwtSlider(self, "", Qt.Vertical, QwtSlider.Right, > QwtSlider.BgSlot | QwtSlider.BgTrough) > > I would expect that one can pass a Python int as well as a SIP-4.2 enum > argument into an enum parameter of a function wrapped by SIP (a C++ > function with a C++ enum parameter accepts C++ int arguments).
Ok, I've had second thoughts about this - the idiom of oring enum values is too common. Tonight's SIP snapshot will allow an integer whereever an enum is expected. I can still get QListBox.setColumnMode() to work properly, which was the original intent of the change. You will need to re-build PyQt as there is a code generation change. Phil _______________________________________________ PyKDE mailing list [email protected] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
