mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
added dict-syntax access to ScratchPad
This commit is contained in:
parent
23b4f51b43
commit
3786a86d0b
@ -2644,6 +2644,15 @@ class ScratchPad:
|
|||||||
for key in self._keys:
|
for key in self._keys:
|
||||||
delattr(self, key)
|
delattr(self, key)
|
||||||
|
|
||||||
|
# allow dict [] syntax
|
||||||
|
def __getitem__(self, itemName):
|
||||||
|
return getattr(self, itemName)
|
||||||
|
def get(self, itemName, default=None):
|
||||||
|
return getattr(self, itemName, default)
|
||||||
|
# allow 'in'
|
||||||
|
def __contains__(self, itemName):
|
||||||
|
return itemName in self._keys
|
||||||
|
|
||||||
class DestructiveScratchPad(ScratchPad):
|
class DestructiveScratchPad(ScratchPad):
|
||||||
# automatically calls destroy() on elements passed to __init__
|
# automatically calls destroy() on elements passed to __init__
|
||||||
def add(self, **kArgs):
|
def add(self, **kArgs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user