KDE 4.9 PyKDE API Reference

- KDE's Python API

# View Class Reference

`from PyKDE4.plasma import *`

Inherits: QGraphicsView → QAbstractScrollArea → QFrame → QWidget → QObject
Namespace: Plasma

## Detailed Description

View plasma/view.h <Plasma/View>

A QGraphicsView for a single Containment

Each View is associated with a Plasma.Containment and tracks geometry changes, maps to the current desktop (if any) among other helpful utilities. It isn't stricly required to use a Plasma.View with Plasma enabled applications, but it can make some things easier.

## Signals

| lostContainment ()
| sceneRectAboutToChange ()
| sceneRectChanged ()

## Methods

| __init__ (self, Plasma.Containment containment, QWidget parent=0)
| __init__ (self, Plasma.Containment containment, int viewId, QWidget parent=0)
KConfigGroup | config (self)
| configNeedsSaving (self)
Plasma.Containment | containment (self)
int | desktop (self)
int | effectiveDesktop (self)
int | id (self)
bool | isWallpaperEnabled (self)
int | screen (self)
| setContainment (self, Plasma.Containment containment)
| setScreen (self, int screen, int desktop=-1)
| setTrackContainmentChanges (self, bool trackChanges)
| setWallpaperEnabled (self, bool draw)
Plasma.Containment | swapContainment (self, Plasma.Containment existing, QString name, [QVariant] args=QVariantList())
Plasma.Containment | swapContainment (self, QString name, [QVariant] args=QVariantList())
bool | trackContainmentChanges (self)

## Static Methods

Plasma.View | topLevelViewAt (QPoint pos)

## Signal Documentation

lostContainment | ( |  | ) |

This is emitted after the containment is destroyed, for views that need to do something about it (like find a new one).

Signal syntax:
  `QObject.connect(source, SIGNAL("lostContainment()"), target_slot)`

sceneRectAboutToChange | ( |  | ) |

This signal is emitted whenever the containment being viewed has changed its geometry, but before the View has shifted the viewd scene rect to the new geometry. This is useful for Views which want to keep their rect() in sync with the containment'sa

Signal syntax:
  `QObject.connect(source, SIGNAL("sceneRectAboutToChange()"), target_slot)`

sceneRectChanged | ( |  | ) |

This signal is emitted whenever the containment being viewed has changed its geometry, and after the View has shifted the viewd scene rect to the new geometry. This is useful for Views which want to keep their rect() in sync with the containment's.

Signal syntax:
  `QObject.connect(source, SIGNAL("sceneRectChanged()"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | Plasma.Containment | containment,
|  | QWidget | parent=0
| ) |  |  |

Constructs a view for a given contanment. An Id is automatically assigned to the View.

Parameters:

  | containment | the containment to center the view on
  | parent | the parent object for this view

__init__ | ( | self, |
|  | Plasma.Containment | containment,
|  | int | viewId,
|  | QWidget | parent=0
| ) |  |  |

Constructs a view for a given contanment.

Parameters:

  | containment | the containment to center the view on
  | viewId | the id to assign to this view
  | parent | the parent object for this view

KConfigGroup config | ( |  | self ) |

Returns:
  a KConfigGroup in the application's config file unique to the view

configNeedsSaving | ( |  | self ) |

Requests that the config be synchronized to disk

Plasma.Containment containment | ( |  | self ) |

Returns:
  the containment associated with this view, or 0 if none is

int desktop | ( |  | self ) |

The virtual desktop this view is associated with

Returns:
  the desktop number, -1 for all desktops and less than -1 for none

int effectiveDesktop | ( |  | self ) |

The virtual desktop this view is actually being viewed on

Returns:
  the desktop number (always valid, never < 0)

int id | ( |  | self ) |

Returns:
  the id of the View set in the constructor

bool isWallpaperEnabled | ( |  | self ) |

Returns:
  whether or not containments should draw wallpaper

int screen | ( |  | self ) |

Returns the screen this view is associated with

Returns:
  the xinerama screen number, or -1 for none

setContainment | ( | self, |
|  | Plasma.Containment | containment
| ) |  |  |

Sets the containment for this view, which will also cause the view to track the geometry of the containment.

Parameters:

  | containment | the containment to center the view on

setScreen | ( | self, |
|  | int | screen,
|  | int | desktop=-1
| ) |  |  |

Sets which screen this view is associated with, if any. This will also set the containment if a valid screen is specified

Parameters:

  | screen | the physical screen number; -1 for no screen
  | desktop | the virtual desktop number, or -1 for all virtual desktops

setTrackContainmentChanges | ( | self, |
|  | bool | trackChanges
| ) |  |  |

Set whether or not the view should adjust its size when the associated containment does.

Parameters:

  | trackChanges | true to synchronize the view's size with the containment's (this is the default behaviour), false to ignore containment size changes

setWallpaperEnabled | ( | self, |
|  | bool | draw
| ) |  |  |

Sets whether or not to draw the containment wallpaper when painting on this item

Plasma.Containment swapContainment | ( | self, |
|  | Plasma.Containment | existing,
|  | QString | name,
|  | [QVariant] | args=QVariantList()
| ) |  |  |

Swap the containment for this view, which will also cause the view to track the geometry of the containment.

Parameters:

  | name | the plugin name for the new containment.
  | args | argument list to pass to the containment

Plasma.Containment swapContainment | ( | self, |
|  | QString | name,
|  | [QVariant] | args=QVariantList()
| ) |  |  |

Swap the containment for this view, which will also cause the view to track the geometry of the containment.

Parameters:

  | name | the plugin name for the new containment.
  | args | argument list to pass to the containment

bool trackContainmentChanges | ( |  | self ) |

Returns:
  whether or not the view tracks changes to the containment

## Static Method Documentation

Plasma.View topLevelViewAt | ( | QPoint | pos
| ) |  |  |

Parameters:

  | pos | the position in screen coordinates.

Returns:
  the Plasma.View that is at position pos.