The resizePolicy module

The resizePolicy module contains the ResizePolicy class which encapsulates a specific policy for resizing widgets.

The ResizePolicy class

Inheritance diagram of pyamp.ui.qt.resizePolicy.ResizePolicy

class pyamp.ui.qt.resizePolicy.ResizePolicy[source]

The ResizePolicy encapsulates a specific policy for resizing widgets.

The possible resize policies are:

  • Fixed – The size never changes
  • Expanding – The size expands

For a specific policy, the ResizePolicy class can return the correct size for a widget, given the widget’s current size as well as the size of all of the widget’s child widgets.

For the Fixed resize policy: the size will always remain the same.

For the Expanding resize policy: the size will always expand to fit all of the widget’s children.

Example:

from PyQt4 import QtCore
from pyamp.ui.qt import ResizePolicy

# Create the size of the widget, and the list of sizes for all of
# the widget's children
size = QtCore.QSize(100, 200)
childSizes = [QtCore.QSize(200, 500), QtCore.QSize(300, 400)]

# Get the list of widths and heights for the child widgets
childWidths = map(QtCore.QSize.width, childSizes)
childHeights = map(QtCore.QSize.width, childSizes)

# Both of these return: 100
# Which is the given value of width
ResizePolicy.getSize(ResizePolicy.Fixed, size.width(), childWidths)
ResizePolicy.getWidth(ResizePolicy.Fixed, size, childSizes)

# Both of these return: 900
# Which is the sum of the childHeights list
ResizePolicy.getSize(ResizePolicy.Expanding, size.height(),
                     childHeights)
ResizePolicy.getHeight(ResizePolicy.Fixed, size, childSizes)
classmethod getHeight(policy, size, sizeList)[source]

For the given resize policy, get the correct height for the size of the widget as well as the size of all of the widget’s children.

  • resizePolicy – The resize policy
  • size – The main PyQt4.QtCore.QSize of the widget
  • sizeList – The list of PyQt4.QtCore.QSize for sub widgets
classmethod getSize(policy, size, sizeList)[source]

Get the correct size based on the given resize policy.

  • resizePolicy – The resize policy

  • size – The main single size (width or height) of the widget

  • sizeList – The list of the single dimension size (widths or heights)

    of widgets’s children

classmethod getWidth(policy, size, sizeList)[source]

For the given resize policy, get the correct width for the size of the widget as well as the size of all of the widget’s children.

  • resizePolicy – The resize policy
  • size – The main PyQt4.QtCore.QSize of the widget
  • sizeList – The list of PyQt4.QtCore.QSize for sub widgets

Table Of Contents

Previous topic

The keyEvents module

Next topic

The spacers module

This Page