Lots of wx namespace updates for the wx.lib package and the demo from

Jeff Grimmett with some tweaks and changes from Robin


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24889 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-12-17 00:34:40 +00:00
parent e1f4ff6ddc
commit b881fc787d
69 changed files with 2756 additions and 2103 deletions

View File

@@ -12,6 +12,11 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o 2.5 compatability update.
#
from pycolourchooser import *
# For the American in you

View File

@@ -12,9 +12,14 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
from wxPython.wx import *
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o 2.5 compatability update.
#
class BitmapBuffer(wxMemoryDC):
import wx
class BitmapBuffer(wx.MemoryDC):
"""A screen buffer class.
This class implements a screen output buffer. Data is meant to
@@ -23,27 +28,27 @@ class BitmapBuffer(wxMemoryDC):
"""
def __init__(self, width, height, colour):
"""Initialize the empty buffer object."""
wxMemoryDC.__init__(self)
wx.MemoryDC.__init__(self)
self.width = width
self.height = height
self.colour = colour
self.bitmap = wxEmptyBitmap(self.width, self.height)
self.bitmap = wx.EmptyBitmap(self.width, self.height)
self.SelectObject(self.bitmap)
# Initialize the buffer to the background colour
self.SetBackground(wxBrush(self.colour, wxSOLID))
self.SetBackground(wx.Brush(self.colour, wx.SOLID))
self.Clear()
# Make each logical unit of the buffer equal to 1 pixel
self.SetMapMode(wxMM_TEXT)
self.SetMapMode(wx.MM_TEXT)
def GetBitmap(self):
"""Returns the internal bitmap for direct drawing."""
return self.bitmap
class Canvas(wxWindow):
class Canvas(wx.Window):
"""A canvas class for arbitrary drawing.
The Canvas class implements a window that allows for drawing
@@ -55,24 +60,24 @@ class Canvas(wxWindow):
are also provided.
"""
def __init__(self, parent, id,
pos=wxDefaultPosition,
size=wxDefaultSize,
style=wxSIMPLE_BORDER):
pos=wx.DefaultPosition,
size=wx.DefaultSize,
style=wx.SIMPLE_BORDER):
"""Creates a canvas instance and initializes the off-screen
buffer. Also sets the handler for rendering the canvas
automatically via size and paint calls from the windowing
system."""
wxWindow.__init__(self, parent, id, pos, size, style)
wx.Window.__init__(self, parent, id, pos, size, style)
# Perform an intial sizing
self.ReDraw()
# Register event handlers
EVT_SIZE(self, self.onSize)
EVT_PAINT(self, self.onPaint)
self.Bind(wx.EVT_SIZE, self.onSize)
self.Bind(wx.EVT_PAINT, self.onPaint)
def MakeNewBuffer(self):
size = self.GetSizeTuple()
size = self.GetSize()
self.buffer = BitmapBuffer(size[0], size[1],
self.GetBackgroundColour())
@@ -91,12 +96,12 @@ class Canvas(wxWindow):
def Refresh(self):
"""Re-draws the buffer contents on-screen."""
dc = wxClientDC(self)
dc = wx.ClientDC(self)
self.Blit(dc)
def onPaint(self, event):
"""Renders the off-screen buffer on-screen."""
dc = wxPaintDC(self)
dc = wx.PaintDC(self)
self.Blit(dc)
def Blit(self, dc):
@@ -109,7 +114,7 @@ class Canvas(wxWindow):
def GetBoundingRect(self):
"""Returns a tuple that contains the co-ordinates of the
top-left and bottom-right corners of the canvas."""
x, y = self.GetPositionTuple()
x, y = self.GetPosition()
w, h = self.GetSize()
return(x, y + h, x + w, y)

View File

