Package proser :: Module proser :: Class Proser
[hide private]
[frames] | no frames]

Class Proser

source code

       object --+                    
                |                    
sip.simplewrapper --+                
                    |                
          sip.wrapper --+            
                        |            
     PyQt4.QtCore.QObject --+        
                            |        
           object --+       |        
                    |       |        
    sip.simplewrapper --+   |        
                        |   |        
 PyQt4.QtGui.QPaintDevice --+        
                            |        
          PyQt4.QtGui.QWidget --+    
                                |    
          PyQt4.QtGui.QMainWindow --+
                                    |
                                   Proser

Creates a top level X window in which user can type. Proser provides statistical word completion suggestions. The suggestions are displayed on five buttons at the top of the window. Two methods are available to select one of the suggestions: Click the respective onscreen button, or type one of F5-F9. Completion is based on the word_completion package, which uses a frequency-ranked 6000 word dictionary.

A Copy button copies the entire typed text into the X cut buffer (a.k.a. clipboard), from where it may be pasted into any other window.

A special link exists between Proser and SpeakEasy. Proser provides two SpeakEasy related buttons:

  1. Erase the SpeakEasy text display
  2. Send the entire Proser window text to SpeakEasy and have it spoken by the currently selected voice. The SpeakEasy window may be minimized during this operation.

Users may type their text from a physical, or any onscreen keyboard.

Nested Classes [hide private]

Inherited from PyQt4.QtGui.QMainWindow: DockOption, DockOptions

Inherited from PyQt4.QtGui.QWidget: RenderFlag, RenderFlags

Inherited from PyQt4.QtGui.QPaintDevice: PaintDeviceMetric

Instance Methods [hide private]
 
