Ejemplo n.º 1
0
    def _makeWidgets(self):
        """Build child widgets.

        Parameters:

        self: This object.

        Return value:

        None.

        Description:

        Create all of the GUI widgets required by this object.
        """

        # Create any inherited widgets.
        ElementEditor._makeWidgets(self)

        # Create and grid a OptionMenu for the Spectrum type.
        width = max([len(s) for s in Spectrum._validTypes])
        optionMenu = Pmw.OptionMenu(self,
                                    items=sorted(Spectrum._validTypes),
                                    label_text='Spectrum Type:',
                                    labelpos='w',
                                    menubutton_width=width,
                                    command=self._onSelectType)
        optionMenu.grid(row=0, column=0, sticky='w')
        self._typeOptionMenu = optionMenu
        self._balloon.bind(self._typeOptionMenu, 'Set the spectrum type.')

        # Create and grid an arbitrary string EntryField for the
        # Spectrum file, and an accompanying button which summons an
        # Open dialog.
        entryField = Pmw.EntryField(self, labelpos='w', label_text='File:')
        entryField.grid(row=0, column=1, sticky='e')
        self._fileEntryField = entryField
        self._balloon.bind(self._fileEntryField,
                           'Enter the path to the file of data for this'\
                           ' spectrum.')
        button = tkinter.Button(self, text='Browse', command=self.onBrowse)
        button.grid(row=0, column=2, sticky='e')
        self._fileBrowseButton = button
        self._balloon.bind(self._fileBrowseButton,
                           'Browse to the file of data for this spectrum.')

        # Create and grid a Frame for the set of ParameterEditors.
        frame = tkinter.Frame(self)
        frame.grid(row=1, column=0, columnspan=3, sticky='ew')

        # Create and grid a set of ParameterEditors.
        self._parameterEditors = []
        for row in range(SpectrumEditor._nParameterEditors):
            if row == 0:
                showLabels = True
            else:
                showLabels = False
            parameterEditor = ParameterEditor(frame, showLabels=showLabels)
            parameterEditor.grid(row=row, column=0, sticky='ew')
            self._parameterEditors.append(parameterEditor)
Ejemplo n.º 2
0
    def __init__(self, parent=None, spatialModel=None, *args, **kwargs):
        """Initialize this SpatialModelEditor.

        Parameters:

        self: This object.

        parent: (Tkinter.Frame) Parent object for this widget.

        spectrum: (SpatialModel) SpatialModel to initialize fields.

        Return value:

        None.

        Description:

        Initialize this SpectrumEditor.
        """

        # Initialize the parent class (which calls _makeWidgets and
        # set for this class).
        if spatialModel is None:
            spatialModel = SpatialModel()
        ElementEditor.__init__(self, parent, spatialModel, *args, **kwargs)
Ejemplo n.º 3
0
    def __init__(self, parent=None, source=None, *args, **kwargs):
        """Initialize this object.

        Parameters:

        self: This object.
        
        parent: (Tkinter.Frame) Parent object for this widget.
 
        source: (Source) Source to initialize fields.

        Return value:

        None.

        Description:

        Initialize this SourceEditor.
        """

        # Initialize the parent class (which calls _makeWidgets and
        # set for this class).
        if source is None:
            source = Source()
        ElementEditor.__init__(self, parent, source, *args, **kwargs)