@@ -11,10 +11,14 @@ This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o 2.5 compatability update.
#
from wxPython.wx import *
import wx
class PyColourBox(wxPanel):
class PyColourBox(wx.Panel):
"""A Colour Selection Box
The Colour selection box implements button like behavior but contains
@@ -24,13 +28,12 @@ class PyColourBox(wxPanel):
def __init__(self, parent, id, colour=(0, 0, 0), size=(25, 20)):
"""Creates a new colour box instance and initializes the colour
content."""
wxPanel.__init__(self, parent, id,
size=wxSize(size[0], size[1]))
wx.Panel.__init__(self, parent, id, size=size)
self.colour_box = wxPanel(self, -1, style=wxSIMPLE_BORDER)
self.colour_box = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
sizer = wxGridSizer(1, 1)
sizer.Add(self.colour_box, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
sizer = wx.GridSizer(1, 1)
sizer.Add(self.colour_box, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
sizer.SetItemMinSize(self.colour_box, size[0] - 5, size[1] - 5)
self.SetAutoLayout(True)
self.SetSizer(sizer)
@@ -57,10 +60,10 @@ class PyColourBox(wxPanel):
def SetColourTuple(self, colour):
"""Sets the box's current couple to the given tuple."""
self.colour = colour
self.colour_box.SetBackgroundColour(wxColour(*self.colour))
self.colour_box.SetBackgroundColour(wx.Colour(*self.colour))
def Update(self):
wxPanel.Update(self)
wx.Panel.Update(self)
self.colour_box.Update()
def SetHighlight(self, val):
@@ -72,7 +75,7 @@ class PyColourBox(wxPanel):
red =(self.real_bg.Red() - 45) % 255
green =(self.real_bg.Green() - 45) % 255
blue =(self.real_bg.Blue() - 45) % 255
new_colour = wxColour(red, green, blue)
new_colour = wx.Colour(red, green, blue)
self.SetBackgroundColour(new_colour)
else:
self.SetBackgroundColour(self.real_bg)

View File

