コード例 #1
0
    def __init__(self, blankOptionSelection=None, wildcard=None):
        super().__init__()

        self.blankOptionSelection = blankOptionSelection
        self.wildcard = wildcard

        self.setWindowTitle('Search Options')
        layout = QVBoxLayout()

        blankOptionsLabel = QLabel(
            'How should blank spaces be interpreted in your search?')
        layout.addWidget(blankOptionsLabel)

        blankOptionsLayout = QVBoxLayout()
        self.blankOptionsGroup = QButtonGroup()

        asBlankOption = QRadioButton(
            'Interpret as literal blanks, and only match blank slots')
        blankOptionsLayout.addWidget(asBlankOption)
        self.blankOptionsGroup.addButton(asBlankOption)
        self.blankOptionsGroup.setId(asBlankOption, 0)
        if self.blankOptionSelection == 'literal':
            asBlankOption.setChecked(True)

        asWildcardOption = QRadioButton(
            'Interpret as wildcards, and match anything')
        blankOptionsLayout.addWidget(asWildcardOption)
        self.blankOptionsGroup.addButton(asWildcardOption)
        self.blankOptionsGroup.setId(asWildcardOption, 1)
        if self.blankOptionSelection == 'wildcard' or self.blankOptionSelection is None:
            asWildcardOption.setChecked(True)

        miniLayout = QHBoxLayout()
        asBlankWithWildcard = QRadioButton(
            'Interpret as literal blanks, and use this character for wildcards: '
        )
        self.wildcardLineEdit = QLineEdit()
        self.wildcardLineEdit.setMaxLength(1)
        self.wildcardLineEdit.setMaximumWidth(30)
        self.blankOptionsGroup.addButton(asBlankWithWildcard)
        self.blankOptionsGroup.setId(asBlankWithWildcard, 2)
        if self.blankOptionSelection == 'both':
            asBlankWithWildcard.setChecked(True)
            self.wildcardLineEdit.setText(self.wildcard)
        miniLayout.addWidget(asBlankWithWildcard)
        miniLayout.addWidget(self.wildcardLineEdit)
        blankOptionsLayout.addLayout(miniLayout)

        layout.addLayout(blankOptionsLayout)

        buttonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        ok.clicked.connect(self.accept)
        buttonLayout.addWidget(ok)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(cancel)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)
コード例 #2
0
    def __init__(self, corpus):
        super().__init__()
        self.setWindowTitle('Search by gloss')

        layout = QVBoxLayout()

        searchLayout = QHBoxLayout()

        searchLabel = QLabel('Enter gloss to search for: ')
        searchLayout.addWidget(searchLabel)

        self.searchEdit = QLineEdit()
        completer = QCompleter()
        model = QStringListModel()
        model.setStringList([word.gloss for word in corpus])
        completer.setModel(model)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.searchEdit.setCompleter(completer)
        searchLayout.addWidget(self.searchEdit)

        buttonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        ok.clicked.connect(self.accept)
        buttonLayout.addWidget(ok)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(cancel)

        layout.addLayout(searchLayout)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)
コード例 #3
0
    def __init__(self, recents, favourites=None):
        if favourites is None:
            favourites = list()
        super().__init__()
        self.setWindowTitle('Recent Searches')
        self.result = None
        layout = QVBoxLayout()

        tableLayout = QHBoxLayout()

        self.recentTable = RecentSearchTable(recents, 'Add to favourites')
        tableLayout.addWidget(self.recentTable)

        self.favouriteTable = RecentSearchTable(favourites,
                                                'Remove from favourites')
        tableLayout.addWidget(self.favouriteTable)

        buttonLayout = QHBoxLayout()
        ok = QPushButton('Use selected search')
        ok.clicked.connect(self.accept)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(ok)
        buttonLayout.addWidget(cancel)

        layout.addLayout(tableLayout)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)

        self.resize(self.recentTable.width() * 1.5, self.height())
