Package speakeasy :: Module speakeasy_ui :: Class SpeakEasyGUI
[hide private]
[frames] | no frames]

Class SpeakEasyGUI

source code

python_qt_binding.QtGui.QMainWindow --+
                                      |
                                     SpeakEasyGUI

One instance of this class builds the entire sound play UI. Instance variable that hold widgets of interest to controllers:

Instance Methods [hide private]
 
__init__(self, parent=None, mirrored=True, stand_alone=False, sound_effect_labels=None) source code
 
programButtonIterator(self, gridLayout=None) source code
 
replaceProgramButtons(self, buttonProgramsArray) source code
 
addTitle(self, layout) source code
 
addTxtInputFld(self, layout)
Creates text input field label and text field in a horizontal box layout.
source code
 
addOnceOrRepeat_And_VoiceRadioButtons(self, layout)
Creates radio buttons for selecting whether a sound is to play once, or repeatedly until stopped.
source code
 
buildTapeRecorderButtons(self, layout)
Creates tape recorder buttons (Play Text, Stop,etc.).
source code
 
buildProgramButtons(self, layout)
Creates grid of buttons for saving sounds.
source code
 
buildSoundButtons(self, layout)
Creates grid of buttons for playing canned sounds.
source code
 
buildButtonSetControls(self, layout) source code
 
buildOptionsRadioButtons(self, layout) source code
 
buildConvenienceButtons(self, layout)
Creates buttons meant for accessibility convenience.
source code
 
buildHorizontalDivider(self, layout) source code
 
buildRadioButtons(self, labelTextArray, orientation, alignment, activeButtons=None, behavior=CheckboxGroupBehavior.RADIO_BUTTONS) source code
{None | string}
getNewButtonLabel(self)
Requests a new button label from the user.
source code
 
playOnceChecked(self) source code
 
setPlayOnceChecked(self) source code
 
playRepeatedlyChecked(self) source code
 
setPlayRepeatedlyChecked(self) source code
 
getPlayRepeatPeriod(self) source code
string
activeVoice(self)
Return the official name of the voice that is currently checked in the UI.
source code
PlayLocation
whereToPlay(self)
Returns which of the play location options is selected: Locally or Robot.
source code
 
setWhereToPlay(self, playLocation)
Set the option radio button that determines where sound is produced, locally, or at the robot.
source code
 
setButtonLabel(self, buttonObj, label) source code
 