@@ -12,14 +12,22 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
import pycolourbox
import pypalette
import pycolourslider
import colorsys
from intl import _
from wxPython.wx import *
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o 2.5 compatability update.
#
class wxPyColourChooser(wxPanel):
import wx
import pycolourbox
import pypalette
import pycolourslider
import colorsys
import intl
from intl import _ # _
class wxPyColourChooser(wx.Panel):
"""A Pure-Python implementation of the colour chooser dialog.
The PyColourChooser is a pure python implementation of the colour
@@ -88,140 +96,147 @@ class wxPyColourChooser(wxPanel):
# Generate the custom colours. These colours are shared across
# all instances of the colour chooser
NO_CUSTOM_COLOURS = 16
custom_colours = [ (wxColour(255, 255, 255),
custom_colours = [ (wx.Colour(255, 255, 255),
pycolourslider.PyColourSlider.HEIGHT / 2)
] * NO_CUSTOM_COLOURS
last_custom = 0
idADD_CUSTOM = wxNewId()
idSCROLL = wxNewId()
idADD_CUSTOM = wx.NewId()
idSCROLL = wx.NewId()
def __init__(self, parent, id):
"""Creates an instance of the colour chooser. Note that it is best to
accept the given size of the colour chooser as it is currently not
resizeable."""
wxPanel.__init__(self, parent, id)
wx.Panel.__init__(self, parent, id)
self.basic_label = wxStaticText(self, -1, _("Basic Colours:"))
self.custom_label = wxStaticText(self, -1, _("Custom Colours:"))
self.add_button = wxButton(self, self.idADD_CUSTOM, _("Add to Custom Colours"))
self.basic_label = wx.StaticText(self, -1, _("Basic Colours:"))
self.custom_label = wx.StaticText(self, -1, _("Custom Colours:"))
self.add_button = wx.Button(self, self.idADD_CUSTOM, _("Add to Custom Colours"))
EVT_BUTTON(self, self.idADD_CUSTOM, self.onAddCustom)
self.Bind(wx.EVT_BUTTON, self.onAddCustom, self.add_button)
# Since we're going to be constructing widgets that require some serious
# computation, let's process any events (like redraws) right now
wxYield()
wx.Yield()
# Create the basic colours palette
self.colour_boxs = [ ]
colour_grid = wxGridSizer(6, 8)
colour_grid = wx.GridSizer(6, 8)
for name in self.colour_names:
new_id = wxNewId()
new_id = wx.NewId()
box = pycolourbox.PyColourBox(self, new_id)
EVT_LEFT_DOWN(box.GetColourBox(), lambda x, b=box: self.onBasicClick(x, b))
box.GetColourBox().Bind(wx.EVT_LEFT_DOWN, lambda x, b=box: self.onBasicClick(x, b))
self.colour_boxs.append(box)
colour_grid.Add(box, 0, wxEXPAND)
colour_grid.Add(box, 0, wx.EXPAND)
# Create the custom colours palette
self.custom_boxs = [ ]
custom_grid = wxGridSizer(2, 8)
custom_grid = wx.GridSizer(2, 8)
for wxcolour, slidepos in self.custom_colours:
new_id = wxNewId()
new_id = wx.NewId()
custom = pycolourbox.PyColourBox(self, new_id)
EVT_LEFT_DOWN(custom.GetColourBox(), lambda x, b=custom: self.onCustomClick(x, b))
custom.GetColourBox().Bind(wx.EVT_LEFT_DOWN, lambda x, b=custom: self.onCustomClick(x, b))
custom.SetColour(wxcolour)
custom_grid.Add(custom, 0, wxEXPAND)
custom_grid.Add(custom, 0, wx.EXPAND)
self.custom_boxs.append(custom)
csizer = wxBoxSizer(wxVERTICAL)
csizer = wx.BoxSizer(wx.VERTICAL)
csizer.Add((1, 25))
csizer.Add(self.basic_label, 0, wxEXPAND)
csizer.Add(self.basic_label, 0, wx.EXPAND)
csizer.Add((1, 5))
csizer.Add(colour_grid, 0, wxEXPAND)
csizer.Add(colour_grid, 0, wx.EXPAND)
csizer.Add((1, 25))
csizer.Add(self.custom_label, 0, wxEXPAND)
csizer.Add(self.custom_label, 0, wx.EXPAND)
csizer.Add((1, 5))
csizer.Add(custom_grid, 0, wxEXPAND)
csizer.Add(custom_grid, 0, wx.EXPAND)
csizer.Add((1, 5))
csizer.Add(self.add_button, 0, wxEXPAND)
csizer.Add(self.add_button, 0, wx.EXPAND)
self.palette = pypalette.PyPalette(self, -1)
self.colour_slider = pycolourslider.PyColourSlider(self, -1)
self.slider = wxSlider(self, self.idSCROLL, 86, 0, self.colour_slider.HEIGHT - 1,
style=wxSL_VERTICAL, size=wxSize(15, self.colour_slider.HEIGHT))
EVT_COMMAND_SCROLL(self, self.idSCROLL, self.onScroll)
psizer = wxBoxSizer(wxHORIZONTAL)
self.slider = wx.Slider(
self, self.idSCROLL, 86, 0, self.colour_slider.HEIGHT - 1,
style=wx.SL_VERTICAL, size=(15, self.colour_slider.HEIGHT)
)
self.Bind(wx.EVT_COMMAND_SCROLL, self.onScroll, self.slider)
psizer = wx.BoxSizer(wx.HORIZONTAL)
psizer.Add(self.palette, 0, 0)
psizer.Add((10, 1))
psizer.Add(self.colour_slider, 0, wxALIGN_CENTER_VERTICAL)
psizer.Add(self.slider, 0, wxALIGN_CENTER_VERTICAL)
psizer.Add(self.colour_slider, 0, wx.ALIGN_CENTER_VERTICAL)
psizer.Add(self.slider, 0, wx.ALIGN_CENTER_VERTICAL)
# Register mouse events for dragging across the palette
EVT_LEFT_DOWN(self.palette, self.onPaletteDown)
EVT_LEFT_UP(self.palette, self.onPaletteUp)
EVT_MOTION(self.palette, self.onPaletteMotion)
self.palette.Bind(wx.EVT_LEFT_DOWN, self.onPaletteDown)
self.palette.Bind(wx.EVT_LEFT_UP, self.onPaletteUp)
self.palette.Bind(wx.EVT_MOTION, self.onPaletteMotion)
self.mouse_down = False
self.solid = pycolourbox.PyColourBox(self, -1, size=wxSize(75, 50))
slabel = wxStaticText(self, -1, _("Solid Colour"))
ssizer = wxBoxSizer(wxVERTICAL)
self.solid = pycolourbox.PyColourBox(self, -1, size=(75, 50))
slabel = wx.StaticText(self, -1, _("Solid Colour"))
ssizer = wx.BoxSizer(wx.VERTICAL)
ssizer.Add(self.solid, 0, 0)
ssizer.Add((1, 2))
ssizer.Add(slabel, 0, wxALIGN_CENTER_HORIZONTAL)
ssizer.Add(slabel, 0, wx.ALIGN_CENTER_HORIZONTAL)
hlabel = wxStaticText(self, -1, _("H:"))
self.hentry = wxTextCtrl(self, -1)
hlabel = wx.StaticText(self, -1, _("H:"))
self.hentry = wx.TextCtrl(self, -1)
self.hentry.SetSize((40, -1))
slabel = wxStaticText(self, -1, _("S:"))
self.sentry = wxTextCtrl(self, -1)
slabel = wx.StaticText(self, -1, _("S:"))
self.sentry = wx.TextCtrl(self, -1)
self.sentry.SetSize((40, -1))
vlabel = wxStaticText(self, -1, _("V:"))
self.ventry = wxTextCtrl(self, -1)
vlabel = wx.StaticText(self, -1, _("V:"))
self.ventry = wx.TextCtrl(self, -1)
self.ventry.SetSize((40, -1))
hsvgrid = wxFlexGridSizer(1, 6, 2, 2)
hsvgrid = wx.FlexGridSizer(1, 6, 2, 2)
hsvgrid.AddMany ([
(hlabel, 0, wxALIGN_CENTER_VERTICAL), (self.hentry, 0, 0),
(slabel, 0, wxALIGN_CENTER_VERTICAL), (self.sentry, 0, 0),
(vlabel, 0, wxALIGN_CENTER_VERTICAL), (self.ventry, 0, 0),
(hlabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.hentry, 0, 0),
(slabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.sentry, 0, 0),
(vlabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.ventry, 0, 0),
])
rlabel = wxStaticText(self, -1, _("R:"))
self.rentry = wxTextCtrl(self, -1)
rlabel = wx.StaticText(self, -1, _("R:"))
self.rentry = wx.TextCtrl(self, -1)
self.rentry.SetSize((40, -1))
glabel = wxStaticText(self, -1, _("G:"))
self.gentry = wxTextCtrl(self, -1)
glabel = wx.StaticText(self, -1, _("G:"))
self.gentry = wx.TextCtrl(self, -1)
self.gentry.SetSize((40, -1))
blabel = wxStaticText(self, -1, _("B:"))
self.bentry = wxTextCtrl(self, -1)
blabel = wx.StaticText(self, -1, _("B:"))
self.bentry = wx.TextCtrl(self, -1)
self.bentry.SetSize((40, -1))
lgrid = wxFlexGridSizer(1, 6, 2, 2)
lgrid = wx.FlexGridSizer(1, 6, 2, 2)
lgrid.AddMany([
(rlabel, 0, wxALIGN_CENTER_VERTICAL), (self.rentry, 0, 0),
(glabel, 0, wxALIGN_CENTER_VERTICAL), (self.gentry, 0, 0),
(blabel, 0, wxALIGN_CENTER_VERTICAL), (self.bentry, 0, 0),
(rlabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.rentry, 0, 0),
(glabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.gentry, 0, 0),
(blabel, 0, wx.ALIGN_CENTER_VERTICAL), (self.bentry, 0, 0),
])
gsizer = wxGridSizer(2, 1)
gsizer = wx.GridSizer(2, 1)
gsizer.SetVGap (10)
gsizer.SetHGap (2)
gsizer.Add(hsvgrid, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
gsizer.Add(lgrid, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
gsizer.Add(hsvgrid, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
gsizer.Add(lgrid, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
hsizer = wxBoxSizer(wxHORIZONTAL)
hsizer.Add(ssizer, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
hsizer.Add(gsizer, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
hsizer.Add(ssizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
hsizer.Add(gsizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
vsizer = wxBoxSizer(wxVERTICAL)
vsizer = wx.BoxSizer(wx.VERTICAL)
vsizer.Add((1, 5))
vsizer.Add(psizer, 0, 0)
vsizer.Add((1, 15))
vsizer.Add(hsizer, 0, wxEXPAND)
vsizer.Add(hsizer, 0, wx.EXPAND)
sizer = wxBoxSizer(wxHORIZONTAL)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add((5, 1))
sizer.Add(csizer, 0, wxEXPAND)
sizer.Add(csizer, 0, wx.EXPAND)
sizer.Add((10, 1))
sizer.Add(vsizer, 0, wxEXPAND)
sizer.Add(vsizer, 0, wx.EXPAND)
self.SetAutoLayout(True)
self.SetSizer(sizer)
sizer.Fit(self)
@@ -232,7 +247,7 @@ class wxPyColourChooser(wxPanel):
def InitColours(self):
"""Initializes the pre-set palette colours."""
for i in range(len(self.colour_names)):
colour = wxTheColourDatabase.FindColour(self.colour_names[i])
colour = wx.TheColourDatabase.FindColour(self.colour_names[i])
self.colour_boxs[i].SetColourTuple((colour.Red(),
colour.Green(),
colour.Blue()))
@@ -364,12 +379,12 @@ class wxPyColourChooser(wxPanel):
def main():
"""Simple test display."""
class App(wxApp):
class App(wx.App):
def OnInit(self):
frame = wxFrame(NULL, -1, 'PyColourChooser Test')
frame = wx.Frame(None, -1, 'PyColourChooser Test')
chooser = wxPyColourChooser(frame, -1)
sizer = wxBoxSizer(wxVERTICAL)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(chooser, 0, 0)
frame.SetAutoLayout(True)
frame.SetSizer(sizer)
@@ -378,7 +393,7 @@ def main():
frame.Show(True)
self.SetTopWindow(frame)
return True
app = App()
app = App(False)
app.MainLoop()
if __name__ == '__main__':

View File

@@ -16,9 +16,15 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
import canvas
import colorsys
from wxPython.wx import *
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o 2.5 compatability update.
#
import wx
import canvas
import colorsys
class PyColourSlider(canvas.Canvas):
"""A Pure-Python Colour Slider
@@ -41,8 +47,7 @@ class PyColourSlider(canvas.Canvas):
# drawing function
self.SetBaseColour(colour)
canvas.Canvas.__init__(self, parent, id,
size=wxSize(self.WIDTH, self.HEIGHT))
canvas.Canvas.__init__(self, parent, id, size=(self.WIDTH, self.HEIGHT))
def SetBaseColour(self, colour):
"""Sets the base, or target colour, to use as the central colour
@@ -76,7 +81,7 @@ class PyColourSlider(canvas.Canvas):
vstep = 1.0 / self.HEIGHT
for y_pos in range(0, self.HEIGHT):
r,g,b = [c * 255.0 for c in colorsys.hsv_to_rgb(h,s,v)]
colour = wxColour(int(r), int(g), int(b))
self.buffer.SetPen(wxPen(colour, 1, wxSOLID))
colour = wx.Colour(int(r), int(g), int(b))
self.buffer.SetPen(wx.Pen(colour, 1, wx.SOLID))
self.buffer.DrawRectangle((0, y_pos), (15, 1))
v = v - vstep

View File

@@ -15,11 +15,19 @@ This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
"""
# 12/14/2003 - Jeff Grimmett (grimmtooth@softhome.net)
#
# o 2.5 compatability update.
#
import cStringIO
import zlib
import wx
import canvas
import colorsys
import canvas
import colorsys
import cStringIO, zlib
from wxPython.wx import *
# Bitmap functions generated from img2py
def getData():
@@ -128,11 +136,11 @@ L\x1a\xc5\x9c\x88U\xde\xc7\x9d\xd04\x04\x8en\x11\x8112\xbd\xf6J\x96wP\x06\
\xc5\x8e\x1a\xd5\x84\x8b\x7f\x8f\x01\x0e6\x8e\xd6eV~W\xff\x01[x\x1b=' )
def getBitmap():
return wxBitmapFromImage(getImage())
return wx.BitmapFromImage(getImage())
def getImage():
stream = cStringIO.StringIO(getData())
return wxImageFromStream(stream)
return wx.ImageFromStream(stream)
class PyPalette(canvas.Canvas):
"""The Pure-Python Palette
@@ -156,8 +164,9 @@ class PyPalette(canvas.Canvas):
def __init__(self, parent, id):
"""Creates a palette object."""
# Load the pre-generated palette XPM
wx.InitAllImageHandlers()
self.palette = getBitmap ()
canvas.Canvas.__init__ (self, parent, id, size=wxSize(200, 192))
canvas.Canvas.__init__ (self, parent, id, size=(200, 192))
def GetValue(self, x, y):
"""Returns a colour value at a specific x, y coordinate pair. This
@@ -173,9 +182,9 @@ class PyPalette(canvas.Canvas):
def HighlightPoint(self, x, y):
"""Highlights an area of the palette with a little circle around
the coordinate point"""
colour = wxColour(0, 0, 0)
self.buffer.SetPen(wxPen(colour, 1, wxSOLID))
self.buffer.SetBrush(wxBrush(colour, wxTRANSPARENT))
colour = wx.Colour(0, 0, 0)
self.buffer.SetPen(wx.Pen(colour, 1, wx.SOLID))
self.buffer.SetBrush(wx.Brush(colour, wx.TRANSPARENT))
self.buffer.DrawCircle((x, y), 3)
self.Refresh()
@@ -201,13 +210,13 @@ class PyPalette(canvas.Canvas):
for x in range(0, width, self.HORIZONTAL_STEP):
hue = float(x) / float(width)
r,g,b = colorsys.hsv_to_rgb(hue, saturation, value)
colour = wxColour(int(r * 255.0), int(g * 255.0), int(b * 255.0))
self.buffer.SetPen(wxPen(colour, 1, wxSOLID))
self.buffer.SetBrush(wxBrush(colour, wxSOLID))
colour = wx.Colour(int(r * 255.0), int(g * 255.0), int(b * 255.0))
self.buffer.SetPen(wx.Pen(colour, 1, wx.SOLID))
self.buffer.SetBrush(wx.Brush(colour, wx.SOLID))
self.buffer.DrawRectangle((x, y),
(self.HORIZONTAL_STEP, self.vertical_step))
# this code is now simpler (and works)
bitmap = self.buffer.GetBitmap()
image = wxImageFromBitmap(bitmap)
image.SaveFile (file_name, wxBITMAP_TYPE_XPM)
image = wx.ImageFromBitmap(bitmap)
image.SaveFile (file_name, wx.BITMAP_TYPE_XPM)