コード例 #4
0
    def __init__(self, coderName, parent=None):
        super().__init__(parent=parent)
        self.setWindowTitle('Edit default coder name')

        self._coderName = coderName

        layout = QVBoxLayout()
        self.setLayout(layout)

        inputLayout = QHBoxLayout()
        layout.addLayout(inputLayout)

        self.coderNameLineEdit = QLineEdit(self._coderName)
        inputLayout.addWidget(QLabel('Default coder:'))
        inputLayout.addWidget(self.coderNameLineEdit)

        buttonLayout = QHBoxLayout()
        layout.addLayout(buttonLayout)

        okButton = QPushButton('Ok')
        buttonLayout.addWidget(okButton)
        okButton.clicked.connect(self.accept)

        cancelButton = QPushButton('Cancel')
        buttonLayout.addWidget(cancelButton)
        cancelButton.clicked.connect(self.reject)
コード例 #5
0
    def __init__(self, results):
        super().__init__()
        self.setWindowTitle('Search Results')
        layout = QVBoxLayout()
        self.result = None

        resultsLayout = QHBoxLayout()

        self.resultsList = QListWidget()
        for r in results:
            self.resultsList.addItem(r.gloss)

        resultsLayout.addWidget(self.resultsList)
        layout.addLayout(resultsLayout)

        buttonLayout = QHBoxLayout()
        okButton = QPushButton('Go to this entry')
        cancelButton = QPushButton('Cancel')
        okButton.clicked.connect(self.accept)
        cancelButton.clicked.connect(self.reject)
        buttonLayout.addWidget(okButton)
        buttonLayout.addWidget(cancelButton)

        layout.addLayout(buttonLayout)

        self.setLayout(layout)
コード例 #6
0
    def __init__(self, parent, corpus):
        super().__init__()

        self.parent = parent
        self.corpus = corpus

        mainLayout = QVBoxLayout()
        self.setLayout(mainLayout)

        handShapeLayout = QVBoxLayout()
        mainLayout.addLayout(handShapeLayout)

        globalFrame = QGroupBox('Global options')
        globalLayout = QHBoxLayout()
        globalFrame.setLayout(globalLayout)
        handShapeLayout.addWidget(globalFrame)

        forearmButton = QCheckBox('Forearm')
        globalLayout.addWidget(forearmButton)
        estimatedButton = QCheckBox('Estimated')
        globalLayout.addWidget(estimatedButton)
        uncertainButton = QCheckBox('Uncertain')
        globalLayout.addWidget(uncertainButton)
        incompleteButton = QCheckBox('Incomplete')
        globalLayout.addWidget(incompleteButton)

        config1Frame = QGroupBox('Config 1')
        config1Layout = QVBoxLayout()
        config1Frame.setLayout(config1Layout)
        handShapeLayout.addWidget(config1Frame)

        config1 = TranscriptionConfigTab(1)
        config1Layout.addWidget(config1)

        config2Frame = QGroupBox('Config 2')
        config2Layout = QVBoxLayout()
        config2Frame.setLayout(config2Layout)
        handShapeLayout.addWidget(config2Frame)

        config2 = TranscriptionConfigTab(2)
        config2Layout.addWidget(config2)

        searchOptionLayout= QHBoxLayout()

        extendedFingerSearch = ExtendedFingerPanel()
        searchOptionLayout.addWidget(extendedFingerSearch)


        mainLayout.addLayout(searchOptionLayout)

        buttonLayout = QHBoxLayout()
        mainLayout.addLayout(buttonLayout)
        okButton = QPushButton('Search')
        recentButton = QPushButton('Show recent searches...')
        cancelButton = QPushButton('Cancel')
        buttonLayout.addWidget(okButton)
        buttonLayout.addWidget(recentButton)
        buttonLayout.addWidget(cancelButton)
