4.2  mdiimageviewer – Synchable image viewers using MDI style interface

4.2.1  Inheritance Diagram

Inheritance diagram of mdiimageviewer

4.2.2  Description

This module implements the MDIImageViewerWindow class which allows optionally synchronized panning and zooming of multiple QPixmaps.

It contains the following classes:

4.2.3  Reference

4.2.3.1  MdiChild

class mdiimageviewer.MdiChild(pixmap, filename, name)[source]

Bases: imageviewer.ImageViewer

ImageViewer that implements <Space> key pressed panning.

Parameters:
  • pixmap (QPixmap or None) – QPixmap to display

  • filename (str or None) – QPixmap filename

  • name (str or None) – name associated with this ImageViewer

currentFile[source]

Current filename (str).

userFriendlyCurrentFile[source]

Get current filename without path (str).

keyPressEvent(keyEvent)[source]

Overrides to enable panning while dragging.

Parameters:
  • keyEvent (QKeyEvent) – instance of QKeyEvent

keyReleaseEvent(keyEvent)[source]

Overrides to disable panning while dragging.

Parameters:
  • keyEvent (QKeyEvent) – instance of QKeyEvent

4.2.3.2  MDIImageViewerWindow

class mdiimageviewer.MDIImageViewerWindow[source]

Bases: PyQt4.QtGui.QMainWindow

Views multiple images with optionally synchonized zooming & panning.

createMappedAction(icon, text, parent, shortcut, methodName)[source]

Create QAction that is mapped via methodName to call.

Parameters:
  • icon (QIcon or None) – icon associated with QAction

  • text (str) – the QAction descriptive text

  • parent (QObject) – the parent QObject

  • shortcut (QKeySequence) – the shortcut QKeySequence

  • methodName (str) – name of method to call when QAction is triggered

Return type:

QAction

createActions()[source]

Create actions used in menus.

createMenus()[source]

Create menus.

updateMenus()[source]

Update menus.

updateRecentFileActions()[source]

Update recent file menu items.

updateWindowMenu()[source]

Update the Window menu.

createStatusBarLabel(stretch=0)[source]

Create status bar label.

Parameters:
  • stretch (int) – stretch factor

Return type:

QLabel

createStatusBar()[source]

Create status bar.

activeMdiChild[source]

Get active MDI child (MdiChild or None).

closeEvent(event)[source]

Overrides close event to save application settings.

Parameters:
  • event (QEvent) – instance of QEvent

mappedImageViewerAction(methodName)[source]

Perform action mapped to imageviewer.ImageViewer methodName.

Parameters:
  • methodName (str) – method to call

toggleSynchPan()[source]

Toggle synchronized subwindow panning.

panChanged()[source]

Synchronize subwindow pans.

toggleSynchZoom()[source]

Toggle synchronized subwindow zooming.

zoomChanged()[source]

Synchronize subwindow zooms.

activateSubwindowSystemMenu()[source]

Activate current subwindow’s System Menu.

openRecentFile(filename)[source]

Open a recent file.

Parameters:
  • filename (str) – filename to view

open()[source]

Handle the open action.

toggleScrollbars()[source]

Toggle subwindow scrollbar visibility.

toggleStatusbar()[source]

Toggle status bar visibility.

about()[source]

Display About dialog box.

subWindowActivated(window)[source]

Handle QMdiSubWindow activated signal.

Parameters:
  • window (QMdiSubWindow) – QMdiSubWindow that was just activated

setActiveSubWindow(window)[source]

Set active QMdiSubWindow.

Parameters:
loadFile(filename)[source]

Load filename into new MdiChild window.

Parameters:
  • filename (str) – filename to load

updateStatusBar()[source]

Update status bar.

createMdiChild(pixmap, filename)[source]

Create new MdiChild for pixmap.

Parameters:
Return type:

MdiChild

switchLayoutDirection()[source]

Switch MDI subwindow layout direction.

synchPan(fromViewer)[source]

Synch panning of all subwindowws to the same as fromViewer.

Parameters:
  • fromViewerMdiChild that initiated synching

synchZoom(fromViewer)[source]

Synch zoom of all subwindowws to the same as fromViewer.

Parameters:
  • fromViewerMdiChild that initiated synching

saveDialogState(dialog, groupName)[source]

Save dialog state, position & size.

Parameters:
  • dialog (QDialog) – dialog to save state of

  • groupName (str) – QSettings group name

restoreDialogState(dialog, groupName)[source]

Restore dialog state, position & size.

Parameters:
writeSettings()[source]

Write application settings.

readSettings()[source]

Read application settings.

updateRecentFileSettings(filename, delete=False)[source]

Update recent file list setting.

Parameters:
  • filename (str) – filename to add or remove from recent file list

  • delete (bool) – if True then filename removed, otherwise added