Thanks for the quick reply. Actually, what I'm trying to do is a bit more involved and may hinge on how filled shapes are implemented in wxWidgets. I'm trying to create a stipple pattern to use with the DrawRectangle function using a PNG file with an alpha channel. Here's a small program patterned after one of your book examples in Chapter 12 (great book btw). Any small PNG file with transparency should suffice to experiment with. It behaves similarly on Windows and Linux running wxPython 2.6.3.
#! /usr/bin/env python
import os
import sys
import wx
class MyFrame(wx.Frame):
def __init__(self, parent=None, id=-1, title='My Frame',
pos=wx.DefaultPosition, size=(300,300)):
wx.Frame.__init__(self, parent, id, title, pos, size)
self.stipple = wx.Bitmap(sys.path[0] + os.sep + 'stipple.png', wx.BITMAP_TYPE_PNG)
self.InitBuffer()
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def InitBuffer(self):
(w, h) = self.GetClientSize()
self.buffer = wx.EmptyBitmap(w, h)
dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
self.Draw(dc)
def Draw(self, dc):
dc.SetBackground(wx.Brush('blue', wx.SOLID))
dc.Clear()
dc.SetPen(wx.Pen('yellow', 2, wx.SOLID))
brush = wx.Brush('yellow', wx.STIPPLE)
brush.SetStipple(self.stipple)
dc.SetBrush(wx.Brush('yellow', wx.CROSSDIAG_HATCH))
#dc.SetBrush(brush)
dc.DrawRectangle(50, 50, 200, 200)
def OnSize(self, event):
self.InitBuffer()
def OnPaint(self, event):
dc = wx.BufferedPaintDC(self, self.buffer)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MyFrame()
frame.Show()
app.MainLoop()
···
--
Dr. Daniel B. Koch
Oak Ridge National Lab
http://www.ornl.gov/sci/gist/bios/bio_koch.html
(865) 241-9096