コード例 #7
0
    def __init__(self, model, checkStrategy=None):
        super().__init__()
        self.setWindowFlags(Qt.WindowStaysOnTopHint)
        self.setWindowTitle('Select Parameters')
        self.adjustedHeight = self.frameGeometry().height()
        self.adjustedWidth = self.frameGeometry().width()
        self.adjustedPos = self.pos()

        self.model = model
        self.model.itemChanged.connect(self.updateDisplayTree)

        self.treeView = ParameterTreeView()
        self.treeView.setModel(self.model)
        self.treeView.clicked.connect(self.updateDisplayTree)

        self.displayTree = anytree.Node('Selected Parameters', parent=None)
        self.displayTreeWidget = QTextEdit()
        self.displayTreeWidget.setReadOnly(True)

        layout = QVBoxLayout()
        self.selectionLayout = QVBoxLayout()
        self.parameterLayout = QHBoxLayout()
        self.selectionLayout.addWidget(self.displayTreeWidget)
        self.parameterLayout.addWidget(self.treeView)
        self.parameterLayout.addLayout(self.selectionLayout)

        self.buildDisplayTree(self.model.invisibleRootItem(), self.displayTree)
        self.generateDisplayTreeText()

        terminalNodesLayout = QVBoxLayout()
        self.terminalNodesLabel = QTextEdit('No parameters selected')
        self.terminalNodesLabel.setReadOnly(True)
        terminalNodesLayout.addWidget(self.terminalNodesLabel)
        self.parameterLayout.addLayout(terminalNodesLayout)
        self.updateTerminalNodes()

        buttonLayout = QGridLayout()
        okButton = QPushButton('OK')
        cancelButton = QPushButton('Cancel')
        resetButton = QPushButton('Reset to default values')
        clearButton = QPushButton('Clear all check boxes')
        buttonLayout.addWidget(resetButton, 0, 0)
        buttonLayout.addWidget(clearButton, 0, 1)
        buttonLayout.addWidget(okButton, 1, 0)
        buttonLayout.addWidget(cancelButton, 1, 1)
        okButton.clicked.connect(self.accept)
        cancelButton.clicked.connect(self.reject)
        resetButton.clicked.connect(self.reset)
        clearButton.clicked.connect(self.clear)

        layout.addLayout(self.parameterLayout)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)
        self.resize(self.adjustedHeight, self.adjustedWidth)
        self.move(self.adjustedPos)
コード例 #8
0
    def __init__(self):
        super().__init__()

        self.fingerConfigPanel = ExtendedFingerPanel()
        self.fingerNumberPanel = NumExtendedFingerPanel()
        self.relationlogicPanel = LogicRadioButtonGroup('vertical',
                                                        'a',
                                                        title='Relation between finger configuration and '
                                                              'number of extended fingers',
                                                        a='Apply both',
                                                        o='Apply either',
                                                        fg='Apply only the finger configuration',
                                                        nf='Apply only the number of extended fingers')
        self.modePanel = LogicRadioButtonGroup('vertical',
                                               'p',
                                               title='Search mode',
                                               p='Positive',
                                               n='Negative')

        self.includeIbutton = QCheckBox('Treat "i" as extended')
        self.includeIbutton.setChecked(False)

        self.default = QPushButton('Return to default')
        self.default.clicked.connect(self.setToDefault)

        mainLayout = QGridLayout()
        self.setLayout(mainLayout)
        mainLayout.addWidget(self.fingerConfigPanel, 0, 0, 1, 3)
        mainLayout.addWidget(self.fingerNumberPanel, 1, 0, 1, 3)
        mainLayout.addWidget(self.relationlogicPanel, 2, 0, 2, 1)
        mainLayout.addWidget(self.modePanel, 2, 1, 2, 1)
        mainLayout.addWidget(self.includeIbutton, 2, 2, 1, 1)
        mainLayout.addWidget(self.default, 3, 2, 1, 1)
コード例 #9
0
    def __init__(self, title, dialog, parent):
        super().__init__(title, dialog, parent)

        self.subsetButton = QPushButton('Subset as a corpus')
        self.subsetButton.clicked.connect(self.subsetAndSave)

        self.buttonLayout.insertWidget(2, self.subsetButton)
コード例 #10
0
    def __init__(self):
        super().__init__()

        self.descriptionLayouts = list()
        self.introduction = QLabel()
        self.introduction.setFont(QFont('Arial', 15))
        #the introduction label is used by subclasses to present different information to the user

        self.transcriptions = list()
        self.regularExpressions = None

        self.layout = QVBoxLayout()
        self.layout.addWidget(self.introduction)

        self.metaLayout = QVBoxLayout()
        self.layout.addLayout(self.metaLayout)

        sepFrame = QFrame()
        sepFrame.setFrameShape(QFrame.HLine)
        sepFrame.setLineWidth(2)
        self.layout.addWidget(sepFrame)

        self.buttonLayout = QVBoxLayout()
        self.topButtonLayout = QHBoxLayout()
        self.addDescription = QPushButton('')
        self.addDescription.clicked.connect(self.addFingerLayout)
        self.topButtonLayout.addWidget(self.addDescription)
        remove = QPushButton('Remove all selected phrases')
        self.topButtonLayout.addWidget(remove)
        remove.clicked.connect(self.removeFingerLayouts)
        self.buttonLayout.addLayout(self.topButtonLayout)

        bottomButtonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        bottomButtonLayout.addWidget(ok)
        ok.clicked.connect(self.accept)
        cancel = QPushButton('Cancel')
        bottomButtonLayout.addWidget(cancel)
        cancel.clicked.connect(self.reject)
        self.buttonLayout.addLayout(bottomButtonLayout)

        self.layout.addLayout(self.buttonLayout)

        self.setLayout(self.layout)
