colors missed under Windows XP ?

If you try the following app, as i can see, under Linux all work well but
under windows some colors was missing.

Someone have any ideas ?

Oz
=========================8<=======================
#!/usr/bin/env python

···

######################################################################
# Name: DrawSpace #
# Purpose: Draving Area Ready to use #
# #
# Author: Pinassi "O-Zone" Michele <o-zone@siena.linux.it> #
# Licence: Same as wxPython's #
# #
# v1.0 - Initial Release #
# #
######################################################################

import wx
import wx.lib.colourdb

class DrawSpace(wx.Window):
  def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=wx.SUNKEN_BORDER, name=""):
    
    wx.Window.__init__(self, parent, id, pos, size, style, name)

    self.parent = parent

    self.bgColour = wx.Colour(180, 233, 255)
    self.fgColour = wx.Colour(74,114,255)
    
    self.SetForegroundColour(wx.Colour(0, 204, 204))

    # Event handling
    self.Bind(wx.EVT_PAINT, self.OnPaint)
    self.Bind(wx.EVT_SIZE, self.OnSize)
    
    self._drawBuffer = None
    
  def OnSize(self, event):
    #self.Clear()
    pass
    
  def OnPaint(self, evt):
    if self._drawBuffer is not None:
        dc = wx.BufferedDC(wx.PaintDC(self),self._drawBuffer)
    else:
        wx.PaintDC(self)
        
  def _selColours(self, colour, dc):
    dc.SetPen(wx.Pen(colour, 1, wx.SOLID))
    dc.SetBrush(wx.Brush(colour, wx.SOLID))

  def SetValue(self, value, x, y, fontsize=16):
    print "SetValue function is deprecated."
    self.SetText(value,x,y,fontsize)

  def SetText(self, text, x, y, fontsize=16, color=None):
    dc = wx.BufferedDC(wx.ClientDC(self),self._drawBuffer)
    #font = wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False,
"Minisystem")
    font = wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, "Arial")
    dc.SetFont(font)
    if color is None:
        dc.SetTextForeground("BLACK")
    else:
        dc.SetTextForeground(color)
        
    dc.DrawText(text,x,y)
      
  def DrawPoint(self,x,y,color):
    dc = wx.BufferedDC(wx.ClientDC(self),self._drawBuffer)
    self._selColours(color, dc)
    dc.DrawPoint(x, y)
    self.Refresh()
      
  def ClearRect(self,sw,sh,ew,eh):
    dc = wx.BufferedDC(wx.ClientDC(self),self._drawBuffer)
    self._selColours(self.bgColour, dc)
    dc.DrawRectangle(sw, sh, ew, eh)
    self.Refresh()

  def Clear(self,bgColor=None):
    w, h = self.GetSizeTuple()
    self._drawBuffer = wx.EmptyBitmap(w,h)
    dc = wx.BufferedDC(wx.ClientDC(self),self._drawBuffer)
    if bgColor is not None:
        self.bgColour = bgColor
    self._selColours(self.bgColour, dc)
    dc.DrawRectangle(0, 0, w, h)
    self.Refresh()
    
  def DrawRect(self,sw,sh,ew,eh,col):
    dc = wx.BufferedDC(wx.ClientDC(self),self._drawBuffer)
    self._selColours(col, dc)
    dc.DrawRectangle(sw, sh, ew, eh)
    self.Refresh()

  def DrawRectList(self,list,col):
    dc = wx.BufferedDC(wx.ClientDC(self),self._drawBuffer)
    self._selColours(col, dc)
    dc.DrawRectangleList(list)
    self.Refresh()

  def DrawBitmap(self,bmp,x,y):
    dc = wx.BufferedDC(wx.ClientDC(self),self._drawBuffer)
    dc.DrawBitmap(bmp, x, y, useMask=True)
    self.Refresh()
  
  def GetDC(self):
    return wx.BufferedDC(wx.ClientDC(self),self._drawBuffer)
  
