mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-08 04:50:07 +01:00
Merge pull request #367 from RobinD42/hashable-treeitemid
Make TreeItemId hashable
This commit is contained in:
@@ -42,6 +42,18 @@ def run():
|
||||
return self->IsOk();
|
||||
""")
|
||||
|
||||
c.addCppMethod('bool', '__eq__', '(const wxTreeItemId* other)', """\
|
||||
return *self == *other;
|
||||
""")
|
||||
c.addCppMethod('bool', '__neq__', '(const wxTreeItemId* other)', """\
|
||||
return *self != *other;
|
||||
""")
|
||||
|
||||
c.addPyMethod('__hash__', '(self)', """\
|
||||
return hash(int(self.GetID()))
|
||||
""")
|
||||
|
||||
|
||||
td = etgtools.TypedefDef(name='wxTreeItemIdValue', type='void*')
|
||||
module.insertItemBefore(c, td)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
%ModuleHeaderCode
|
||||
#include <wx/treebase.h>
|
||||
|
||||
// A wxTreeItemData that knows what to do with PyObjects for maintianing the refcount
|
||||
// A wxTreeItemData that knows what to do with PyObjects for maintaining the refcount
|
||||
class wxPyTreeItemData : public wxPyUserDataHelper<wxTreeItemData>
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -28,6 +28,13 @@ class treectrl_Tests(wtc.WidgetTestCase):
|
||||
self.assertTrue(child is not root)
|
||||
self.assertTrue(child != root)
|
||||
|
||||
# Can TreeItemId be a dictionary key?
|
||||
d = dict()
|
||||
d[root] = 'root'
|
||||
d[child] = 'child'
|
||||
assert d[root] == 'root'
|
||||
assert d[r] == 'root'
|
||||
|
||||
|
||||
def test_treectrlTreeItemData(self):
|
||||
value = 'Some Python Object'
|
||||
|
||||
Reference in New Issue
Block a user