コード例 #11
0
    def __init__(self, parent, settings, worker):
        super().__init__(parent)

        self.settings = settings

        self.setWindowTitle(self.name.title())

        self.newTableButton = QPushButton('Run/Restart')
        self.newTableButton.setDefault(True)
        self.newTableButton.clicked.connect(self.newTable)

        self.oldTableButton = QPushButton('Append to current results table')
        self.oldTableButton.clicked.connect(self.oldTable)

        self.cancelButton = QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.reject)

        self.aboutButton = QPushButton('About {}...'.format(self.name))
        self.aboutButton.clicked.connect(self.open_about)

        acLayout = QHBoxLayout()
        acLayout.addWidget(self.newTableButton)
        acLayout.addWidget(self.oldTableButton)
        acLayout.addWidget(self.cancelButton)
        acLayout.addWidget(self.aboutButton)

        self.thread = worker
        self.thread.dataReady.connect(self.setResults)

        #if self.settings['tooltips']:
        #    self.aboutButton.setToolTip(('<FONT COLOR=black>'
        #                                 '{}'
        #                                 '</FONT>'.format('\n'.join(self.about)))
        #                                )

        majorLayout = QVBoxLayout()
        majorLayout.addLayout(acLayout)

        self.setLayout(majorLayout)
        self.resize(1000, 500)
コード例 #12
0
    def __init__(self, title, dialog, parent):
        super().__init__(parent=parent)
        self.setWindowTitle(title)
        self.dialog = dialog
        dataModel = ResultsTableModel(self.dialog.header, self.dialog.results)

        self.table = ResultsTableView()
        self.table.setModel(dataModel)
        self.table.horizontalHeader().setSectionResizeMode(
            QHeaderView.ResizeToContents)

        # The option buttons
        self.reopenButton = QPushButton('Reopen function dialog')
        self.reopenButton.clicked.connect(self.reopen)

        self.saveButton = QPushButton('Save to file')
        self.saveButton.clicked.connect(self.save)

        self.closeButton = QPushButton('Close window')
        self.closeButton.clicked.connect(self.reject)

        # Appearance
        self.table.resizeColumnsToContents()
        self.table.resizeRowsToContents()
        dialogWidth = self.table.horizontalHeader().length() + 25
        dialogHeight = self.table.verticalHeader().length() + 25
        self.resize(dialogWidth, dialogHeight)

        # Layout
        self.buttonLayout = QHBoxLayout()
        self.buttonLayout.addWidget(self.reopenButton)
        self.buttonLayout.addWidget(self.saveButton)
        self.buttonLayout.addWidget(self.closeButton)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(self.table)
        mainLayout.addLayout(self.buttonLayout)

        self.setLayout(mainLayout)
コード例 #13
0
 def __init__(self, corpus, recents):
     PhraseDialog.__init__(self)
     self.corpus = corpus
     self.recents = recents
     self.regularExpressions = None
     self.transcriptions = list()
     self.setWindowTitle('Seach by descriptive phrase')
     self.addDescription.setText('Add search description')
     self.introduction.setText(
         'Find a handshape with the following properties...')
     self.addFingerLayout()
     self.regularExpressions = list()
     showRecents = QPushButton('Show recent searches...')
     showRecents.clicked.connect(self.recentSearches)
     self.topButtonLayout.addWidget(showRecents)
