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 functionality to menu items

Recall that, at the time of creating our menu using the Framework class, we created empty methods that were linked to our menu items. We will now modify those empty methods to make them functional (see code 6.09.py )

File | New Menu:

The canvas delete method can be used to delete an item, given an item-specifier. Here we use ALL to delete all items from the canvas:

def on_new_file_menu_clicked(self, event=None):  self.start_new_project()def start_new_project(self):  self.canvas.delete(ALL)  self.canvas.config(bg="#ffffff")  self.root.title('untitled')

File | Save, File | Save As:

Tkinter lets you save canvas objects as a postscript file using the command postscript(). Note, however, that the resulting postscript ...

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