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 ...

Get Tkinter GUI Application Development Blueprints - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.