Ejemplo n.º 4
0
    def __init__(self,
                 parent     = None,
                 parameter  = None,
                 showLabels = False,
                 *args, **kwargs):
        """Initialize this ParameterEditor.

        Parameters:

        self: This object.

        parent: (tkinter.Frame) Parent object for this widget.

        parameter: (Parameter) Parameter to initialize fields.

        showLabels: (Boolean) True if labels should be printed above
        the fields, False otherwise.

        Return value:

        None.

        Description:

        Initialize this ParameterEditor.
        """
        self._ds9Connector = None
        # Set the label printing flag.
        ParameterEditor._showLabels = showLabels

        # Initialize the parent class (which calls _makeWidgets and
        # set for this class).
        if parameter is None:
            parameter = Parameter()
        ElementEditor.__init__(self, parent, parameter, *args, **kwargs)
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        super(StartWindow, self).__init__(parent)

        self.button1 = QPushButton("Create grammar elements")
        self.button2 = QPushButton("Create grammar rules")
        self.button3 = QPushButton("Practice")

        self.layout1 = QVBoxLayout()
        self.layout1.addWidget(self.button1)
        self.layout1.addWidget(self.button2)
        self.layout1.addWidget(self.button3)

        self.cWidget = QWidget()
        self.cWidget.setLayout(self.layout1)

        self.button1.clicked.connect(self.startElementEditor)
        self.button2.clicked.connect(self.startRuleEditor)
        self.button3.clicked.connect(self.startPractice)

        self.setCentralWidget(self.cWidget)
        #self.setLayout(self.layout1)

        self.setWindowTitle("WordChain")

        self.elementEditor = ElementEditor()
        self.ruleEditor = RuleEditor()
        self.practice = Practice()
Ejemplo n.º 6
0
    def __init__(self, parent=None, sourceLibrary=None, *args, **kwargs):
        """Initialize this object.

        Parameters:

        self: This object.
        
        parent: (Tkinter.Frame) Parent object for this widget.

        sourceLibrary: (SourceLibrary) SourceLibrary object to
        initialize fields.
        """

        # Initialize the parent class (which calls _makeWidgets and
        # set for this class).
        if sourceLibrary is None:
            sourceLibrary = SourceLibrary()
        ElementEditor.__init__(self, parent, sourceLibrary, *args, **kwargs)
Ejemplo n.º 7
0
    def _makeWidgets(self):
        """Build child widgets.

        Parameters:

        self: This object.

        Return value:

        None.

        Description:

        Create all of the GUI widgets required by this object.
        """

        # Create any inherited widgets.
        ElementEditor._makeWidgets(self)

        # Create and grid an EntryField for the SourceLibrary title.
        entryField = Pmw.EntryField(
            self,
            label_text='Title',
            modifiedcommand=(lambda: self._changeTitle(self._titleEntryField)),
            labelpos='w')
        entryField.grid(row=0, column=0, columnspan=2)
        self._titleEntryField = entryField
        self._balloon.bind(self._titleEntryField,
                           'Enter the title of the source library.')

        # Create and grid a ScrolledListBox for the Source list.
        scrolledListBox = \
            Pmw.ScrolledListBox(self,
                                selectioncommand = self._onSelectSource)
        scrolledListBox.grid(row=1, column=0, sticky='ns')
        self._sourceScrolledListBox = scrolledListBox
        self._balloon.bind(self._sourceScrolledListBox,
                           'Select the source to edit.')

        # Create and grid a SourceEditor.
        sourceEditor = SourceEditor(self, borderwidth=2, relief='ridge')
        sourceEditor.grid(row=1, column=1)
        self._sourceEditor = sourceEditor
Ejemplo n.º 8
0
    def _makeWidgets(self):
        """Build child widgets.

        Parameters:

        self: This object.

        Return value:

        None.

        Description:

        Create all of the GUI widgets required by this object.
        """

        # Create any inherited widgets.
        ElementEditor._makeWidgets(self)

        # Create and grid an EntryField for the Source name.
        entryField = Pmw.EntryField(self,
                                    label_text='Source Name:',
                                    labelpos='w')
        entryField.grid(row=0, column=0, sticky='w')
        self._nameEntryField = entryField
        self._balloon.bind(self._nameEntryField, 'Enter the source name.')

        # Create and grid a Label for the Source type.
        label = Tkinter.Label(self, text='Source Type:')
        label.grid(row=0, column=1, sticky='e')
        self._typeLabel = label

        # Create and grid a SpectrumEditor.
        spectrumEditor = SpectrumEditor(self, borderwidth=2, relief='ridge')
        spectrumEditor.grid(row=1, column=0, columnspan=2, sticky='ew')
        self._spectrumEditor = spectrumEditor

        # Create and grid a SpatialModel editor.
        spatialModelEditor = SpatialModelEditor(self,
                                                borderwidth=2,
                                                relief='ridge')
        spatialModelEditor.grid(row=2, column=0, columnspan=2, sticky='ew')
        self._spatialModelEditor = spatialModelEditor
