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

Adding toolbar buttons

Next, we need to add 16 buttons to the left toolbar. Furthermore, depending on which button is clicked, different options would show up in the top bar as shown here:

We do not want our code structure to be too bloated by conditional logic to switch among these 16 functions. Therefore, we will call these methods dynamically.

We first begin by defining a tuple of all 16 function names (see code 6.01.py):

tool_bar_functions = ( "draw_line", "draw_oval", "draw_rectangle", "draw_arc", "draw_triangle", "draw_star", "draw_irregular_line", "draw_super_shape", "draw_text", "delete_item", "fill_item", "duplicate_item", "move_to_top", ...

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