# Basic Tkinter

| Support            | ![](assets/images/sample_programs/applies_to/python.svg)   |
|--------------------|------------------------------------------------------------|
| Required licenses  | **EasyImage**                                              |
| Recommended images | Any image                                                  |
| Location           | `Tkinter samples/basic`                                    |

## Purpose

This sample program demonstrates how to:

- Perform and rotate and scale an image.
- Display the image using the Tkinter GUI framework.

The process steps are:

- Load an image.
- Convert the image from RGB to BGR.
- Scale and rotate the image.
- Display the image.

![](assets/images/sample_programs/python_specific-base_web.webp)

## Code highlights

1. Load an image.
   ```python
   import eVision

   image_rgb = eVision.EImageC24()
   image_rgb.Load("path/to/your/image")
   ```
2. Rotate the image.

#### ATTENTION
The image must be converted from RGB to BGR to be properly displayed with Tkinter.

```none
```c++
image_rgb = eVision.EImageC24(image_rgb.Width, image_rgb.Height)

eVision.EasyColor.ConvertRGBImageToBGR(self.image_rgb, self.image_bgr)
```
```

1. Scale and rotate the image.
   ```c++
   image_scaled_rotated = eVision.EImageC24(image_rgb.Width, image_rgb.Height)

   eVision.EasyImage.ScaleRotate(image_bgr, image_bgr.Width / 2, image_bgr.Height / 2, image_bgr.Width / 2, image_bgr.Height / 2, scale, scale, eVision.Easy.FromDegrees(rotation), image_scaled_rotated, 4)
   ```
2. Display the image.

#### ATTENTION
Consider reading carefully the note concerning the lifetime of Tkinter variables in the source code of the sample as well as the Tkinter documentation ([https://docs.python.org/3/library/tkinter.html#images](https://docs.python.org/3/library/tkinter.html#images)).
