Interactive visualization

I was thinking of creating a small experiment for an information visualization (infovis) application. For example, there could be a pie chart where you can click parts of the chart to show updated data on some other, lets say, bar chart on the same display. Should I create buttons that show the different parts of the pie chart (so that the graphics can be clicked) or can I embed mouse events to parts of the non-rectangular graphics (maybe an image map of sorts) or is there a smarter way of doing this? Which classes and/or methods should I look into to get started?

A concrete, but simple, example could be a 2-part pie chart where there is a blue slice for water (71 % of surface on Earth) and a brown slice for ground (29 % of surface on Earth). When you click the blue slice, I dunno, maybe the application tells about H₂O.

Buttons are not the way to go.

Have a look at the demo, sections “PseudoDC” and “ScrolledWindow” to see examples for drawing and handling mouse events.

Alternatively, you may have a look at matplotlib. This can be embedded into wxPython. It has most drawing capabilities you need and also it allows to handle mouse events.

For some pie chart examples look here:
https://matplotlib.org/3.1.1/gallery/index.html#pie-and-polar-charts

For handling mouse events of a matplotlib canvas that’s embedded into a wxPython application, an example is included with wxGlade.
(examples\matplotlib3\matplotlib_example.py)

Regards,
Dietmar

In the demo, “OGL” also seems interesting, but it obviously will take some time to test the ones you suggested and the one I have found to really understand what they do and how to use them. I know you are not recommending buttons, such as GenericButtons and ButtonPanel, but I like their look anyway.

As a side note, I could use HTML2_WebView as I already know how to make visualizations with JavaScript without using any JavaScript libraries. Using my Python application as a web browser (HTML file renderer) seems interesting even though I probably will not use the application that way.

Update: FloatCanvas seems promising according to the wxPython samples ClickableBoxes.py and Hexagons.py, but there is still a lot to go through. I’m not totally sure about creating pie charts with it yet. According to the source code of FloatCanvas, you can draw at least polygons, circles, arcs and rectangles, but I have not made my own tests yet. A “simple” EVT_FC_LEFT_DOWN seems to work for clicking the graphics.