1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2020 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.PaintEvent:
==========================================================================================================================================
|phoenix_title| **wx.PaintEvent**
==========================================================================================================================================
A paint event is sent when a window's contents needs to be repainted.
The handler of this event must create a :ref:`wx.PaintDC` object and use it for painting the window contents. For example: ::
def OnPaint(self, event):
dc = wx.PaintDC(self)
DrawMyDocument(dc)
Notice that you must `not` create other kinds of :ref:`wx.DC` (e.g. :ref:`wx.ClientDC` or :ref:`wx.WindowDC`) in ``EVT_PAINT`` handlers and also don't create :ref:`wx.PaintDC` outside of this event handlers.
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 :ref:`wx.RegionIterator` class: ::
# Called when window needs to be repainted.
def OnPaint(self, event):
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()
^^
.. _PaintEvent-events:
|events| Events Emitted by this Class
=====================================
Handlers bound for the following event types will receive a :ref:`wx.PaintEvent` parameter.
Event macros:
- EVT_PAINT: Process a ``wxEVT_PAINT`` event. ^^
.. note::
Please notice that in general it is impossible to change the drawing of a standard control (such as :ref:`wx.Button`) 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.
.. seealso:: :ref:`Events and Event Handling <events and event handling>`
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
<div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
<img id="toggleBlock-trigger" src="_static/images/closed.png"/>
Inheritance diagram for class <strong>PaintEvent</strong>:
</div>
<div id="toggleBlock-summary" style="display:block;"></div>
<div id="toggleBlock-content" style="display:none;">
<p class="graphviz">
<center><img src="_static/images/inheritance/wx.PaintEvent_inheritance.png" alt="Inheritance diagram of PaintEvent" usemap="#dummy" class="inheritance"/></center>
<script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
<map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.PaintEvent.html" title="wx.PaintEvent" alt="" coords="5,160,120,189"/> <area shape="rect" id="node2" href="wx.Event.html" title="wx.Event" alt="" coords="21,83,104,112"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="19,5,106,35"/> </map>
</p>
</div>
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.PaintEvent.__init__` Constructor for exclusive use of wxWidgets itself.
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.PaintEvent(Event)
**Possible constructors**::
PaintEvent(window)
A paint event is sent when a window's contents needs to be repainted.
.. method:: __init__(self, window)
Constructor for exclusive use of wxWidgets itself.
Note that the objects of this class can `not` be created from application code, they're only created by the library itself. If you need a window to be repainted, use :meth:`wx.Window.Refresh` instead of trying to manually create an event of this class.
:param `window`:
:type `window`: wx.Window
|