Reader small image

You're reading from  Tkinter GUI Application Development Blueprints

Product typeBook
Published inNov 2015
Reading LevelExpert
PublisherPackt
ISBN-139781785889738
Edition1st Edition
Languages
Right arrow
Author (1)
Bhaskar Chaudhary
Bhaskar Chaudhary
author image
Bhaskar Chaudhary

Bhaskar Chaudhary is a professional programmer and information architect. He has a decade of experience in consulting, contracting, and educating in the field of software development. He has worked with a large set of programming languages on various platforms over the years. He is an electronics hobbyist and a musician in his free time.
Read more about Bhaskar Chaudhary

Right arrow

Drawing irregular lines and super shapes


Let's now add the feature to draw irregular or continuous free-flowing lines. We will also add the ability to draw a variety of interesting shapes on the drawing canvas as shown here:

As a reminder, all our buttons are linked to dynamically call functions defined in our tool_bar_functions tuple. Further, we can specify unique options for a given function by adding the string _options to the function name.

Drawing irregular lines

To add the capability to draw irregular lines, we just need to define the method named draw_irregular_line. To specify options that appear in the top bar, we need to define the method named draw_irregular_line_options.

We define the draw_irregular_line method as follows (see code 6.07.py):

    def draw_irregular_line(self):
        self.current_item = self.canvas.create_line(
            self.start_x, self.start_y, self.end_x, self.end_y, fill=self.fill, width=self.width)
        self.canvas.bind("<B1-Motion>", self.draw_irregular_line_update_x_y...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Tkinter GUI Application Development Blueprints
Published in: Nov 2015Publisher: PacktISBN-13: 9781785889738

Author (1)

author image
Bhaskar Chaudhary

Bhaskar Chaudhary is a professional programmer and information architect. He has a decade of experience in consulting, contracting, and educating in the field of software development. He has worked with a large set of programming languages on various platforms over the years. He is an electronics hobbyist and a musician in his free time.
Read more about Bhaskar Chaudhary