Hi,

I've been using FloatCanvas for 2 years now to draw a visual of a 
manufactured product. Each component going into the product can be 
clicked on by the user, and from their they can change dimensions and 
other properties. Couldn't be much slicker, and I'm really happy.

However, now I need to support Mac (previously I supported Windows and 
Linux).

Up until now I've been setting the background color of the canvas to 
match the background color of the parent, drawing the product, and then 
calling ZoomToBB() to get the drawing to go as large as it can go within 
the bounds of the windows size. Setting the background color to match 
gives the canvas a borderless look that works with the rest of the frame 
(the canvas part is only about 1/5 of the frame).

However, Mac has these really juicy backgrounds like the alternating 
grey/silver stripes, so the above strategy shows the border of the 
canvas. I discovered that if I set the background color of the canvas to 
None, the background would become transparent; problem solved.

Except when I resize the parent frame, and my onResize handler calls 
ZoomToBB() to get the drawing to fit in the new size, artifacts are left 
behind. The only way I've found to make them go away is to do a 
Canvas.Refresh at least 50ms after calling ZoomToBB().

In case it helps with a better fix, here's how I've worked around this 
in my code:

     402 class FC(FloatCanvas.FloatCanvas):
     403   def ZoomToBB(self, *args, **kwargs):
     404     if sys.platform.startswith("darwin"):
     405       # Mac's transparent background shows artifacts when
               # zooming. Worked out the
     406       # recipe to work around this by trial and error:
     407       def do():
     408         super(FC, self).ZoomToBB(*args, **kwargs)
     409         dabo.ui.callAfterInterval(50, self.Refresh)
     410       dabo.ui.callAfter(do)
     411     else:
     412       super(FC, self).ZoomToBB(*args, **kwargs)

dabo.ui.callAfter() maps to wx.CallAfter(); dabo.ui.callAfterInterval 
maps to wx.FutureCall()

Paul
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to