Button class

Button class

Represents the Forms control: Button

Inheritance: ButtonShape

The Button type exposes the following members:

Properties

PropertyDescription
macro_nameGets and sets the name of macro.
is_equationIndicates whether the shape only contains an equation.
is_smart_artIndicates whether the shape is a smart art.
z_order_positionReturns the position of a shape in the z-order.
nameGets and sets the name of the shape.
alternative_textReturns or sets the descriptive (alternative) text string of the Shape object.
titleSpecifies the title (caption) of the current shape object.
line_formatReturns a MsoLineFormat object that contains line formatting properties for the specified shape.
fill_formatReturns a MsoFillFormat object that contains fill formatting properties for the specified shape.
lineGets line style
fillReturns a Shape.fill_format object that contains fill formatting properties for the specified shape.
shadow_effectRepresents a ShadowEffect object that specifies shadow effect for the chart element or shape.
reflectionRepresents a ReflectionEffect object that specifies reflection effect for the chart element or shape.
glowRepresents a GlowEffect object that specifies glow effect for the chart element or shape.
soft_edgesGets and sets the radius of blur to apply to the edges, in unit of points.
three_d_formatGets and sets 3d format of the shape.
format_pictureGets and sets the options of the picture format.
is_hiddenIndicates whether the object is visible.
is_lock_aspect_ratioTrue means that aspect ratio of the shape is locked.
is_aspect_ratio_lockedTrue means that aspect ratio of the shape is locked.
rotation_angleGets and sets the rotation of the shape.
hyperlinkGets the hyperlink of the shape.
idGets the identifier of this shape.
spidSpecifies an optional string identifier that an application can use to identify the particular shape.
sptSpecifies an optional number that an application can use to associate the particular shape with a defined shape type.
worksheetGets the Shape.worksheet object which contains this shape.
is_groupIndicates whether this shape is a group shape.
is_in_groupIndicates whether the shape is grouped.
is_word_artIndicates whether this shape is a word art.
text_effectReturns a TextEffectFormat object that contains text-effect formatting properties for the specified shape.
Applies to Shape objects that represent WordArt.
is_lockedTrue means the object can not be modified when the sheet is protected.
Note that this value is meaningful only if the worksheet or objects in the worksheet are protected.
is_printableIndicates whether the object is printable.
If False, this shape will not be printed when printing.
mso_drawing_typeGets drawing type.
auto_shape_typeGets and sets the auto shape type.
anchor_typeGets and set the type of the shape anchor placeholder.
placementRepresents the way the drawing object is attached to the cells below it.
The property controls the placement of an object on a worksheet.
upper_left_rowRepresents the top row index.
upper_delta_yGets or sets the shape’s vertical offset from its upper left corner row.
upper_left_columnRepresents upper left corner column index.
upper_delta_xGets or sets the shape’s horizontal offset from its upper left corner column.
lower_right_rowRepresents lower right corner row index.
lower_delta_yGets or sets the shape’s vertical offset from its lower right corner row.
lower_right_columnRepresents lower right corner column index.
lower_delta_xGets or sets the shape’s horizontal offset from its lower right corner column.
rightRepresents the width of the shape’s horizontal offset from its lower right corner column, in unit of pixels.
bottomRepresents the width of the shape’s vertical offset from its lower bottom corner row, in unit of pixels.
widthRepresents the width of shape, in unit of pixels.
width_inchRepresents the width of the shape, in unit of inch.
width_ptRepresents the width of the shape, in unit of point.
width_cmRepresents the width of the shape, in unit of centimeters.
heightRepresents the height of shape, in unit of pixel.
height_inchRepresents the height of the shape, in unit of inches.
height_ptRepresents the height of the shape, in unit of points.
height_cmRepresents the height of the shape, in unit of centimeters.
leftRepresents the horizontal offset of shape from its left column, in unit of pixels.
left_inchRepresents the horizontal offset of shape from its left column, in unit of inches.
left_cmRepresents the horizontal offset of shape from its left column, in unit of centimeters.
topRepresents the vertical offset of shape from its top row, in unit of pixels.
top_inchRepresents the vertical offset of shape from its top row, in unit of inches.
top_cmRepresents the vertical offset of shape from its top row, in unit of centimeters.
top_to_cornerGets and sets the vertical offset of shape from worksheet top border, in unit of pixels.
left_to_cornerGets and sets the horizonal offset of shape from worksheet left border.
xGets and sets the horizontal offset of shape from worksheet left border,in unit of pixels.
yGets and sets the vertical offset of shape from worksheet top border,in unit of pixels.
width_scaleGets and sets the width scale, in unit of percent of the original picture width.
If the shape is not picture ,the WidthScale property only returns 100;
height_scaleGets and sets the height scale,in unit of percent of the original picture height.
If the shape is not picture ,the HeightScale property only returns 100;
top_in_shapeRepresents the vertical offset of shape from the top border of the parent shape,
in unit of 1/4000 of height of the parent shape.
left_in_shapeRepresents the horizontal offset of shape from the left border of the parent shape,
in unit of 1/4000 of width of the parent shape.
width_in_shapeRepresents the width of the shape, in unit of 1/4000 of the parent shape.
height_in_shapeRepresents the vertical offset of shape from the top border of the parent shape, in unit of 1/4000 of height of the parent shape..
groupGets the group shape which contains this shape.
typeGets the auto shape type.
has_lineGets and sets the line border of the shape is visible.
is_filledIndicates whether the fill format is visible.
is_flipped_horizontallyGets and sets whether shape is horizontally flipped .
is_flipped_verticallyGets and sets whether shape is vertically flipped .
actual_lower_right_rowGet the actual bottom row.
relative_to_original_picture_sizeIndicates whether shape is relative to original picture size.
linked_cellGets or sets the worksheet range linked to the control’s value.
input_rangeGets or sets the worksheet range used to fill the specified combo box.
text_shape_typeGets and sets the preset text shape type.
text_bodyGets and sets the setting of the shape’s text.
fontRepresents the font of shape.
text_optionsRepresents the text options of the shape.
textGets and sets the text of this shape.
is_rich_textWhether or not the text is rich text.
html_textGets and sets the html string which contains data and some formats in this textbox.
text_vertical_overflowGets and sets the text vertical overflow type of the shape which contains text.
text_horizontal_overflowGets and sets the text horizontal overflow type of the shape which contains text.
is_text_wrappedGets and sets the text wrapped type of the shape which contains text.
text_orientation_typeGets and sets the text orientation type of the shape.
text_horizontal_alignmentGets and sets the text horizontal alignment type of the shape.
text_vertical_alignmentGets and sets the text vertical alignment type of the shape.
text_directionGets/Sets the direction of the text flow for this object.
control_dataGets the data of control.
active_x_controlGets the ActiveX control.
pathsGets the paths of a custom geometric shape.
geometryGets the geometry
create_idGets and sets create id for this shape.
is_decorativeIndicates whether the object is decorative.

