phoenix_title wx.PowerResourceBlocker

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.


class_hierarchy Class Hierarchy

Inheritance diagram for class PowerResourceBlocker:

method_summary Methods Summary

__init__

Acquires the power resource.

IsInEffect

Returns whether the power resource could be acquired.

__enter__

__exit__


api Class API

class wx.PowerResourceBlocker(object)

Possible constructors:

PowerResourceBlocker(kind, reason="")

Helper RAII class ensuring that power resources are released.


Methods

__init__(self, kind, reason="")

Acquires the power resource.

Uses the same parameters as wx.PowerResource.Acquire .

Parameters


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.

Return type

bool



__enter__(self)


__exit__(self, exc_type, exc_val, exc_tb)