Chaco and MakeMenu

Sunday 6 April 2003

Chaco is a full-featured plotting package built on Numeric and wxPython. It looks very interesting in its own right, but here’s the thing that caught my eye: MakeMenu.

In the demo script (, I saw this code:

plot_demo_menu = """
      Open | Ctrl-O:             self.on_open()
      Save as
         Single page...:         self.create_file(None,0)
         One canvas per page...: self.create_file(None,1)
         One value per page...:  self.create_file(None,2)
      Exit | Ctrl-Q:             self.on_exit()
      Undo | Ctrl-Z [menu_undo]: self.undo()
      Redo | Ctrl-Y [menu_redo]: self.redo()
   #(etc, 30 more lines..)

and then later: = chaco.wxMenu.MakeMenu( plot_demo_menu, self )

Very cool: a single string to define an entire menu tree, including the Python code to execute when the item is picked, with the whole menu constructed by a single call with the string.


Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.