Helper RAII
class ensuring that power resources are released.
A wx.PowerResourceBlocker object acquires a power resource in the constructor and releases it in the destructor making it impossible to forget to release the power resource (which would prevent suspending or screen power off until the application ends).
Example:
blocker = wx.PowerResourceBlocker(
wx.POWER_RESOURCE_SYSTEM, "Downloading something important")
if not blocker.IsInEffect():
# If the resource could not be acquired, tell the user that he has
# to keep the system alive
wx.LogMessage("Warning: system may suspend while downloading.")
# Run an important download and the system will not suspend while downloading
for i in range(download.size()):
download.read_byte()
del blocker
# wx.POWER_RESOURCE_SYSTEM automatically released here.
Base ^^<>< =’’>:</>&;&;< =’’>\ </></>
New in version 4.1/wxWidgets-3.1.0.
See also
Acquires the power resource. |
|
Returns whether the power resource could be acquired. |
|
wx.
PowerResourceBlocker
(object)¶Possible constructors:
PowerResourceBlocker(kind, reason="")
Helper RAII
class ensuring that power resources are released.
__init__
(self, kind, reason="")¶Acquires the power resource.
Uses the same parameters as wx.PowerResource.Acquire
.
kind (PowerResourceKind) –
reason (string) –
IsInEffect
(self)¶Returns whether the power resource could be acquired.
This can be used to inform the user that the application will not prevent automatic suspending.
bool
See also
__enter__
(self)¶__exit__
(self, exc_type, exc_val, exc_tb)¶