コード例 #14
0
    def __init__(self, constraints):
        super().__init__()
        self.setWindowTitle('Select constraints')
        self.constraints = constraints
        layout = QVBoxLayout()

        self.transcriptionPage = QWidget()
        self.populateTranscriptionPage()
        self.simplePage = QWidget()
        self.populateSimplePage()
        self.conditionalPage = QWidget()
        self.populateConditionalPage()

        self.pageSelection = QComboBox()
        self.pageSelection.addItem('Transcription Constraints')
        self.pageSelection.addItem('Simple Constraints')
        self.pageSelection.addItem('Conditional Constraints')
        layout.addWidget(self.pageSelection)

        self.pages = QStackedWidget()
        self.pages.addWidget(self.transcriptionPage)
        self.pages.addWidget(self.simplePage)
        self.pages.addWidget(self.conditionalPage)
        self.pageSelection.currentIndexChanged.connect(self.pages.setCurrentIndex)
        self.pages.setCurrentIndex(0)
        layout.addWidget(self.pages)

        buttonLayout = QHBoxLayout()
        selectThisPageButton = QPushButton('Select all (this page)')
        selectThisPageButton.clicked.connect(self.selectThisPage)
        buttonLayout.addWidget(selectThisPageButton)
        selectAllButton = QPushButton('Select all (global)')
        selectAllButton.clicked.connect(self.selectAll)
        buttonLayout.addWidget(selectAllButton)
        removeThisPageButton = QPushButton('Unselect all (this page)')
        removeThisPageButton.clicked.connect(self.removeThisPage)
        buttonLayout.addWidget(removeThisPageButton)
        removeAllButton = QPushButton('Unselect all (global)')
        removeAllButton.clicked.connect(self.removeAll)
        buttonLayout.addWidget(removeAllButton)
        okCancelLayout = QHBoxLayout()
        ok = QPushButton('OK')
        cancel = QPushButton('Cancel')
        ok.clicked.connect(self.accept)
        cancel.clicked.connect(self.reject)
        okCancelLayout.addWidget(ok)
        okCancelLayout.addWidget(cancel)
        layout.addLayout(buttonLayout)
        layout.addLayout(okCancelLayout)

        self.setLayout(layout)
コード例 #15
0
class FunctionDialog(QDialog):
    header = None
    about = None
    name = ''

    def __init__(self, parent, settings, worker):
        super().__init__(parent)

        self.settings = settings

        self.setWindowTitle(self.name.title())

        self.newTableButton = QPushButton('Run/Restart')
        self.newTableButton.setDefault(True)
        self.newTableButton.clicked.connect(self.newTable)

        self.oldTableButton = QPushButton('Append to current results table')
        self.oldTableButton.clicked.connect(self.oldTable)

        self.cancelButton = QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.reject)

        self.aboutButton = QPushButton('About {}...'.format(self.name))
        self.aboutButton.clicked.connect(self.open_about)

        acLayout = QHBoxLayout()
        acLayout.addWidget(self.newTableButton)
        acLayout.addWidget(self.oldTableButton)
        acLayout.addWidget(self.cancelButton)
        acLayout.addWidget(self.aboutButton)

        self.thread = worker
        self.thread.dataReady.connect(self.setResults)

        #if self.settings['tooltips']:
        #    self.aboutButton.setToolTip(('<FONT COLOR=black>'
        #                                 '{}'
        #                                 '</FONT>'.format('\n'.join(self.about)))
        #                                )

        majorLayout = QVBoxLayout()
        majorLayout.addLayout(acLayout)

        self.setLayout(majorLayout)
        self.resize(1000, 500)

    @Slot(object)
    def setResults(self, results):
        pass  # Implemented in subclasses

    def generateKwargs(self):
        pass  # Implemented in subclasses

    def calc(self):
        kwargs = self.generateKwargs()
        #if kwargs is None:
        #    return
        self.thread.setParams(kwargs)
        self.thread.start()

        #result = self.progressDialog.exec_()

        #self.progressDialog.reset()
        #if result:
        #self.accept()

    def newTable(self):
        self.update = False
        self.calc()

    def oldTable(self):
        self.update = True
        self.calc()

    def open_about(self):
        #TODO: implement this
        pass
