Code: Select all
[size=200]
class C_Window(QtGui.QDialog):
def __init__(self):
super(C_Window, self).__init__()
def createLabel(self, x, y, text, fontName="" , fontSize=18 , style=0):
l...ines of code...
class C_HelpWindow(M_Window.C_Window):
def __init__(self):
super(C_HelpWindow,self).__init__()
self.initUI()
def initUI(self):
...other lines of code...
self.labelTitre = self.createLabel(100,30, "Titre")
>>> no error
self.labelTitre1 = self.createLabel(30,60, "Explanations", fontSize = 10)
>>> error
[/size]
a reference on self before the parameters (this is the normal behavior), but also another ref to self before passing the optional parameters.
The first optional parameter, when given in the calling code, is hidden by 'self'
The solution, add an optional placeHolder parameter in the funtion definition It will be hidden by 'self' but as it is not used, it does'nt matter
The new code which works
Code: Select all
[size=200]
class C_Window(QtGui.QDialog):
def __init__(self):
super(C_Window, self).__init__()
def createLabel(self, x, y, text, placeHolder=0, fontName="" , fontSize=18 , style=0):
l...ines of code...
class C_HelpWindow(M_Window.C_Window):
def __init__(self):
super(C_HelpWindow,self).__init__()
self.initUI()
def initUI(self):
...other lines of code...
self.labelTitre = self.createLabel(100,30, "Titre")
>>> no error
self.labelTitre1 = self.createLabel(30,60, "Explanations", fontSize = 10)
>>> no error
[/size]
-----------------------------------
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13541 (Git)
Build type: Release
Branch: releases/FreeCAD-0-17
Hash: 9948ee4f1570df9216862a79705afb367b2c6ffb
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: French/France (fr_FR)