O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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)def draw_irregular_line_update_x_y(self, event=None): self.start_x, self.start_y = self.end_x, self.end_y self.end_x, self.end_y = event.x, event.y self.draw_irregular_line()

The preceding code is similar ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required