def add_shape(self, autoshape_type_id, left, top, width, height): """ Add auto shape of type specified by *autoshape_type_id* (like ``MSO_SHAPE.RECTANGLE``) and of specified size at specified position. """ autoshape_type = AutoShapeType(autoshape_type_id) sp = self._add_sp_from_autoshape_type(autoshape_type, left, top, width, height) return self._shape_factory(sp)
def add_shape(self, autoshape_type_id, left, top, width, height): """Return new |Shape| object appended to this shape tree. Auto shape is of type specified by *autoshape_type_id* (like ``MSO_SHAPE.RECTANGLE``) and of specified size at specified position. """ autoshape_type = AutoShapeType(autoshape_type_id) sp = self._add_sp(autoshape_type, left, top, width, height) self._recalculate_extents() return self._shape_factory(sp)
def add_shape(self, autoshape_type_id, left, top, width, height): """Return new |Shape| object appended to this shape tree. *autoshape_type_id* is a member of :ref:`MsoAutoShapeType` e.g. ``MSO_SHAPE.RECTANGLE`` specifying the type of shape to be added. The remaining arguments specify the new shape's position and size. """ autoshape_type = AutoShapeType(autoshape_type_id) sp = self._add_sp(autoshape_type, left, top, width, height) self._recalculate_extents() return self._shape_factory(sp)
def it_raises_on_construction_with_bad_autoshape_type_id(self): with pytest.raises(KeyError): AutoShapeType(9999)
def it_caches_autoshape_type_lookups(self): autoshape_type_id = MSO_SHAPE.ROUNDED_RECTANGLE autoshape_type_1 = AutoShapeType(autoshape_type_id) autoshape_type_2 = AutoShapeType(autoshape_type_id) assert autoshape_type_2 is autoshape_type_1
def it_raises_when_asked_for_autoshape_type_id_with_a_bad_prst(self): with pytest.raises(KeyError): AutoShapeType.id_from_prst('badPrst')
def it_knows_the_autoshape_type_id_for_each_prst_key(self): assert AutoShapeType.id_from_prst('rect') == MSO_SHAPE.RECTANGLE
def it_knows_the_default_adj_vals_for_its_autoshape_type( self, default_adj_vals_fixture_): prst, default_adj_vals = default_adj_vals_fixture_ _default_adj_vals = AutoShapeType.default_adjustment_values(prst) assert _default_adj_vals == default_adj_vals
def it_knows_the_details_of_the_auto_shape_type_it_represents(self): autoshape_type = AutoShapeType(MSO_SHAPE.ROUNDED_RECTANGLE) assert autoshape_type.autoshape_type_id == MSO_SHAPE.ROUNDED_RECTANGLE assert autoshape_type.prst == 'roundRect' assert autoshape_type.basename == 'Rounded Rectangle'