> For the complete documentation index, see [llms.txt](https://easy-draw.joemazzone.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easy-draw.joemazzone.net/python/module-reference/property-getters-and-setters.md).

# Property Getting and Setting

## Property Getting

`object.property_name`

To get any property from an Easy Draw object, simply use the variable name of storing the object dot the name of the property.&#x20;

Example:  Getting the `radius` property from a Regular Polygon object named `pentagon`&#x20;

```python
pentagon.radius
```

Example:  Getting the `color` property from a Text object named `title`

```python
title.color
```

## Property Setting

`object.set_property(property_name = new_value)`

To set a property to a new value, you must call the `.set_property()` method on the object you want to change, identifying the property you want to change and its new value.

Example:  Changing the `text` property of a Text object named `title`

```python
title.set_property(text = "Player 1 has selected a character...")
```

Example:  Changing the `width` property of a Rectangle object named `box`

```python
box.set_property(width = 200)
```

## Examples

In this example we will create a square with a random color and an octagon with default color, `"black"`.  Whenever the octagon is clicked, its color will change to the square's color.

To do this, we need to get the `color` property of the square and set the `color` property of the octagon.

Get the square's color property -- `square.color`

Set the octagon's property -- `octagon.set_property()`

```python
import easy_draw
import random

easy_draw.load_canvas()

square = easy_draw.Rectangle(
    xy = (100, 100), 
    width = 200, 
    height = 200,
    color = random.choice(["blue", "red", "yellow", "green", "orange", "purple"])
)

octagon = easy_draw.RegPolygon(
    center_xy=(400,400),
    radius=100, 
    nsides=8
)

def click_octagon(event):
    global square
    global octagon
    octagon.set_property(color = square.color)

square.event_setup("<Button-1>", click_octagon)

easy_draw.end()
```

In this example, we create a growing circle by increasing the circle's radius by 10 each time it is clicked.&#x20;

Notice how the Circle object's `radius` property is set to the current `cir.radius` plus 10.&#x20;

```python
import easy_draw

easy_draw.load_canvas()

cir = easy_draw.Circle(
    center_xy = (300, 300),
    radius = 20
)

def click_circle(event):
    global cir
    cir.set_property(radius = cir.radius + 10)

cir.event_setup("<Button-1>", click_circle)

easy_draw.end()
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://easy-draw.joemazzone.net/python/module-reference/property-getters-and-setters.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
