A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://wxpython.org/Phoenix/docs/html/wx.PowerResourceBlocker.html below:

wx.PowerResourceBlocker — wxPython Phoenix 4.2.4a1 documentation

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

Added in version 4.1/wxWidgets-3.1.0.

Class Hierarchy¶

Inheritance diagram for class

PowerResourceBlocker

:

Methods Summary¶ Class API¶
class wx.PowerResourceBlocker(object)¶

Possible constructors:

PowerResourceBlocker(kind, reason="") -> None

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:
Return type:

None


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)¶

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4