From: Paul K. <pki...@gm...> - 2008-07-27 18:05:09
|
On Sun, Jul 27, 2008 at 10:20 AM, John Hunter <jd...@gm...> wrote: > On Sun, Jul 27, 2008 at 7:43 AM, Paul Kienzle <pki...@gm...> wrote: >> On Sat, Jul 26, 2008 at 7:26 PM, John Hunter <jd...@gm...> wrote: >>> But this example revealed a serious problem for wxagg -- the wx >>> backend save method was getting triggered. So wxagg couuld display an >>> image, but if we try to save it, it fails because backend_wx's >>> print_figure is getting called. I fixed this by reversing the order >>> of the inheritance in FigureCanvasWXAgg so that FigureCanvasAgg is >>> first. *please test*. >> >> That one is my fault. I was having trouble getting start_event_loop >> and draw_idle from Wx to trigger from WxAgg. I have no explanation >> why it works now with Agg before Wx --- Agg should pick up the default >> draw_idle from Base so WxAgg shouldn't try to look for it in Wx. > > You are right -- I just tested with the example below. We need to be > very careful here and make sure we are getting the methods we want > start_event_loop, draw_idle and friends) from the wx base class and > not the base base class, and need to understand why it is working if > it is (my guess is it is not but I haven't dived in yet). I think the > only way to do this is to put the wx base class first and then make > sure we override the print method in wxagg. My aversion to multiple > inheritance grows by the day. Yup. The problem is with diamond inheritance. Mixins tend not to have this problem since they are not defining default behaviour, but instead are adding particular behaviours to a given class hierarchy. For the current situation we have a couple of options. One is to separate the drawing backend (Renderer) completely from the interaction backend (Canvas). This is mostly done already, and may not take that much effort to complete. The faster and good enough solution is to move the GUI parts of Wx into WxAgg and deprecate Wx. I don't understand why the current code seems to work. I put print statements in Wx.draw_idle and WxAgg.draw and both were called. I'll verify later if I get a chance. - Paul |