class MyFrame(wx.Frame):
  def __init__(self, *args, **kwds):
    # begin wxGlade: MyFrame.__init__
    kwds["style"] = wx.DEFAULT_FRAME_STYLE
    wx.Frame.__init__(self, *args, **kwds)
    self.window_1 = DrawSpace(self, -1)

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

    self.Bind(wx.EVT_TIMER, self.OnTimer)
    
    self.t1 = wx.Timer(self)
    self.t1.Start(100)

  def __set_properties(self):
    # begin wxGlade: MyFrame.__set_properties
    self.SetTitle("frame_1")
    # end wxGlade

  def __do_layout(self):
    # begin wxGlade: MyFrame.__do_layout
    sizer_1 = wx.BoxSizer(wx.VERTICAL)
    sizer_1.Add(self.window_1, 1, wx.EXPAND, 0)
    self.SetAutoLayout(True)
    self.SetSizer(sizer_1)
    sizer_1.Fit(self)
    sizer_1.SetSizeHints(self)
    self.Layout()
    # end wxGlade

  def DISPLAY_DrawLevels(self,dc,level,mul=1):
        colors =
['FORESTGREEN','FORESTGREEN','GREEN','GREEN','GREEN','GREEN','GREENYELLOW','GREENYELLOW','YELLOW','YELLOW','YELLOW','YELLOW','GOLD','GOLD','ORANGE','ORANGE','ORANGERED','ORANGERED','RED','RED']
        dc.SetBackground(wx.Brush('LIGHTGRAY', wx.SOLID))
        dc.Clear()
        rectangles = []
        rect_colors = []
        pen = wx.Pen('LIGHTGRAY',1, wx.SOLID)
        y = 178
        for i in range(20):
      if (level * mul) >= i:
          rectangles.append([1,y,13,9])
          rect_colors.append(wx.Brush(colors[i], wx.SOLID))
          y = y - 9
        
        dc.DrawRectangleList(rectangles,pen,rect_colors)

  def OnTimer(self, event): # Chiamata ogni secondo
    import random
    self.window_1.Clear()
    self.DISPLAY_DrawLevels(self.window_1.GetDC(),random.randint(1, 20))
    
# end of class MyFrame

class MyApp(wx.App):
  def OnInit(self):
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    self.SetTopWindow(frame_1)
    frame_1.Show()
    return 1
# end of class MyApp

if __name__ == "__main__":
  app = MyApp(0)
  app.MainLoop()
=========================8<=======================
  
--
----
O-Zone ! No (C) 2005
WEB @ http://www.zerozone.it
HOBBY @ http://peggy.altervista.org
Call me with FWD: 692329

Hello Michele,

I made a few changes, so it should work on Windows.

If you try the following app, as i can see, under Linux all work well but
under windows some colors was missing.

Someone have any ideas ?

Oz

[...]
      for i in range(20):
    if (level * mul) >= i:
        rectangles.append([1,y,13,9])

insert: rect_colors.append(wx.Brush(wx.TheColourDatabase.Find(colors[i]), wx.SOLID))
delete: rect_colors.append(wx.Brush(colors[i], wx.SOLID))

        y = y - 9
      
      dc.DrawRectangleList(rectangles,pen,rect_colors)

def OnTimer(self, event): # Chiamata ogni secondo
  import random
  self.window_1.Clear()
  self.DISPLAY_DrawLevels(self.window_1.GetDC(),random.randint(1, 20))
  
# end of class MyFrame

class MyApp(wx.App):
def OnInit(self):
  wx.InitAllImageHandlers()

insert: wx.lib.colourdb.updateColourDB()

···

On Wed, 28 Sep 2005 13:51:13 +0200, "Michele \"O-Zone\" Pinassi" <liste@zerozone.it> wrote:

  frame_1 = MyFrame(None, -1, "")
  self.SetTopWindow(frame_1)
  frame_1.Show()
  return 1
# end of class MyApp

--
Franz Steinhaeusler