mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Add repr for QgsMargins
This commit is contained in:
parent
3f795c544d
commit
e9a51d6806
@ -124,6 +124,12 @@ if the string could not be interpreted as margins.
|
||||
.. seealso:: :py:func:`toString`
|
||||
%End
|
||||
|
||||
SIP_PYOBJECT __repr__();
|
||||
%MethodCode
|
||||
const QString str = QStringLiteral( "<QgsMargins: %1 %2 %3 %4>" ).arg( sipCpp->left() ).arg( sipCpp->top() ).arg( sipCpp->right() ).arg( sipCpp->bottom() );
|
||||
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -124,6 +124,12 @@ if the string could not be interpreted as margins.
|
||||
.. seealso:: :py:func:`toString`
|
||||
%End
|
||||
|
||||
SIP_PYOBJECT __repr__();
|
||||
%MethodCode
|
||||
const QString str = QStringLiteral( "<QgsMargins: %1 %2 %3 %4>" ).arg( sipCpp->left() ).arg( sipCpp->top() ).arg( sipCpp->right() ).arg( sipCpp->bottom() );
|
||||
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -160,6 +160,14 @@ class CORE_EXPORT QgsMargins
|
||||
*/
|
||||
static QgsMargins fromString( const QString &string );
|
||||
|
||||
#ifdef SIP_RUN
|
||||
SIP_PYOBJECT __repr__();
|
||||
% MethodCode
|
||||
const QString str = QStringLiteral( "<QgsMargins: %1 %2 %3 %4>" ).arg( sipCpp->left() ).arg( sipCpp->top() ).arg( sipCpp->right() ).arg( sipCpp->bottom() );
|
||||
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
|
||||
% End
|
||||
#endif
|
||||
|
||||
private:
|
||||
double mLeft = 0.0;
|
||||
double mTop = 0.0;
|
||||
|
@ -34,6 +34,10 @@ class TestQgsOptional(unittest.TestCase):
|
||||
self.assertFalse(margins.isNull())
|
||||
self.assertEqual(margins, QgsMargins(5.5, 0.0, 5.5, 0.0))
|
||||
|
||||
def test_repr(self):
|
||||
self.assertEqual(str(QgsMargins(12.1, 14.1, 16.1, 18.1)),
|
||||
'<QgsMargins: 12.1 14.1 16.1 18.1>')
|
||||
|
||||
def testOperators(self):
|
||||
m1 = QgsMargins(12.1, 14.1, 16.1, 18.1)
|
||||
m2 = QgsMargins(2.1, 3.1, 4.1, 5.1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user