コード例 #16
0
    def __init__(self, corpus, recents, blankValue, wildcard):
        super().__init__()

        print('recents', recents)
        print('blankValue', blankValue)
        print('wildcard', wildcard)

        self.corpus = corpus
        self.recents = recents
        self.blankValue = blankValue
        self.wildcard = wildcard
        self.setWindowTitle('Search')
        self.setWindowFlags(Qt.WindowMaximizeButtonHint
                            | Qt.WindowMinimizeButtonHint
                            | Qt.WindowCloseButtonHint)

        layout = QVBoxLayout()

        #Set up up top layout
        self.topLayout = QHBoxLayout()
        explanation = QLabel()
        text = ('Enter the transcription you want to match in your corpus.')
        explanation.setText(text)
        explanation.setFont(QFont('Arial', 16))
        self.topLayout.addWidget(explanation)
        layout.addLayout(self.topLayout)

        #Set up config tabs
        self.configTabs = QTabWidget()
        self.configTabs.addTab(TranscriptionConfigTab(1), 'Config 1')
        self.configTabs.addTab(TranscriptionConfigTab(2), 'Config 2')
        layout.addWidget(self.configTabs)

        # Add "global" handshape options (as checkboxes)
        self.globalOptionsLayout = QHBoxLayout()
        self.setupGlobalOptions()
        layout.addLayout(self.globalOptionsLayout)

        #Add hand image
        self.infoPanel = QHBoxLayout()
        self.handImage = HandShapeImage(getMediaFilePath('hand.JPG'))
        self.infoPanel.addWidget(self.handImage)
        self.transcriptionInfo = TranscriptionInfo()
        self.infoPanel.addLayout(self.transcriptionInfo)
        layout.addLayout(self.infoPanel)

        #Connects some slots and signals
        for k in [0, 1]:
            for slot in self.configTabs.widget(k).hand1Transcription.slots[1:]:
                slot.slotSelectionChanged.connect(
                    self.handImage.useNormalImage)
                slot.slotSelectionChanged.connect(
                    self.handImage.transcriptionSlotChanged)
                slot.slotSelectionChanged.connect(
                    self.transcriptionInfo.transcriptionSlotChanged)
                slot.changeValidatorState(True)

            for slot in self.configTabs.widget(k).hand2Transcription.slots[1:]:
                slot.slotSelectionChanged.connect(
                    self.handImage.useReverseImage)
                slot.slotSelectionChanged.connect(
                    self.handImage.transcriptionSlotChanged)
                slot.slotSelectionChanged.connect(
                    self.transcriptionInfo.transcriptionSlotChanged)
                slot.changeValidatorState(True)

        buttonLayout = QHBoxLayout()
        blankOptionsButton = QPushButton('Search options...')
        blankOptionsButton.clicked.connect(self.showSearchOptions)
        buttonLayout.addWidget(blankOptionsButton)
        showRecents = QPushButton('Show recent searches...')
        showRecents.clicked.connect(self.recentSearches)
        ok = QPushButton('Search')
        ok.clicked.connect(self.accept)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(showRecents)
        buttonLayout.addWidget(ok)
        buttonLayout.addWidget(cancel)
        layout.addLayout(buttonLayout)
        self.setLayout(layout)
        self.showMaximized()
