A really basic drawing question

Phil <[email protected]>
Newsgroups gmane.comp.python.wxpython
Message-ID <[email protected]>
Thank you for reading this.

It's been awhile since I've done anything useful with wxPython and I 
find that I now cannot get past a very basic concept.

I want to call Fill_board() but even though the function is called it's 
not drawing anything, just a blank window is displayed. It must have 
something to do with a drawing context.

class Mywin(wx.Frame):
     def __init__(self, parent, title):
         super(Mywin, self).__init__(parent, title=title, size=(500, 400))

         self.Bind(wx.EVT_PAINT, self.OnPaint)

         self.InitUI()

     def InitUI(self):

         self.Bind(wx.EVT_PAINT, self.OnPaint)
         self.Centre()
         self.Show(True)

         self.Fill_board(self) ---> Fill_board() is called but it's not 
drawing anything.

      def Fill_board(self, dc):
         dc = wx.ClientDC(self)

         dc.SetPen(wx.BLACK_PEN)

         for y in range(board_y):
             for x in range(board_x):
                 dc.SetBrush(random.choice(colours))
                 dc.DrawRectangle(x * 20 + 100, y * 20, 20, 20)

However, if I call Fill_board() from an event such as a paint event (as 
shown below) or a timer event, then a filled board is displayed.

      def OnPaint(self, e):
         dc = wx.PaintDC(self)
         self.Fill_board(dc)  ---> if called from an event such as 
OnPaint() then all is good.

I've searched through wxdemo examples but haven't found anything as 
simple as what I'm asking about. What am I missing?

-- 

Regards,
Phil

-- 
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/c11ecb5d-c227-96a1-29a3-c55988e2d9bc%40gmail.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.