Sunday 6 April 2003 — This is close to 22 years old. Be careful.
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 (wxdemo_plot.py), I saw this code:
plot_demo_menu = """
&File
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()
&Edit
Undo | Ctrl-Z [menu_undo]: self.undo()
Redo | Ctrl-Y [menu_redo]: self.redo()
#(etc, 30 more lines..)
"""
and then later:
self.menu = 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.
Comments
Add a comment: