Added Python == and != operators for some basic classes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17595 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-10-21 21:04:49 +00:00
parent f0a3fd5400
commit 2b3a3838ee
2 changed files with 23 additions and 3 deletions

View File

@@ -356,10 +356,14 @@ public:
PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
return rv;
}
bool __eq__(const wxColour& o) { return *self == o; }
bool __ne__(const wxColour& o) { return *self != o; }
}
%pragma(python) addtoclass = "asTuple = Get"
%pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
%pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
%pragma(python) addtoclass = "asTuple = Get
def __str__(self): return str(self.asTuple())
def __repr__(self): return str(self.asTuple())
def __nonzero__(self): return self.asTuple() != (0,0,0)
"
};

View File

@@ -84,6 +84,9 @@ public:
if (*self == *sz) return 0;
return -1;
}
bool __eq__(const wxSize& o) { return *self == o; }
bool __ne__(const wxSize& o) { return *self != o; }
}
%pragma(python) addtoclass = "
@@ -95,6 +98,7 @@ public:
if index == 0: self.width = val
elif index == 1: self.height = val
else: raise IndexError
def __nonzero__(self): return self.asTuple() != (0,0)
"
};
@@ -137,6 +141,9 @@ public:
if (*self == *p) return 0;
return -1;
}
bool __eq__(const wxRealPoint& o) { return *self == o; }
bool __ne__(const wxRealPoint& o) { return *self != o; }
}
%pragma(python) addtoclass = "
def __str__(self): return str(self.asTuple())
@@ -147,6 +154,7 @@ public:
if index == 0: self.width = val
elif index == 1: self.height = val
else: raise IndexError
def __nonzero__(self): return self.asTuple() != (0.0, 0.0)
"
};
@@ -187,6 +195,9 @@ public:
if (*self == *p) return 0;
return -1;
}
bool __eq__(const wxPoint& o) { return *self == o; }
bool __ne__(const wxPoint& o) { return *self != o; }
}
%pragma(python) addtoclass = "
def __str__(self): return str(self.asTuple())
@@ -197,6 +208,7 @@ public:
if index == 0: self.x = val
elif index == 1: self.y = val
else: raise IndexError
def __nonzero__(self): return self.asTuple() != (0,0)
"
};
@@ -260,6 +272,9 @@ public:
if (*self == *rect) return 0;
return -1;
}
bool __eq__(const wxRect& o) { return *self == o; }
bool __ne__(const wxRect& o) { return *self != o; }
}
%pragma(python) addtoclass = "
@@ -273,6 +288,7 @@ public:
elif index == 2: self.width = val
elif index == 3: self.height = val
else: raise IndexError
def __nonzero__(self): return self.asTuple() != (0,0,0,0)
# override the __getattr__ made by SWIG
def __getattr__(self, name):