.. 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.DPIChangedEvent: ========================================================================================================================================== |phoenix_title| **wx.DPIChangedEvent** ========================================================================================================================================== Event sent when the display scale factor or pixel density (measured in dots-per-inch, or ``DPI``) of the monitor a window is on changes. The event is sent to each :ref:`wx.TopLevelWindow` affected by the change, and all its children recursively (post-order traversal). For example, this event is sent to the window when it is moved, by the user, from a display using some ``DPI`` value to another display using a different ``DPI`` value. It also sent to all program windows on the given display if its ``DPI`` changes due to a change in the system settings. If you define an event handler for this event, you should almost always call ``event.Skip()`` in it in order to allow the base class handler to execute, as many controls rely on processing this event in order to update their appearance when the ``DPI`` changes. However the default handler for the top level window itself only sets the new window size, by scaling the current size by the ``DPI`` ratio – e.g. doubling it if the ``DPI`` has changed from normal to "high", i.e. 200%, one – and also ensuring that the window is still bigger than its best size, as returned by :meth:`wx.Window.GetBestSize` . Note that in some cases this may cause the window size to grow unexpectedly and you may prefer to call :meth:`wx.Window.SetSize` in your handler of this event for the top level window and `not` call ``event.Skip()`` to prevent the default handler from resizing the window. Currently this event is generated by wxMSW port if only and only if the MSW application runs under Windows 10 Creators Update (v1703) or later and is marked as being "per-monitor ``DPI`` aware", i.e. contains a ``dpiAwareness`` tag with the value "PerMonitorV2" in its manifest (see Microsoft `"Application Manifests" documentation `_ for more details). ^^ .. _DPIChangedEvent-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`wx.DPIChangedEvent` parameter. - EVT_DPI_CHANGED: Process a ``wxEVT_DPI_CHANGED`` event. ^^ .. versionadded:: 4.1/wxWidgets-3.1.3 .. seealso:: :ref:`Events and Event Handling ` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class DPIChangedEvent:
| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.DPIChangedEvent.GetNewDPI` Returns the new ``DPI``. :meth:`~wx.DPIChangedEvent.GetOldDPI` Returns the old ``DPI``. :meth:`~wx.DPIChangedEvent.Scale` Rescale a value in pixels to match the new ``DPI``. :meth:`~wx.DPIChangedEvent.ScaleX` Rescale horizontal component to match the new ``DPI``. :meth:`~wx.DPIChangedEvent.ScaleY` Rescale vertical component to match the new ``DPI``. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~wx.DPIChangedEvent.NewDPI` See :meth:`~wx.DPIChangedEvent.GetNewDPI` :attr:`~wx.DPIChangedEvent.OldDPI` See :meth:`~wx.DPIChangedEvent.GetOldDPI` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.DPIChangedEvent(Event) Event sent when the display scale factor or pixel density (measured in dots-per-inch, or ``DPI``) of the monitor a window is on changes. .. method:: GetNewDPI(self) Returns the new ``DPI``. :rtype: :ref:`wx.Size` .. method:: GetOldDPI(self) Returns the old ``DPI``. :rtype: :ref:`wx.Size` .. method:: Scale(self, sz) Rescale a value in pixels to match the new ``DPI``. This is a convenience function to use in wxEVT_DPI_CHANGED event handlers, as they often need to update some sizes to the new ``DPI``. It simply calls :meth:`MulDivInt32` with new and old ``DPI`` values, but is more readable and less error-prone. For example, the returned value will be twice bigger than the original one when switching from normal (96) ``DPI`` to high (2x, 192) ``DPI``. :param `sz`: :type `sz`: wx.Size :rtype: :ref:`wx.Size` .. versionadded:: 4.1/wxWidgets-3.1.6 .. method:: ScaleX(self, x) Rescale horizontal component to match the new ``DPI``. This is the same as :meth:`Scale` , but for the horizontal component only. :param `x`: :type `x`: int :rtype: `int` .. versionadded:: 4.1/wxWidgets-3.1.6 .. method:: ScaleY(self, y) Rescale vertical component to match the new ``DPI``. This is the same as :meth:`Scale` , but for the vertical component only. :param `y`: :type `y`: int :rtype: `int` .. versionadded:: 4.1/wxWidgets-3.1.6 .. attribute:: NewDPI See :meth:`~wx.DPIChangedEvent.GetNewDPI` .. attribute:: OldDPI See :meth:`~wx.DPIChangedEvent.GetOldDPI`