GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Table of Contents
  • wx.PowerResourceBlocker
  • Show Source
  • index
  • modules
  • next
  • previous
  • Home
  • Gallery
  • wx

This view

  • Original page
  • New address

GeezerVison is showing docs.wxpython.org — wx.PowerResourceBlocker — wxPython 4.3.2 Docs

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.

Core

Added in version 4.1/wxWidgets-3.1.0.

See also

wx.PowerResource


class_hierarchy Class Hierarchy¶

Inheritance diagram for class PowerResourceBlocker:

Inheritance diagram of 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="", blockKind=POWER_PREVENT) -> None

Helper RAII class ensuring that power resources are released.


Methods¶

__init__(self, kind, reason='', blockKind=POWER_PREVENT)¶

Acquires the power resource.

Uses the same parameters as wx.PowerResource.Acquire .

Parameters:
  • kind (PowerResourceKind)

  • reason (string)

  • blockKind (PowerBlockKind)

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

See also

wx.PowerResource.Acquire



__enter__(self)¶


__exit__(self, exc_type, exc_val, exc_tb)¶
© Copyright 2012-2026, The wxPython Team. Created using Sphinx 9.1.0 and the python-docs-theme.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.