In this chapter, we will cover:
In this chapter, we explore alternate ways and means of getting graphic-shaped data into Tkinter programs. Probably the most widespread vector-graphic format is the one designed to work on web pages. This is known as SVG, which is short-form for Scaled Vector Graphics. It is the official standard specification defined by the World Wide Web Consortium and has been around since 1999.
Our interest in SVG comes from the practical use it has for us in creating drawn shapes in Python with the Tkinter module.
Professional vector-drawing packages like Inkscape and some of the proprietary-drawing packages allow us, aided by some Python code, to acquire lists of coordinates that can be used directly in the create_line(x0,y0 …)
functions of Tkinter.
There are growing libraries of copyright-free SVG pictures available on the web. With tools like Inkscape, we can dismantle existing images and use parts of them for our own graphic work and Python programs. One such site is www.openclipart.org/ which allows and encourages anyone to copy the thousands of images stored there in SVG format.
SVG drawings encode lines in more than one way. One way is to represent a line as a series of x-y coordinate points on a canvas. Each point is defined as a pair of numbers referred to the zero position of the canvas which is the North-West corner (top-right). The second way is to represent each point as a relative shift from the previous point.
13.59.48.161