Created
October 20, 2016 13:20
-
-
Save antiero/0afa26559ffec85bc7d25663a3376fcd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workaround for the fact that Bins have no setName method. | |
# Check help for comments on the Undo problems associated with this! | |
from hiero.core import Bin | |
from copy import copy | |
def _setName(self, name): | |
""" | |
self.setName() -> set the name of the Bin. | |
@param: string new name | |
Notes: | |
--------------- | |
-This is a workaround for the fact that setName is missing from the Python API for Bins. | |
-Any Clips/Sequences from this Bin which are open in a Viewer will be closed after renaming. | |
-There is a bug in the Undo stack which can sometimes cause a crash when clicking on sub-bins - use with caution! | |
""" | |
newBin = Bin(name) | |
parent = self.parentBin() | |
contents = self.items() | |
project = self.project() | |
contents = self.items() | |
parent = self.parentBin() | |
newBin = Bin(name) | |
parent.removeItem(self) | |
for item in contents: | |
# Bug - there's no copy method for a Bin! | |
if isinstance(item, Bin): | |
clonedItem = copy(item) | |
newBin.addItem(clonedItem) | |
else: | |
clonedItem = item.copy() | |
newBin.addItem(clonedItem) | |
parent.addItem(newBin) | |
# Punch setName() in to hiero.core.Bin | |
# For future proofing don't punch in this been implemented in native C++! | |
if not hasattr(Bin, 'setName'): | |
Bin.setName = _setName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment