Basic Tkinter

Support

Required licenses

EasyImage

Recommended images

Any image

Location

Python: […]C:\Users\Public\Documents\Euresys\Open eVision 24.10\Sample Programs
\Python samples
\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.

Code highlights

This is not supposed to be a Tkinter tutorial.

1. Load an image.
import open_evision as oev

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

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

image_rgb = oev.EImageC24(image_rgb.Width, image_rgb.Height)

oev.EasyColor.ConvertRGBImageToBGR(self.image_rgb, self.image_bgr)
3. Scale and rotate the image.
image_scaled_rotated = oev.EImageC24(image_rgb.Width, image_rgb.Height)

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

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).