blinkButton(self, buttonObj, turnOn)
Used to make a program button blink in some way to indicate that it is changing into programming mode.
source code
Static Methods [hide private]
QGridLayout
buildButtonGrid(labelTextArray, numColumns)
Creates a grid of QPushButton widgets.
source code
Class Variables [hide private]
  PROGRAM_BUTTON_HOLD_TIME = 3.0
  PROGRAM_BUTTON_LOOK_CHANGE_DURATION = 0.2
  BUTTON_MIN_HEIGHT = 30
  BUTTON_LABEL_FONT_SIZE = 16
  RADIO_BUTTON_LABEL_FONT_SIZE = 16
  EDIT_FIELD_TEXT_SIZE = 18
  NUM_OF_PROGRAM_BUTTON_COLUMNS = 4
  NUM_OF_SOUND_BUTTON_COLUMNS = 4
  voices = {'VOICE_1': 'voice_kal_diphone', 'VOICE_2': 'David', ...
  interactionWidgets = {'PLAY_ONCE': 'Play once', 'PLAY_REPEATED...
  veryLightBlue = QColor(230, 255, 255)
  stylesheetAppBG = 'QDialog {background-color: %s}' % veryLight...
  defaultStylesheet = 'QDialog {background-color: %s}' % veryLig...
  defaultStylesheetName = "Default"
  editFieldBGColor = QColor(12, 21, 109)
  editFieldTextColor = QColor(244, 244, 246)
  inputFldStylesheet = 'TextPanel {background-color: '+ editFiel...
  recorderButtonBGColor = QColor(176, 220, 245)
  recorderButtonDisabledBGColor = QColor(187, 200, 208)
  recorderButtonTextColor = QColor(0, 0, 0)
  programButtonBGColor = QColor(117, 150, 169)
  programButtonTextColor = QColor(251, 247, 247)
  soundButtonBGColor = QColor(110, 134, 211)
  soundButtonTextColor = QColor(251, 247, 247)
  recorderButtonStylesheet = 'QPushButton {background-color: '+ ...
  recorderButtonDisabledStylesheet = 'QPushButton {background-co...
  programButtonStylesheet = 'QPushButton {background-color: '+ p...
  programButtonModeTransitionStylesheet = 'QPushButton {backgrou...
  soundButtonStylesheet = 'QPushButton {background-color: '+ sou...
  playOnceRepeatButtonBGColor = QColor(121, 229, 230)
  voicesButtonBGColor = QColor(97, 164, 165)
  playOnceRepeatButtonStylesheet = 'font-size: '+ str(RADIO_BUTT...
  playRepeatSpinboxStylesheet = 'font-size: '+ str(RADIO_BUTTON_...
  voiceButtonStylesheet = 'font-size: '+ str(RADIO_BUTTON_LABEL_...
  hideButtonSignal = pyqtSignal(QPushButton)
  showButtonSignal = pyqtSignal(QPushButton)
Method Details [hide private]

addTxtInputFld(self, layout)

source code 

Creates text input field label and text field in a horizontal box layout. Adds that hbox layout to the passed-in layout.

Sets instance variables:

  1. self.speechInputFld
Parameters:
  • layout (QLayout) - Layout object to which the label/txt-field hbox is to be added.

addOnceOrRepeat_And_VoiceRadioButtons(self, layout)

source code 

Creates radio buttons for selecting whether a sound is to play once, or repeatedly until stopped. Also adds radio buttons for selecting voices. Places all in a horizontal box layout. Adds that hbox layout to the passed-in layout.

Sets instance variables:

  1. self.onceOrRepeatDict
  2. self.voicesRadioButtonsDict
Parameters:
  • layout (QLayout) - Layout object to which the label/txt-field hbox is to be added.

buildTapeRecorderButtons(self, layout)

source code 

Creates tape recorder buttons (Play Text, Stop,etc.). Places all in a row, though the layout is a QGridLayout. Adds QGridLayout to the passed-in layout.

Sets instance variables:

  1. self.recorderDict
Parameters:
  • layout (QLayout) - Layout object to which the label/txt-field QGridlayout is to be added.

buildProgramButtons(self, layout)

source code 

Creates grid of buttons for saving sounds. Adds the resulting QGridLayout to the passed-in layout.

Sets instance variables:

  1. self.programButtonDict
Parameters:
  • layout (QLayout) - Layout object to which the label/txt-field QGridlayout is to be added.

buildSoundButtons(self, layout)

source code 

Creates grid of buttons for playing canned sounds. Adds the resulting QGridLayout to the passed-in layout.

Sets instance variables:

  1. self.soundButtonDict
Parameters:
  • layout (QLayout) - Layout object to which the label/txt-field QGridlayout is to be added.

buildConvenienceButtons(self, layout)

source code 

Creates buttons meant for accessibility convenience. Example: Paste. Places all in a row, though the layout is a QGridLayout. Adds QGridLayout to the passed-in layout.

Sets instance variables:

  1. self.convenienceButtonDict
Parameters:
  • layout (QLayout) - Layout object to which the label/txt-field QGridlayout is to be added.

buildRadioButtons(self, labelTextArray, orientation, alignment, activeButtons=None, behavior=CheckboxGroupBehavior.RADIO_BUTTONS)

source code 
Parameters:
  • labelTextArray ([string]) - Names of buttons
  • orientation (Orientation) - Whether to arrange the buttons vertically or horizontally.
  • alignment (Alignment) - whether buttons should be aligned Left/Center/Right for horizontal, Top/Center/Bottom for vertical:/c
  • activeButtons ([string]) - Name of the buttons that is to be checked initially. Or None.
  • behavior (CheckboxGroupBehavior @return
    1. The button group that contains the related buttons. Caller: ensure that this object does not go out of scope.
    2. The button layout, which callers will need to add to their own layouts.
    3. and a dictionary mapping button names to button objects that were created within this method. This dict is needed by the controller.

    @rtype (QButtonGroup, QLayout, dict<string,QRadioButton>).

    ) - Indicates whether the button group is to behave like Radio Buttons, or like Checkboxes.

buildButtonGrid(labelTextArray, numColumns)
Static Method

source code 

Creates a grid of QPushButton widgets. They will be

Parameters:
  • labelTextArray ([string]) - Button labels.
  • numColumns (int) - The desired width of the button grid.
Returns: QGridLayout
1. a grid layout with the button objects inside.
  1. a dictionary mapping button labels to button objects.

getNewButtonLabel(self)

source code 

Requests a new button label from the user. Returns None if user canceled out, or a string with the new button label.

Returns: {None | string}
None if user canceled, else string from input field.

activeVoice(self)

source code 

Return the official name of the voice that is currently checked in the UI. This is the name that will be recognized by the underlying text-to-speech engine(s).

Returns: string
Name of voice as per the SpeakEasyGUI.voices dict.

whereToPlay(self)

source code 

Returns which of the play location options is selected: Locally or Robot.

Returns: PlayLocation
Selection of where sound and text-to-speech output is to occur.

setWhereToPlay(self, playLocation)

source code 

Set the option radio button that determines where sound is produced, locally, or at the robot. No action is taken. This method merely sets the appropriate radio button.

Parameters:
  • playLocation (PlayLocation) - PlayLocation.LOCALLY, or PlayLocation.ROBOT

blinkButton(self, buttonObj, turnOn)

source code 

Used to make a program button blink in some way to indicate that it is changing into programming mode. Since this method is triggered by a timer thread, it cannot make any GUI changes. Instead, it sends a signal to have the GUI thread place the button into an alternative look. It then schedules a call to itself for a short time later. At that point it sends a signal to the GUI thread to return the button to its usual look:

Parameters:
  • buttonObj (QPushButton) - The button to be blinked
  • turnOn (bool) - Indicates whether to turn the button back into its normal state, or whether to make it take on its alternate look.

Class Variable Details [hide private]

voices

Value:
{'VOICE_1': 'voice_kal_diphone', 'VOICE_2': 'David', 'VOICE_3': 'Amy',\
 'VOICE_4': 'Shouty', 'VOICE_5': 'Whispery', 'VOICE_6': 'Lawrence', 'V\
OICE_7': 'William'}

interactionWidgets

Value:
{'PLAY_ONCE': 'Play once', 'PLAY_REPEATEDLY': 'Play repeatedly', 'PLAY\
_REPEATEDLY_PERIOD': 'Pause between plays', 'VOICE_1': 'Machine', 'VOI\
CE_2': 'David', 'VOICE_3': 'Amy', 'VOICE_4': 'Shout', 'VOICE_5': 'Whis\
per', 'VOICE_6': 'Lawrence', 'VOICE_7': 'William', 'PLAY_TEXT': 'Play \
Text', 'STOP': 'Stop', 'STOP_ALL': 'Stop All', 'SPEECH_1': 'Speech 1',\
 'SPEECH_2': 'Speech 2', 'SPEECH_3': 'Speech 3', 'SPEECH_4': 'Speech 4\
', 'SPEECH_5': 'Speech 5', 'SPEECH_6': 'Speech 6', 'SPEECH_7': 'Speech\
 7', 'SPEECH_8': 'Speech 8', 'SPEECH_9': 'Speech 9', 'SPEECH_10': 'Spe\
...

stylesheetAppBG

Value:
'QDialog {background-color: %s}' % veryLightBlue.name()

defaultStylesheet

Value:
'QDialog {background-color: %s}' % veryLightBlue.name()

inputFldStylesheet

Value:
'TextPanel {background-color: '+ editFieldBGColor.name()+ '; color: '+\
 editFieldTextColor.name()+ '; font-size: '+ str(EDIT_FIELD_TEXT_SIZE)\
+ 'pt'+ '}'

recorderButtonStylesheet

Value:
'QPushButton {background-color: '+ recorderButtonBGColor.name()+ '; co\
lor: '+ recorderButtonTextColor.name()+ '; font-size: '+ str(BUTTON_LA\
BEL_FONT_SIZE)+ 'px'+ '}'

recorderButtonDisabledStylesheet

Value:
'QPushButton {background-color: '+ recorderButtonDisabledBGColor.name(\
)+ '; color: '+ recorderButtonTextColor.name()+ '; font-size: '+ str(B\
UTTON_LABEL_FONT_SIZE)+ 'px'+ '}'

programButtonStylesheet

Value:
'QPushButton {background-color: '+ programButtonBGColor.name()+ '; col\
or: '+ programButtonTextColor.name()+ '; font-size: '+ str(BUTTON_LABE\
L_FONT_SIZE)+ 'px'+ '}'

programButtonModeTransitionStylesheet

Value:
'QPushButton {background-color: '+ editFieldBGColor.name()+ '; color: \
'+ programButtonTextColor.name()+ '; font-size: '+ str(BUTTON_LABEL_FO\
NT_SIZE)+ 'px'+ '}'

soundButtonStylesheet

Value:
'QPushButton {background-color: '+ soundButtonBGColor.name()+ '; color\
: '+ soundButtonTextColor.name()+ '; font-size: '+ str(BUTTON_LABEL_FO\
NT_SIZE)+ 'px'+ '}'

playOnceRepeatButtonStylesheet

Value:
'font-size: '+ str(RADIO_BUTTON_LABEL_FONT_SIZE)+ 'px'+ '; color: '+ s\
oundButtonTextColor.name()+ '; background-color: '+ voicesButtonBGColo\
r.name()

playRepeatSpinboxStylesheet

Value:
'font-size: '+ str(RADIO_BUTTON_LABEL_FONT_SIZE)+ 'px'+ '; color: '+ s\
oundButtonTextColor.name()+ '; background-color: '+ voicesButtonBGColo\
r.name()

voiceButtonStylesheet

Value:
'font-size: '+ str(RADIO_BUTTON_LABEL_FONT_SIZE)+ 'px'+ '; color: '+ s\
oundButtonTextColor.name()+ '; background-color: '+ voicesButtonBGColo\
r.name()