Methods

MethodDescription
to_imageCreates the shape image and saves it to a stream in the specified format.
to_imageSaves the shape to a file.
to_imageSaves the shape to a stream.
get_result_of_smart_artConverting smart art to grouped shapes.
to_front_or_backBrings the shape to the front or sends the shape to back.
get_locked_propertyGets the value of locked property.
set_locked_propertySet the locked property.
add_hyperlinkAdds a hyperlink to the shape.
remove_hyperlinkRemoves the hyperlink of the shape.
move_to_rangeMoves the shape to a specified range.
align_top_right_cornerMoves the picture to the top-right corner.
get_connection_pointsGet the connection points
get_linked_cellGets the range linked to the control’s value.
set_linked_cellSets the range linked to the control’s value.
get_input_rangeGets the range used to fill the control.
set_input_rangeSets the range used to fill the control.
update_selected_valueUpdate the selected value by the value of the linked cell.
calculate_text_sizeRecalculate the text area
format_charactersFormats some characters with the font setting.
charactersReturns a Characters object that represents a range of characters within the text.
get_charactersReturns all Characters objects
that represents a range of characters within the text .
get_rich_formattingsReturns all Characters objects
that represents a range of characters within the text .
remove_active_x_controlRemove activeX control.
is_same_settingReturns whether the shape is same.
get_actual_boxGet the actual position and size of the shape (after applying rotation, flip, etc.)

Example

from aspose.cells import Workbook
from aspose.cells.drawing import PlacementType
from aspose.pydrawing import Color

# Create a new Workbook.
workbook = Workbook()
# Get the first worksheet in the workbook.
sheet = workbook.worksheets[0]
# Add a new button to the worksheet.
button = sheet.shapes.add_button(2, 0, 2, 0, 28, 80)
# Set the caption of the button.
button.text = "Aspose"
# Set the Placement Type, the way the
# button is attached to the cells.
button.placement = PlacementType.FREE_FLOATING
# Set the font name.
button.font.name = "Tahoma"
# Set the caption string bold.
button.font.is_bold = True
# Set the color to blue.
button.font.color = Color.blue
# Set the hyperlink for the button.
button.add_hyperlink("http://www.aspose.com/")
# Saves the file.
workbook.save(r"tstbutton.xls")

See Also