************* wx.PaintEvent ************* Inheritance diagram for `wx.PaintEvent`: | .. inheritance-diagram:: wx.PaintEvent | Description =========== A paint event is sent when a window's contents needs to be repainted. .. note:: Please notice that in general it is impossible to change the drawing of a standard control (such as `wx.Button <../Widgets/wx.Button.html>`_) and so you shouldn't attempt to handle paint events for them as even if it might work on some platforms, this is inherently not portable and won't work everywhere. Derived From ^^^^^^^^^^^^^ * `wx.Event `_ * `wx.Object <../Widgets/wx.Object.html>`_ Event Handling ^^^^^^^^^^^^^^ ================================================== ================================================== Event Name Description ================================================== ================================================== wx.EVT_PAINT(func) Process a ``wx.wxEVT_PAINT`` event. ================================================== ================================================== Remarks ^^^^^^^ Note that In a paint event handler, the application must *always* create a `wx.PaintDC <../Widgets/wx.PaintDC.html>`_ object, even if you do not use it. Otherwise, under MS Windows, refreshing for this and other windows will go wrong. For example:: def OnPaint(self, event): dc = wx.PaintDC(self) DrawMyDocument(dc) You can optimize painting by retrieving the rectangles that have been damaged and only repainting these. The rectangles are in terms of the client area, and are unscrolled, so you will need to do some calculations using the current view position to obtain logical, scrolled units. Here is an example of using the `wx.RegionIterator <../Widgets/wx.RegionIterator.html>`_ class:: def OnPaint(self, event): """ Called when window needs to be repainted. """ dc = wx.PaintDC(self) # Find Out where the window is scrolled to vbX, vbY = self.GetViewStart() # get the update rect list upd = wx.RegionIterator(self.GetUpdateRegion()) while upd.HaveRects(): rect = upd.GetRect() # Repaint this rectangle PaintRectangle(rect, dc) upd.Next() Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(Id=0) Constructors. **Parameters:** * `Id` (int) | **Returns:** `wx.PaintEvent `_