コード例 #17
0
    def __init__(self, corpus):
        super().__init__()
        self.corpus = corpus
        self.results = list()

        self.setWindowTitle('Functional Load')
        layout = QVBoxLayout()

        #Set up top row of radio button options
        contrastBox = QGroupBox('Contrast')
        contrastLayout = QHBoxLayout()
        self.contrastGroup = QButtonGroup()
        flexionOption = QRadioButton('Degrees of flexion')
        flexionOption.click()
        ductionOption = QRadioButton('Degree of duction')
        oppositionOption = QRadioButton('Thumb opposition')
        contactOption = QRadioButton('Thumb/finger contact')
        customOption = QRadioButton('Custom options')
        self.contrastGroup.addButton(flexionOption, id=0)
        self.contrastGroup.addButton(ductionOption, id=1)
        self.contrastGroup.addButton(oppositionOption, id=2)
        self.contrastGroup.addButton(contactOption, id=3)
        self.contrastGroup.addButton(customOption, id=4)
        contrastLayout.addWidget(flexionOption)
        contrastLayout.addWidget(ductionOption)
        contrastLayout.addWidget(oppositionOption)
        contrastLayout.addWidget(contactOption)
        contrastLayout.addWidget(customOption)
        contrastBox.setLayout(contrastLayout)

        #set up stacked widgets
        self.middleWidget = QStackedWidget()

        #Collapse degress of flexion
        flexionWidget = QWidget()
        flexionLayout = QHBoxLayout()
        self.flexionFingerSelection = QComboBox()
        self.flexionFingerSelection.addItems(
            ['Thumb', 'Index', 'Middle', 'Pinky', 'Ring', 'All'])
        self.flexionJointSelection = QComboBox()
        self.flexionJointSelection.addItems(
            ['Proximal', 'Medial', 'Distal', 'All'])
        #note: Thumb+Proximal not possible, and there's an alert window that will pop up if this combination is chosen
        flexionLayout.addWidget(self.flexionFingerSelection)
        flexionLayout.addWidget(self.flexionJointSelection)
        flexionWidget.setLayout(flexionLayout)

        #Collapse degrees of duction
        ductionWidget = QWidget()
        ductionLayout = QHBoxLayout()
        self.ductionFingerSelection = QComboBox()
        self.ductionFingerSelection.addItems([
            'Thumb/Finger', 'Index/Middle', 'Middle/Ring', 'Ring/Pinky', 'All'
        ])
        ductionLayout.addWidget(self.ductionFingerSelection)
        ductionWidget.setLayout(ductionLayout)

        #Collapse thumb opposition
        oppositionWidget = QWidget()
        oppositionLayout = QHBoxLayout()
        oppositionWidget.setLayout(oppositionLayout)

        #Collapse thumb/finger contact
        contactWidget = QWidget()
        contactLayout = QHBoxLayout()
        contactWidget.setLayout(contactLayout)

        #Collapse custom slots
        customWidget = QWidget()
        customLayout = QHBoxLayout()
        customLayout.addWidget(QLabel('Merge this symbol: '))
        self.customSymbo1A = QComboBox()
        self.customSymbo1A.addItem('')
        self.customSymbo1A.addItems(STANDARD_SYMBOLS)
        self.customSymbo1A.setEditable(True)
        customLayout.addWidget(self.customSymbo1A)
        customLayout.addWidget(QLabel('with this symbol: '))
        self.customSymbolB = QComboBox()
        self.customSymbolB.addItem('')
        self.customSymbolB.addItems(STANDARD_SYMBOLS)
        self.customSymbolB.setEditable(True)
        customLayout.addWidget(self.customSymbolB)
        customLayout.addWidget(QLabel('in these slots: '))
        self.customSlots = QLineEdit()
        customLayout.addWidget(self.customSlots)
        customLayout.addWidget(
            QLabel(
                '(separate numbers with commas, leave blank to merge symbols everywhere)'
            ))
        customWidget.setLayout(customLayout)

        #Build up middle widget
        self.middleWidget.addWidget(flexionWidget)
        self.middleWidget.addWidget(ductionWidget)
        self.middleWidget.addWidget(oppositionWidget)
        self.middleWidget.addWidget(contactWidget)
        self.middleWidget.addWidget(customWidget)

        #Connect slots and signals
        flexionOption.clicked.connect(self.changeMiddleWidget)
        ductionOption.clicked.connect(self.changeMiddleWidget)
        oppositionOption.clicked.connect(self.changeMiddleWidget)
        contactOption.clicked.connect(self.changeMiddleWidget)
        customOption.clicked.connect(self.changeMiddleWidget)

        #Bottom buttons (OK/Cancel)
        buttonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        ok.clicked.connect(self.accept)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(ok)
        buttonLayout.addWidget(cancel)

        layout.addWidget(contrastBox)
        layout.addWidget(self.middleWidget)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)