__init__(self, dictDir=None, userDictFilePath=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
connectWidgets(self)
Attach slots and widgets to actions.
source code
 
actionClear(self)
Clear the text display.
source code
 
actionCopy(self)
Copy all Proser text to the X cut buffer (i.e.
source code
 
actionTextChanged(self)
Act on notification that text in the text panel changed.
source code
 
actionCompletionButton(self, buttonObj)
One of the text completion buttons was pushed.
source code
 
actionKeyShortcut(self, buttonIndex)
User pressed a function key F5-F9.
source code
 
actionAddToDictButton(self)
Add selected text to the dictionary that is used for word completion.
source code
 
getWordSoFar(self)
Service method to retrieve the most recent partially typed word.
source code
 
clearCompletionButtons(self)
Service method to clear labels on all word completion buttons.
source code
 
focusOnTextArea(self)
Service method to force the cursor focus into the text area.
source code
 
actionSendTextToSpeakEasy(self)
Copy current content of the text field into the X clipboard.
source code
 
actionClearSpeakEasyText(self)
Cause a running SpeakEasy process to clear its text area.
source code
 
getSpeakEasyPID(self)
Return the PID of the SpeakEasy application, if it is running.
source code

Inherited from PyQt4.QtGui.QMainWindow: addDockWidget, addToolBar, addToolBarBreak, centralWidget, contextMenuEvent, corner, createPopupMenu, dockOptions, dockWidgetArea, documentMode, event, iconSize, iconSizeChanged, insertToolBar, insertToolBarBreak, isAnimated, isDockNestingEnabled, isSeparator, menuBar, menuWidget, removeDockWidget, removeToolBar, removeToolBarBreak, restoreDockWidget, restoreState, saveState, setAnimated, setCentralWidget, setCorner, setDockNestingEnabled, setDockOptions, setDocumentMode, setIconSize, setMenuBar, setMenuWidget, setStatusBar, setTabPosition, setTabShape, setToolButtonStyle, setUnifiedTitleAndToolBarOnMac, splitDockWidget, statusBar, tabPosition, tabShape, tabifiedDockWidgets, tabifyDockWidget, toolBarArea, toolBarBreak, toolButtonStyle, toolButtonStyleChanged, unifiedTitleAndToolBarOnMac

Inherited from PyQt4.QtGui.QWidget: acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsMargins, contentsRect, contextMenuPolicy, create, cursor, customContextMenuRequested, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, enabledChange, ensurePolished, enterEvent, find, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontChange, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabGesture, grabKeyboard, grabMouse, grabShortcut, graphicsEffect, graphicsProxyWidget, handle, hasFocus, hasMouseTracking, height, heightForWidth, hide, hideEvent, inputContext, inputMethodEvent, inputMethodHints, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isEnabledToTLW, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isTopLevel, isVisible, isVisibleTo, isWindow, isWindowModified, keyPressEvent, keyReleaseEvent, keyboardGrabber, languageChange, layout, layoutDirection, leaveEvent, locale, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, overrideWindowFlags, overrideWindowState, paintEngine, paintEvent, palette, paletteChange, parentWidget, pos, previousInFocusChain, raise_, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, repaint, resetInputContext, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedWidth, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGraphicsEffect, setHidden, setInputContext, setInputMethodHints, setLayout, setLayoutDirection, setLocale, setMask, setMaximumHeight, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setShortcutAutoRepeat, setShortcutEnabled, setShown, setSizeIncrement, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, topLevelWidget, underMouse, ungrabGesture, unsetCursor, unsetLayoutDirection, unsetLocale, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, winId, window, windowActivationChange, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, x, x11Info, x11PictureHandle, y

Inherited from PyQt4.QtCore.QObject: __getattr__, blockSignals, childEvent, children, connect, connectNotify, customEvent, deleteLater, destroyed, disconnect, disconnectNotify, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, emit, eventFilter, findChild, findChildren, inherits, installEventFilter, isWidgetType, killTimer, metaObject, moveToThread, objectName, parent, property, pyqtConfigure, receivers, removeEventFilter, sender, senderSignalIndex, setObjectName, setProperty, signalsBlocked, startTimer, thread, timerEvent, tr, trUtf8

Inherited from PyQt4.QtGui.QPaintDevice: colorCount, depth, heightMM, logicalDpiX, logicalDpiY, numColors, paintingActive, physicalDpiX, physicalDpiY, widthMM

Inherited from sip.simplewrapper: __new__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  VERSION = '1.0'
  SPEAKEASY_PID_PUBLICATION_FILE = '/tmp/speakeasyPID'
  NO_COMPLETION_TEXT = ''
  FIRST_SHORTCUT_FUNC_KEY = 5
  REMOTE_CLEAR_TEXT_SIG = 10
  REMOTE_PASTE_AND_SPEAK_SIG = 12

Inherited from PyQt4.QtGui.QMainWindow: AllowNestedDocks, AllowTabbedDocks, AnimatedDocks, ForceTabbedDocks, VerticalTabs

Inherited from PyQt4.QtGui.QWidget: DrawChildren, DrawWindowBackground, IgnoreMask

Inherited from PyQt4.QtCore.QObject: staticMetaObject

Inherited from PyQt4.QtGui.QPaintDevice: PdmDepth, PdmDpiX, PdmDpiY, PdmHeight, PdmHeightMM, PdmNumColors, PdmPhysicalDpiX, PdmPhysicalDpiY, PdmWidth, PdmWidthMM

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, dictDir=None, userDictFilePath=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

actionCopy(self)

source code 

Copy all Proser text to the X cut buffer (i.e. clipboard).

actionTextChanged(self)

source code 

Act on notification that text in the text panel changed. This notification occurs with every one of the user's keystroke. In response this method updates the text completion buttons.

actionCompletionButton(self, buttonObj)

source code 

One of the text completion buttons was pushed. Insert the respective text at the current cursor position.

Parameters:
  • buttonObj (QPushButton) - the QPushButton object that was pushed.

actionKeyShortcut(self, buttonIndex)

source code 

User pressed a function key F5-F9. Invoke the actionCompletionButton() method.

Parameters:
  • buttonIndex (int) - Index 0-4 into the array self.completionButtons.

actionAddToDictButton(self)

source code 

Add selected text to the dictionary that is used for word completion. Words added by this method are appended to the dict_files/dictUserRankAndWord.txt file in the word_completion package. A default rank of 100 is attached.

The method attempts to warn the user if the text selection seems to span multiple words. In that case, a warning is displayed. A confirmation dialog is raised in case of success.

Raises:
  • ValueError - if provided rank < 0.

actionSendTextToSpeakEasy(self)

source code 

Copy current content of the text field into the X clipboard. Cause a running SpeakEasy process to paste that newly loaded X clipboard into its SpeakEasy text area, and to speak the content using the current voice. The method getSpeakEasyPID() is called from here, and that method will raise a warning dialog if no SpeakEasy process is currently running. That method will also raise the ValueError documented below.

Implementation: Send a Unix signal REMOTE_PASTE_AND_SPEAK_SIG to the SpeakEasy application, if one is running.

Raises:
  • ValueError - if the file /tmp/speakeasyPID does not contain an integer. That file is initialized by SpeakEasy with that process' PID. While that pid might be stale, it would still be an integer, unless the file is changed manually.

actionClearSpeakEasyText(self)

source code 

Cause a running SpeakEasy process to clear its text area.

Implementation: Send a Unix signal REMOTE_CLEAR_TEXT_SIG to the SpeakEasy process if one is running. Else a warning dialog is raised.

Raises:
  • ValueError - if the file /tmp/speakeasyPID does not contain an integer. That file is initialized by SpeakEasy with that process' PID. While that pid might be stale, it would still be an integer, unless the file is changed manually.

getSpeakEasyPID(self)

source code 

Return the PID of the SpeakEasy application, if it is running. Else return None. The PID is communicated via a file. Note that this file's content might be stale. So callers must protect against the target process not running any more.

Raises:
  • ValueError - if the file /tmp/speakeasyPID does not contain an integer. That file is initialized by SpeakEasy with that process' PID. While that pid might be stale, it would still be an integer, unless the file is changed manually.