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:
@@ -356,10 +356,14 @@ public:
|
|||||||
PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
|
PyTuple_SetItem(rv, 2, PyInt_FromLong(self->Blue()));
|
||||||
return rv;
|
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 = "asTuple = Get
|
||||||
%pragma(python) addtoclass = "def __str__(self): return str(self.asTuple())"
|
def __str__(self): return str(self.asTuple())
|
||||||
%pragma(python) addtoclass = "def __repr__(self): return str(self.asTuple())"
|
def __repr__(self): return str(self.asTuple())
|
||||||
|
def __nonzero__(self): return self.asTuple() != (0,0,0)
|
||||||
|
"
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -84,6 +84,9 @@ public:
|
|||||||
if (*self == *sz) return 0;
|
if (*self == *sz) return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool __eq__(const wxSize& o) { return *self == o; }
|
||||||
|
bool __ne__(const wxSize& o) { return *self != o; }
|
||||||
}
|
}
|
||||||
|
|
||||||
%pragma(python) addtoclass = "
|
%pragma(python) addtoclass = "
|
||||||
@@ -95,6 +98,7 @@ public:
|
|||||||
if index == 0: self.width = val
|
if index == 0: self.width = val
|
||||||
elif index == 1: self.height = val
|
elif index == 1: self.height = val
|
||||||
else: raise IndexError
|
else: raise IndexError
|
||||||
|
def __nonzero__(self): return self.asTuple() != (0,0)
|
||||||
"
|
"
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -137,6 +141,9 @@ public:
|
|||||||
if (*self == *p) return 0;
|
if (*self == *p) return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool __eq__(const wxRealPoint& o) { return *self == o; }
|
||||||
|
bool __ne__(const wxRealPoint& o) { return *self != o; }
|
||||||
}
|
}
|
||||||
%pragma(python) addtoclass = "
|
%pragma(python) addtoclass = "
|
||||||
def __str__(self): return str(self.asTuple())
|
def __str__(self): return str(self.asTuple())
|
||||||
@@ -147,6 +154,7 @@ public:
|
|||||||
if index == 0: self.width = val
|
if index == 0: self.width = val
|
||||||
elif index == 1: self.height = val
|
elif index == 1: self.height = val
|
||||||
else: raise IndexError
|
else: raise IndexError
|
||||||
|
def __nonzero__(self): return self.asTuple() != (0.0, 0.0)
|
||||||
"
|
"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -187,6 +195,9 @@ public:
|
|||||||
if (*self == *p) return 0;
|
if (*self == *p) return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool __eq__(const wxPoint& o) { return *self == o; }
|
||||||
|
bool __ne__(const wxPoint& o) { return *self != o; }
|
||||||
}
|
}
|
||||||
%pragma(python) addtoclass = "
|
%pragma(python) addtoclass = "
|
||||||
def __str__(self): return str(self.asTuple())
|
def __str__(self): return str(self.asTuple())
|
||||||
@@ -197,6 +208,7 @@ public:
|
|||||||
if index == 0: self.x = val
|
if index == 0: self.x = val
|
||||||
elif index == 1: self.y = val
|
elif index == 1: self.y = val
|
||||||
else: raise IndexError
|
else: raise IndexError
|
||||||
|
def __nonzero__(self): return self.asTuple() != (0,0)
|
||||||
"
|
"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -260,6 +272,9 @@ public:
|
|||||||
if (*self == *rect) return 0;
|
if (*self == *rect) return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool __eq__(const wxRect& o) { return *self == o; }
|
||||||
|
bool __ne__(const wxRect& o) { return *self != o; }
|
||||||
}
|
}
|
||||||
|
|
||||||
%pragma(python) addtoclass = "
|
%pragma(python) addtoclass = "
|
||||||
@@ -273,6 +288,7 @@ public:
|
|||||||
elif index == 2: self.width = val
|
elif index == 2: self.width = val
|
||||||
elif index == 3: self.height = val
|
elif index == 3: self.height = val
|
||||||
else: raise IndexError
|
else: raise IndexError
|
||||||
|
def __nonzero__(self): return self.asTuple() != (0,0,0,0)
|
||||||
|
|
||||||
# override the __getattr__ made by SWIG
|
# override the __getattr__ made by SWIG
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
|
Reference in New Issue
Block a user