KDE 4.2 PyKDE API Reference

- KDE's Python API

# KCapacityBar Class Reference

`from PyKDE4.kdeui import *`

Inherits: QWidget → QObject

## Detailed Description

This widget shows a bar which is filled to show the level of usage of a certain device.

This widget represents a bar which goal is to show the level of usage of a device. Its look is similar to a progress bar, but different, because this widget does not want to give a notion of progress.

Since:
  4.2

Author:
  Rafael Fernández López <ereslibre@kde.org>

## Enumerations

DrawTextMode | { DrawTextInline, DrawTextOutline }

## Methods

| __init__ (self, KCapacityBar.DrawTextMode drawTextMode=KCapacityBar.DrawTextOutline, QWidget parent=0)
int | barHeight (self)
| changeEvent (self, QEvent event)
bool | continuous (self)
| drawCapacityBar (self, QPainter p, QRect rect)
bool | fillFullBlocks (self)
Qt.Alignment | horizontalTextAlignment (self)
QSize | minimumSizeHint (self)
| paintEvent (self, QPaintEvent event)
| setBarHeight (self, int barHeight)
| setContinuous (self, bool continuous)
| setFillFullBlocks (self, bool fillFullBlocks)
| setHorizontalTextAlignment (self, Qt.Alignment textAlignment)
| setText (self, QString text)
| setValue (self, int value)
QString | text (self)
int | value (self)

## Method Documentation

__init__ | ( | self, |
|  | KCapacityBar.DrawTextMode | drawTextMode=KCapacityBar.DrawTextOutline,
|  | QWidget | parent=0
| ) |  |  |

Capacity bar constructor.

Parameters:

  | drawTextMode | If any text set, whether to draw it into the capacity bar or not.
  | parent | The parent of the widget.

int barHeight | ( |  | self ) |

Returns:
  The preferred height of the capacity bar.

changeEvent | ( | self, |
|  | QEvent | event
| ) |  |  |

bool continuous | ( |  | self ) |

Returns:
  Whether the fill of the capacity bar should be continuous or block-based.

drawCapacityBar | ( | self, |
|  | QPainter | p,
|  | QRect | rect
| ) |  |  |

This method allows you to draw the widget, directly, for example on item delegates. You only need the painter object and the rect where this widget should be drawn.

bool fillFullBlocks | ( |  | self ) |

Returns:
  Whether the last block shown can be cut off when necessary.

Qt.Alignment horizontalTextAlignment | ( |  | self ) |

Returns:
  The horizontal alignment for the text that will be drawn.

QSize minimumSizeHint | ( |  | self ) |

paintEvent | ( | self, |
|  | QPaintEvent | event
| ) |  |  |

setBarHeight | ( | self, |
|  | int | barHeight
| ) |  |  |

Sets the height (in pixels) of the bar.

Parameters:

  | barHeight | The preferred height (in pixels) of the capacity bar.

Note:
  If you set a certain text and the capacity bar is in inline mode, the height of the bar will be the maximum of the font height and this value.

Note:
  If you set a certain text and the capacity bar is in outline mode, the height of the whole capacity bar will be bigger than this value. Take in count the height of this widget is got from adding the bar height, the font metrics height and a small separator between the bar and the outline text.

Note:
  Its value is 12 pixels by default.

setContinuous | ( | self, |
|  | bool | continuous
| ) |  |  |

Sets whether the fill of the capacity bar should be continuous or in block mode.

Parameters:

  | continuous | If true, the fill of the capacity bar is done in a continuous way. In other case, the fill is done with separated blocks.

Note:
  Its value is true by default.

setFillFullBlocks | ( | self, |
|  | bool | fillFullBlocks
| ) |  |  |

When the capacity bar is non-continuous, sets whether the last block shown should be drawn full or can be cut off (depending on the capacity bar width, and the value set on it).

Parameters:

  | fillFullBlocks | If true, the last block drawn will be fully filled, on other case, the last block drawn could be cut off.

Note:
  This method is only relevant if the capacity bar is in non-continuous mode.

Note:
  Its value is true by default.

See also:
  setContinuous, continuous

setHorizontalTextAlignment | ( | self, |
|  | Qt.Alignment | textAlignment
| ) |  |  |

If the capacity bar is in outline text mode, draw the text with textAlignment alignment.

Parameters:

  | textAlignment | Sets the horizontal alignment for the text if the capacity bar is in outline text mode.

Note:
  If textAlignemt contains vertical alignment flags, they will be ignored.

Note:
  If the capacity bar is in inline text mode, the text is always centered, and both vertical and horizontal flags set through this method are ignored.

Note:
  Its value is centered by default.

setText | ( | self, |
|  | QString | text
| ) |  |  |

Sets the text for the capacity bar.

Parameters:

  | text | The text that the capacity bar will show.

Note:
  This is an empty string by default.

setValue | ( | self, |
|  | int | value
| ) |  |  |

Capacity bar fill value.

Parameters:

  | value | This parameter can take values from 0 to 100.

Note:
  Its value is 0 by default.

QString text | ( |  | self ) |

Returns:
  The text that the capacity bar will show.

int value | ( |  | self ) |

Returns:
  The fill value of the capacity bar.

## Enumeration Documentation

DrawTextMode

Enumerator:

  DrawTextInline = 0 |
  DrawTextOutline |