コード例 #18
0
    def __init__(self, constraints, configTabs):
        super().__init__()
        self.setWindowTitle('Transcription verification')
        layout = QVBoxLayout()
        if all([not value for value in constraints.values()]):
            layout.addWidget(QLabel('There were no problems detected with your transcription, '
                            'because no constraints have been selected. '
                          '\nTo set constraints, go to the Settings menu.'))
            buttonLayout = QHBoxLayout()
            ok = QPushButton('OK')
            ok.clicked.connect(self.accept)
            buttonLayout.addWidget(ok)
            layout.addLayout(buttonLayout)
            self.setLayout(layout)
            self.violations = {}
            return

        self.satisfied_message = 'This constraint is fully satisfied.\n("{}")'
        self.violations = {'config1hand1': {n:set() for n in range(35)}, 'config2hand1': {n:set() for n in range(35)},
                           'config1hand2': {n:set() for n in range(35)}, 'config2hand2': {n:set() for n in range(35)}}

        layout = QVBoxLayout()

        self.pageSelection = QComboBox()
        self.pageSelection.addItem('Transcription constraints')
        self.pageSelection.addItem('Simple constraints')
        self.pageSelection.addItem('Conditional constraints')
        layout.addWidget(self.pageSelection)

        self.pages = QStackedWidget()
        self.transcriptionsConstraintsTab = QTabWidget()
        self.transcriptionsConstraintsTab.currentChanged.connect(self.changedTab)
        self.pages.addWidget(self.transcriptionsConstraintsTab)
        self.simpleConstraintsTab = QTabWidget()
        self.simpleConstraintsTab.currentChanged.connect(self.changedTab)
        self.pages.addWidget(self.simpleConstraintsTab)
        self.conditionalConstraintsTab = QTabWidget()
        self.conditionalConstraintsTab.currentChanged.connect(self.changedTab)
        self.pages.addWidget(self.conditionalConstraintsTab)
        self.pageSelection.currentIndexChanged.connect(self.pages.setCurrentIndex)
        self.selected_page = 0
        self.selected_tab = 0
        self.page_maximum = self.pages.count()
        self.pages.currentChanged.connect(self.changedPage)

        #first, add all of the selected constraints to the stacked widgets
        # selected_constraints = list()
        # for c in MasterConstraintList:
        #     alert_text = list()
        #     constraint_text = list()
        #     if constraints[c[0]]:
        #         selected_constraints.append(c)
        #         tab = ConstraintTab()
        #         if c[1].constraint_type == 'transcription':
        #             self.transcriptionsConstraintsTab.addTab(tab, c[1].name)
        #         elif c[1].constraint_type == 'simple':
        #             self.simpleConstraintsTab.addTab(tab, c[1].name)
        #         elif c[1].constraint_type == 'conditional':
        #             self.conditionalConstraintsTab.addTab(tab, c[1].name)
        #             no_problems = True
        #then check to see if any constraints are actually violated
        #if they are, then add them to the self.violations set

        problems = dict()
        for constraint_name, constraint in MasterConstraintList:
            if not constraints[constraint_name]:
                continue
            if constraint in UnsupportedConstraints:
                problems[constraint_name] = [(('The constraint "{}" is not supported '
                                            'in the current version of SLPAnnotator'.format(constraint_name)), constraint)]
                continue
            for j in [1,2]:
                for k in [0,1]:
                    transcription = 'hand{}Transcription'.format(j)
                    transcription = getattr(configTabs.widget(k), transcription)
                    result = constraint.check(transcription.slots)
                    if result:
                        handconfig = 'config{}hand{}'.format(k+1, j)
                        for slot in result.split(', '):
                            self.violations[handconfig][int(slot)].add(constraint.name)
                    else:
                        result = 'This constraint is fully satisfied.'
                    text = 'Config {}, Hand {}: {}'.format(k+1, j, result)
                    info = (text, constraint)
                    try:
                        problems[constraint_name].append(info)
                    except (KeyError, AttributeError):
                        problems[constraint_name] = [info]

        for name,details in problems.items():
            tab = ConstraintTab()
            constraint_type = details[-1][-1].constraint_type
            labeltext = '\n'.join([d[0] for d in details])
            tab.layout.addWidget(QLabel(labeltext))
            if constraint_type == 'transcription':
                self.transcriptionsConstraintsTab.addTab(tab, name)
            elif constraint_type == 'simple':
                self.simpleConstraintsTab.addTab(tab, name)
            elif constraint_type == 'conditional':
                self.conditionalConstraintsTab.addTab(tab, name)

        if not problems:
            layout.addWidget(QLabel('All constraints are satisfied!'))
        else:
            layout.addWidget(self.pages)


        self.tab_maximum = {page_number:self.pages.widget(page_number).count()-1
                                     for page_number in range(self.page_maximum)}
        buttonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        ok.clicked.connect(self.accept)
        buttonLayout.addWidget(ok)

        layout.addLayout(buttonLayout)

        self.setLayout(layout)