Ejemplo n.º 9
0
    def _makeWidgets(self):
        """Build child widgets.

        Parameters:

        self: This object.

        Return value:

        None.

        Description:

        Create all of the GUI widgets required by this object.
        """

        # Create any inherited widgets.
        ElementEditor._makeWidgets(self)

        # Start at the top row.
        row = 0

        # If labels were requested, create and grid them above the
        # EntryFields.
        if ParameterEditor._showLabels:
            col = 0
            for fieldName in Parameter._fieldNames:
                label = Tkinter.Label(self,
                                      text=fieldName,
                                      width=ParameterEditor._textFieldWidth)
                label.grid(row=row, column=col, sticky='ew')
                col += 1
            row += 1

        # Create and grid an arbitrary string EntryField for the
        # Parameter name.
        entryField = Pmw.EntryField(self, entry_width = \
                                    ParameterEditor._textFieldWidth)
        entryField.grid(row=row, column=0)
        self._nameEntryField = entryField
        self._balloon.bind(self._nameEntryField, 'Edit the parameter name.')

        # Create and grid a real-number EntryField for the Parameter
        # value.
        entryField = Pmw.EntryField(self, validate = 'real', entry_width = \
                                    ParameterEditor._textFieldWidth, \
                                    modifiedcommand = (lambda: self._updateDS9()) \
                                    )
        entryField.grid(row=row, column=1)
        self._valueEntryField = entryField
        self._balloon.bind(self._valueEntryField, 'Edit the parameter value.')

        # Create and grid a real-number EntryField for the Parameter
        # scale.
        entryField = Pmw.EntryField(self, validate = 'real', entry_width = \
                                    ParameterEditor._textFieldWidth)
        entryField.grid(row=row, column=2)
        self._scaleEntryField = entryField
        self._balloon.bind(self._scaleEntryField,
                           'Edit the scale factor for the parameter value.')

        # Create and grid a real-number EntryField for the Parameter
        # minimum value.
        entryField = Pmw.EntryField(self, validate = 'real', entry_width = \
                                    ParameterEditor._textFieldWidth,
                                    command = self._updateValidation)
        entryField.grid(row=row, column=3)
        self._minEntryField = entryField
        self._balloon.bind(self._minEntryField,
                           'Edit the minimum value for the parameter value.')

        # Create and grid a real-number EntryField for the Parameter
        # maximum value.
        entryField = Pmw.EntryField(self, validate = 'real', entry_width = \
                                    ParameterEditor._textFieldWidth,
                                    command = self._updateValidation)
        entryField.grid(row=row, column=4)
        self._maxEntryField = entryField
        self._balloon.bind(self._maxEntryField,
                           'Edit the maximum value for the parameter value.')

        # Create and grid a Checkbutton for the Parameter free
        # flag. Note that we also must create a BooleanVar to store
        # the state of the Checkbutton.
        self._free = Tkinter.BooleanVar()
        checkbutton = Tkinter.Checkbutton(self, variable = self._free,
                                          width = ParameterEditor.\
                                          _textFieldWidth)
        checkbutton.grid(row=row, column=5)
        self._freeCheckbutton = checkbutton
        self._balloon.bind(
            self._freeCheckbutton,
            'Check to allow parameter adjustment by the ' +
            'likelihood estimator.')