Peter's Blog

Redefining the Impossible

Pythoncard


Been playing with Pythoncard. This is a wrapper library for wxpython that simplifies using it somewhat. The best feature of it is probably the resource manager that provides a visual GUI editor for dropping controls and assigning properties, vb style. It is clean and stable.

I've written a utility that uses:

and it all works together sweetly. The application generates an html report and uses the HtmlWindow control to display it an also print it, complete with graphics.

Problems encountered:

  • The BitmapCanvas component is supposed to support the display of PIL images directly but it did not work for me. I had to hack bitmapcanvas.py as follows:
       1      def drawBitmapScaled(self, aBitmap, xy, size, transparency=1):
       2          if isinstance(aBitmap, graphic.Bitmap):
       3              img = wx.ImageFromBitmap(aBitmap.getBits())
       4          elif isinstance(aBitmap, wx.Bitmap):
       5              img = wx.ImageFromBitmap(aBitmap)
       6          elif isinstance(aBitmap, wx.Image):
       7              img = aBitmap
       8          # pcw elif PIL_FOUND and isinstance(aBitmap, Image.Image):
       9          elif PIL_FOUND:
      10              img = graphic.PILToImage(aBitmap)
      11          elif NUMERIC_FOUND and isinstance(aBitmap, ArrayType):
      12              img = graphic.numericArrayToImage(aBitmap)
      13          else:
      14              return
    
    The isinstance call was returning PIL.Image.Image so the above test was failing. I put a similar change in DrawBitmap
  • The HtmlWindow control does not seem to support coloured fonts. The following:
    <span style="color:#ff0000;">Bin It</span>.
    
    comes out black instead of red. Maybe it doesn't support .CSS.

Filed under: cheetah python wxpython

Comments are Closed