我有一个要求,我必须拍摄图像并将其渲染到隐藏的画布。然后读取其图像数据,然后使用动画慢慢渲染到另一个画布。
我做到了:
def main():
session = orm.sessionmaker(bind=engine)
db = session()
Base.metadata.create_all(engine)
p1 = Obj()
db.add(p1)
db.flush()
p2 = Obj()
p2.deleted = True
p1.children.append(p2)
db.flush()
# prints <Obj id=1 children=1>
# This means the object is in the `children` collection, even though
# it is deleted. If you want to prevent this you may want to use
# custom collection classes (not for novices!).
print p1
# We let SQLalchemy forget everything and fetch the state from the DB.
db.expire_all()
p3 = db.query(Obj).first()
# prints <Obj id=1 children=0>
# This indicates that the children which is still linked is not
# loaded into the relationship, which is what we wanted.
print p3
db.rollback()
if __name__ == '__main__':
main()
以上代码有效,但它以奇怪的方式缓慢渲染图像。 我也知道我在for循环中犯了一个错误,有人能帮我找到我做错的地方吗?