예제 #1
0
    def __init__(self):
        super().__init__('Number of extended fingers')

        groupLayout = QVBoxLayout()
        self.setLayout(groupLayout)

        logicComment = QLabel('Returned signs will contain ANY of the specificed numbers:')
        groupLayout.addWidget(logicComment)

        buttonLayout = QHBoxLayout()
        groupLayout.addLayout(buttonLayout)

        self.zero = QCheckBox('0')
        self.one = QCheckBox('1')
        self.two = QCheckBox('2')
        self.three = QCheckBox('3')
        self.four = QCheckBox('4')
        self.five = QCheckBox('5')
        self.zero.setChecked(True)
        self.one.setChecked(True)
        self.two.setChecked(True)
        self.three.setChecked(True)
        self.four.setChecked(True)
        self.five.setChecked(True)

        buttonLayout.addWidget(self.zero)
        buttonLayout.addWidget(self.one)
        buttonLayout.addWidget(self.two)
        buttonLayout.addWidget(self.three)
        buttonLayout.addWidget(self.four)
        buttonLayout.addWidget(self.five)
예제 #2
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)
    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)
    def __init__(self, results):
        super().__init__()

        layout = QHBoxLayout()

        table = QTableWidget()
        table.setColumnCount(5)
        table.setHorizontalHeaderLabels([
            'Starting corpus size', 'Starting entropy', 'Ending corpus size',
            'Ending entropy', 'Change in entropy'
        ])
        for result in results:
            table.insertRow(table.rowCount())
            for i, item in enumerate(result):
                newItem = QTableWidgetItem(str(item))
                table.setItem(table.rowCount() - 1, i, newItem)

        layout.addWidget(table)
        self.setLayout(layout)
예제 #5
0
    def __init__(self):
        super().__init__()

        style = 'QTabWidget::pane { /* The tab widget frame */' \
                'border: 5px solid #9B9B9B;' \
                'top: -0.75em;}'

        self.c1h1Tab = AdvancedFingerTab()
        self.c1h2Tab = AdvancedFingerTab()
        self.c2h1Tab = AdvancedFingerTab()
        self.c2h2Tab = AdvancedFingerTab()

        handTab = QTabWidget()
        handTab.setStyleSheet(style)
        handTab.addTab(self.c1h1Tab, 'Config1Hand1')
        handTab.addTab(self.c1h2Tab, 'Config1Hand2')
        handTab.addTab(self.c2h1Tab, 'Config2Hand1')
        handTab.addTab(self.c2h2Tab, 'Config2Hand2')

        self.logicPanel = LogicRadioButtonGroup('horizontal', 'all', 'Signs should contain',
                                                all='All four hand/configuration specifications',
                                                any='Any of the four hand/configuration specifications')

        self.searchModePanel = LogicRadioButtonGroup('horizontal', 'pos', 'Global search mode',
                                                     pos='Positive search',
                                                     neg='Negative search')

        #self.signTypePanel = LogicRadioButtonGroup('horizontal',
        #                                           'e',
        #                                           title='Sign type',
        #                                           sg='Only one-hand signs',
        #                                           db='Only two-hand signs',
        #                                           e='Either')

        self.handCheckboxGroup = QGroupBox('Hand')
        self.box1 = QCheckBox('One-hand signs')
        self.box2 = QCheckBox('Two-hand signs (H1 == H2)')
        self.box3 = QCheckBox('Two-hand signs (H1 != H2)')

        self.box1.setChecked(True)
        self.box2.setChecked(True)
        self.box3.setChecked(True)

        hBox = QHBoxLayout()
        hBox.addWidget(self.box1)
        hBox.addWidget(self.box2)
        hBox.addWidget(self.box3)
        self.handCheckboxGroup.setLayout(hBox)

        self.notePanel = QLineEdit()
        self.notePanel.setPlaceholderText('Enter notes here...')

        mainLayout = QVBoxLayout()
        self.setLayout(mainLayout)
        mainLayout.addWidget(handTab)
        mainLayout.addWidget(self.logicPanel)
        mainLayout.addWidget(self.searchModePanel)
        #mainLayout.addWidget(self.signTypePanel)
        mainLayout.addWidget(self.handCheckboxGroup)
        mainLayout.addWidget(self.notePanel)
예제 #6
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)
예제 #7
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)
    def __init__(self, direction, default, title='', **kwarg):
        super().__init__(title)

        if direction == 'vertical':
            buttonLayout = QVBoxLayout()
        else:  # direction == 'horizontal'
            buttonLayout = QHBoxLayout()

        self.buttonGroup = QButtonGroup()
        self.setLayout(buttonLayout)

        for short_name, text in kwarg.items():
            button = QRadioButton(text)
            button.clicked.connect(self.selected)
            if short_name == default:
                button.setChecked(True)
            self.buttonGroup.addButton(button)
            buttonLayout.addWidget(button)
예제 #9
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)
예제 #10
0
    def __init__(self):
        super().__init__('Finger configuration')
        mainLayout = QVBoxLayout()
        self.setLayout(mainLayout)

        fingerExtensionSpecificationLayout = QHBoxLayout()
        mainLayout.addLayout(fingerExtensionSpecificationLayout)

        self.optionsForT = FingerOptionGroup('Thumb')
        self.optionsForI = FingerOptionGroup('Index')
        self.optionsForM = FingerOptionGroup('Middle')
        self.optionsForR = FingerOptionGroup('Ring')
        self.optionsForP = FingerOptionGroup('Pinky')
        fingerExtensionSpecificationLayout.addWidget(self.optionsForT)
        fingerExtensionSpecificationLayout.addWidget(self.optionsForI)
        fingerExtensionSpecificationLayout.addWidget(self.optionsForM)
        fingerExtensionSpecificationLayout.addWidget(self.optionsForR)
        fingerExtensionSpecificationLayout.addWidget(self.optionsForP)

        self.logicGroup = LogicRadioButtonGroup('horizontal', 'a',
                                                title='Sign should contain:',
                                                a='All of the extensions',
                                                o='Any of the extensions')
        mainLayout.addWidget(self.logicGroup)
예제 #11
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())
class ParameterDialog(QDialog):
    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)

    def saveParameters(self):
        def traverse(item):
            item.parameter.is_checked = item.checkState()
            if item.isEditable():
                item.parameter.name = item.text()
            for m in range(item.rowCount()):
                newItem = item.child(m)
                traverse(newItem)

        output = list()
        for j in range(self.model.invisibleRootItem().rowCount()):
            item = self.model.item(j)
            traverse(item)
            output.append(self.model.item(j).parameter)

        return output

    def buildDisplayTree(self, modelItem, displayNode):
        canBeChecked = modelItem.isCheckable()
        if (not canBeChecked) or (canBeChecked and modelItem.checkState()):
            #display anything that cannot be checked (e.g. parent items like Quality or Location)
            #or display anything that could be checked and actually is
            newDisplayNode = anytree.Node(modelItem.text(), parent=displayNode)
            for n in range(modelItem.rowCount()):
                child = modelItem.child(n)
                self.buildDisplayTree(child, newDisplayNode)

    def generateDisplayTreeText(self):
        treeText = list()
        for pre, fill, node in anytree.RenderTree(self.displayTree):
            treeText.append("{}{}".format(pre, node.name))
        treeText = '\n'.join(treeText)
        self.displayTreeWidget.setText(treeText)

    def clear(self):
        continue_ = self.showWarning()
        if continue_:

            def traverse(item):
                item.parameter.is_checked = False
                if item.isCheckable():
                    item.setCheckState(False)
                for m in range(item.rowCount()):
                    newItem = item.child(m)
                    traverse(newItem)

            for j in range(self.model.invisibleRootItem().rowCount()):
                item = self.model.item(j)
                traverse(item)
            self.terminalNodesLabel.setText('No parameters selected')

    def reset(self):
        continue_ = self.showWarning()
        if continue_:

            def traverse(item):
                item.parameter.is_checked = item.parameter.is_default
                if item.isCheckable():
                    item.setCheckState(item.parameter.is_default)
                if item.isEditable():
                    item.setText('(Specify)')
                for m in range(item.rowCount()):
                    newItem = item.child(m)
                    traverse(newItem)

            for j in range(self.model.invisibleRootItem().rowCount()):
                item = self.model.item(j)
                traverse(item)

    def showWarning(self):
        alert = QMessageBox()
        alert.setWindowFlags(Qt.WindowStaysOnTopHint)
        alert.setWindowTitle('Warning')
        alert.setText(
            'This will erase your currently selected parameters. This action cannot be undone. Continue?'
        )
        alert.addButton('OK', QMessageBox.AcceptRole)
        alert.addButton('Cancel', QMessageBox.RejectRole)
        alert.exec_()
        role = alert.buttonRole(alert.clickedButton())
        if role == QMessageBox.AcceptRole:
            return True
        else:
            return False

    def closeEvent(self, e):
        self.close()

    def accept(self):
        self.saveParameters()
        self.adjustedHeight = self.frameGeometry().height()
        self.adjustedWidth = self.frameGeometry().width()
        self.adjustedPos = self.pos()
        self.hide()

    def reject(self):
        self.adjustedHeight = self.frameGeometry().height()
        self.adjustedWidth = self.frameGeometry().width()
        self.adjustedPos = self.pos()
        self.hide()

    def updateDisplayTree(self):
        self.displayTree = anytree.Node('Selected Parameters', parent=None)
        self.buildDisplayTree(self.model.invisibleRootItem(), self.displayTree)
        self.generateDisplayTreeText()
        self.updateTerminalNodes()

    def updateTerminalNodes(self):
        text = list()
        for pre, fill, node in anytree.RenderTree(self.displayTree):
            if node.is_leaf:
                text.append(' : '.join([node.parent.name, node.name]))
        text = '\n'.join(text)
        self.terminalNodesLabel.setText(text)
예제 #13
0
class TranscriptionSearchDialog(SearchDialog):
    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()

    def showSearchOptions(self):
        dialog = TranscriptionsSearchOptionsDialog(self.blankValue,
                                                   self.wildcard)
        if dialog.exec_():
            self.blankValue = dialog.blankOptionSelection
            self.wildcard = dialog.wildcard

    def recentSearches(self):
        result = self.showRecentSearches()
        if result is not None:
            results = result.recentData.segmentedTranscription
            results = [[results[0], results[1]], [results[2], results[3]]]
            for config in [0, 1]:
                for hand in [0, 1]:
                    widget = getattr(self.configTabs.widget(config),
                                     'hand{}Transcription'.format(hand + 1))
                    for n, symbol in enumerate(results[config][hand]):
                        slot = getattr(widget, 'slot{}'.format(n + 1))
                        slot.setText(symbol)

    def setupGlobalOptions(self):
        self.globalOptionsWidgets = list()
        globalOptionsLabel = QLabel('Global handshape options:')
        globalOptionsLabel.setFont(QFont(FONT_NAME, FONT_SIZE))
        self.globalOptionsLayout.addWidget(globalOptionsLabel)
        for option in GLOBAL_OPTIONS:
            widget = QCheckBox(option.title())
            option += 'CheckBox'
            setattr(self, option, widget)
            widget = getattr(self, option)
            self.globalOptionsLayout.addWidget(widget)
            self.globalOptionsWidgets.append(widget)

    def generateRegEx(self):
        expressions = list()

        for transcription in self.transcriptions:
            regex = list()
            for slot in transcription.slots:
                symbol = slot.text()
                if not symbol or symbol == ' ':
                    if self.blankValue == 'literal' or self.blankValue == 'both':
                        symbol = '_'
                    elif self.blankValue == 'wildcard':
                        symbol = '.'
                if symbol == self.wildcard:
                    symbol = '.'
                if symbol in ['?', '*', '$', '^', '+']:
                    symbol = '\\' + symbol

                regex.append(symbol)
            regex = ''.join(regex)
            expressions.append(regex)
        self.regularExpressions = expressions

    def generateTranscriptions(self):
        self.transcriptions = list()
        self.transcriptions.append(
            self.configTabs.widget(0).hand1Transcription)
        self.transcriptions.append(
            self.configTabs.widget(0).hand2Transcription)
        self.transcriptions.append(
            self.configTabs.widget(1).hand1Transcription)
        self.transcriptions.append(
            self.configTabs.widget(1).hand2Transcription)

    def generateGlobalOptions(self):
        for option in GLOBAL_OPTIONS:
            setattr(self, option,
                    getattr(self, option + 'CheckBox').isChecked())
예제 #14
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()
예제 #15
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)
예제 #16
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)
예제 #17
0
class PhraseDialog(QDialog):
    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)

    def clearLayout(self, layout):
        if layout is not None:
            while layout.count():
                item = layout.takeAt(0)
                widget = item.widget()
                if widget is not None:
                    widget.deleteLater()
                else:
                    self.clearLayout(item.layout())

    def removeFingerLayouts(self):
        for n in reversed(range(len(self.descriptionLayouts))):
            layout = self.metaLayout.itemAt(n)
            if layout.deleteMe.isChecked():
                layout = self.metaLayout.takeAt(n)
                self.descriptionLayouts.pop(n)
                while layout.count():
                    item = layout.takeAt(0)
                    widget = item.widget()
                    if widget is not None:
                        widget.deleteLater()

    def addFingerLayout(self, disable_quantifiers=False, allowAnyFinger=False):
        newLayout = FingerSearchLayout(allowAnyFinger)
        if disable_quantifiers:
            newLayout.quantifiers.removeItem(2)
            newLayout.quantifiers.removeItem(1)
            newLayout.configs.removeItem(2)
            newLayout.hands.removeItem(2)
        self.descriptionLayouts.append(newLayout)
        self.metaLayout.addLayout(newLayout)

    def addJointLayout(self):
        newLayout = JointSearchLayout()
        self.descriptionLayouts.append(newLayout)
        self.metaLayout.addLayout(newLayout)

    def findSlotNumbers(self, finger):
        if finger == 'thumb':
            slots = [4, 5]
        elif finger == 'index':
            slots = [17, 18, 19]
        elif finger == 'middle':
            slots = [22, 23, 24]
        elif finger == 'ring':
            slots = [27, 28, 29]
        elif finger == 'pinky':
            slots = [32, 33, 34]
        elif finger == 'any':
            slots = [4, 5, 17, 18, 19, 22, 23, 24, 32, 33, 34]
        return slots

    def findTranscriptionSymbol(self, description):
        description = description.lower()
        if description == 'unestimatable':
            symbol = '?'

        elif description == 'blank':
            symbol = ''

        elif 'extended' in description:
            if 'hyper' in description:
                symbol = 'H'
            elif 'fully' in description:
                symbol = 'E'
            elif 'somewhat' in description:
                symbol = 'e'
            else:
                symbol = 'HEe'

        elif 'flexed' in description:
            if 'fully' in description:
                symbol = 'F'
            elif 'somewhat' in description:
                symbol = 'f'
            else:
                symbol = 'Ff'

        elif 'intermediate' in description:
            if 'clearly' in description:
                symbol = 'i'
            else:
                symbol = 'efi'

        return symbol

    def generateTranscriptions(self):
        transcriptions = list()
        for regex in self.regularExpressions:
            t = list()
            for symbol in regex:
                if symbol == '.':
                    t.append('_')
                else:
                    t.append(symbol)
            transcriptions.append(t)
        self.transcriptions = transcriptions

    def generateGlobalOptions(self):
        self.forearm = False
        self.estimated = False
        self.uncertain = False
        self.incomplete = False
        self.reduplicated = False

    def generatePhrases(self):
        self.phrases = [
            layout.generatePhrase() for layout in self.descriptionLayouts
        ]

    def generateRegEx(self):
        mapping = {
            'config1hand1': (0, 'hand1Transcription'),
            'config1hand2': (0, 'hand2Transcription'),
            'config2hand1': (1, 'hand1Transcription'),
            'config2hand2': (1, 'hand2Transcription')
        }

        for layout in self.descriptionLayouts:
            transcriptions = {
                'config1hand1': [None for n in range(34)],
                'config1hand2': [None for n in range(34)],
                'config2hand1': [None for n in range(34)],
                'config2hand2': [None for n in range(34)]
            }

            finger = layout.fingers.currentText().lower()
            quantifier = layout.quantifiers.currentText().lower()
            config = layout.configs.currentText().lower().replace(' ', '')
            hand = layout.hands.currentText().lower().replace(' ', '')
            slots = self.findSlotNumbers(layout.fingers.currentText().lower())
            symbol = self.findTranscriptionSymbol(
                layout.flexions.currentText())

            configs = ['config1', 'config2'
                       ] if config == 'bothconfigs' else [config]
            hands = ['hand1', 'hand2'] if hand == 'bothhands' else [hand]

            if quantifier == 'all':
                pass  #symbol is normal
            elif quantifier == 'any':
                if finger == 'thumb':
                    symbol = '{}|.(?={})'.format(symbol, symbol)
                    slots = [slots[0], -1 * slots[1]]
                elif finger == 'any':
                    pass
                else:
                    symbol = '{}|.(?={})|.(?=.{})'.format(
                        symbol, symbol, symbol)
                    slots = [slots[0], -1 * slots[1], -1 * slots[2]]
                #this new "symbol" acts as a regex that looks ahead 2 or 3 slots, depending on the selected finger
                #we don't want to put this regex in each of those slots, but rather only in the first one
            elif quantifier == 'none':
                symbol = '[^{}]'.format(symbol)

            for c in configs:
                for h in hands:
                    for slot in slots:
                        if slot < 0:
                            transcriptions[c + h].pop(slot - 1 * -1)
                        else:
                            transcriptions[c + h][slot - 1] = symbol

            for key, value in transcriptions.items():
                regex = ['.' if v is None else v for v in value]
                transcriptions[key] = regex

            self.regularExpressions = [
                ''.join(transcriptions[key])
                for key in sorted(list(transcriptions.keys()))
            ]

    def accept(self):
        self.accepted = True
        super().accept()

    def reject(self):
        self.accepted = False
        super().reject()
    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)
예제 #19
0
class ResultsWindow(QDialog):
    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)

    # def sizeHint(self):
    #     sz = QDialog.sizeHint(self)
    #     minWidth = self.table.calcWidth()+41
    #     if sz.width() < minWidth:
    #
    #         sz.setWidth(minWidth)
    #     if sz.height() < 400:
    #         sz.setHeight(400)
    #     return sz

    def reopen(self):
        #TODO: maybe modify this so that function and result windows can appear together
        if self.dialog.exec_():
            if self.dialog.update:
                self.table.model().appendRows(self.dialog.results)
                self.table.resizeColumnsToContents()
                self.table.resizeRowsToContents()
            else:
                dataModel = ResultsTableModel(self.dialog.header,
                                              self.dialog.results)
                self.table.setModel(dataModel)
                self.table.resizeColumnsToContents()
                self.table.resizeRowsToContents()
        self.raise_()
        self.activateWindow()

    def save(self):
        fileDialog = QFileDialog(caption='Save results')
        fileDialog.setAcceptMode(QFileDialog.AcceptSave)
        fileDialog.setFileMode(QFileDialog.AnyFile)
        fileDialog.setNameFilter('Text files (*.txt *.tsv)')
        fileDialog.selectFile('results')
        fileDialog.setDefaultSuffix('txt')

        if fileDialog.exec_():
            filename = fileDialog.selectedFiles()
            with open(filename[0], mode='w', encoding='utf-8-sig') as f:
                model = self.table.model()
                writer = csv.writer(f, delimiter='\t')
                writer.writerow(model.header)
                for row in range(model.rowCount()):
                    entry = list()
                    for column in range(model.columnCount()):
                        idx = model.index(row, column)
                        dataPoint = str(model.data(idx))
                        entry.append(dataPoint)
                    writer.writerow(entry)
예제 #20
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)
예제 #21
0
    def __init__(self, corpus, parent, settings, recent):
        super().__init__(parent, settings, HSWorker())

        self.corpus = corpus
        self.recent = recent

        # container widget for scroll
        container = QWidget()

        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        scroll.setWidget(container)

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

        self.forearmLogic = LogicRadioButtonGroup('vertical', 'e',
                                                  title='Forearm',
                                                  y='Yes', n='No', e='Either')

        self.estimateLogic = LogicRadioButtonGroup('vertical', 'e',
                                                   title='Estimated',
                                                   y='Yes', n='No', e='Either')

        self.uncertainLogic = LogicRadioButtonGroup('vertical', 'e',
                                                    title='Uncertain',
                                                    y='Yes', n='No', e='Either')

        self.incompleteLogic = LogicRadioButtonGroup('vertical', 'e',
                                                     title='Incomplete',
                                                     y='Yes', n='No', e='Either')
        globalLayout.addWidget(self.forearmLogic)
        globalLayout.addWidget(self.estimateLogic)
        globalLayout.addWidget(self.uncertainLogic)
        globalLayout.addWidget(self.incompleteLogic)

        self.configLogic = LogicRadioButtonGroup('vertical', 'e',
                                                 title='Configuration',
                                                 one='One-config signs', two='Two-config signs', e='Either')
        self.configLogic.chosen.connect(self.handleConfigChange)

        #self.handLogic = LogicRadioButtonGroup('vertical', 'e',
        #                                       title='Hand',
        #                                       one='One-hand signs', two='Two-hand signs', e='Either')
        #self.handLogic.chosen.connect(self.handleHandChange)

        self.handCheckboxGroup = QGroupBox('Hand')
        self.box1 = QCheckBox('One-hand signs')
        self.box2 = QCheckBox('Two-hand signs (H1 == H2)')
        self.box3 = QCheckBox('Two-hand signs (H1 != H2)')

        self.box1.setChecked(True)
        self.box2.setChecked(True)
        self.box3.setChecked(True)

        self.box1.stateChanged.connect(self.handCheckboxGroupChange)
        self.box2.stateChanged.connect(self.handCheckboxGroupChange)
        self.box3.stateChanged.connect(self.handCheckboxGroupChange)

        vBox = QVBoxLayout()
        vBox.addWidget(self.box1)
        vBox.addWidget(self.box2)
        vBox.addWidget(self.box3)
        self.handCheckboxGroup.setLayout(vBox)

        self.createConfigHand()
        self.createHandshapes()

        self.logicPanel = LogicRadioButtonGroup('vertical',
                                                'all',
                                                title='Signs should contain...',
                                                all='All of the above configurations',
                                                any='Any of the above configurations')

        self.searchModePanel = LogicRadioButtonGroup('vertical', 'pos', 'Global search mode',
                                                     pos='Positive search',
                                                     neg='Negative search')

        self.notePanel = QLineEdit()
        self.notePanel.setPlaceholderText('Enter notes here...')

        mainLayout = QGridLayout()
        mainLayout.addWidget(globalFrame, 0, 0, 1, 2)
        mainLayout.addWidget(self.configLogic, 0, 2, 1, 1)
        #mainLayout.addWidget(self.handLogic, 0, 3, 1, 1)
        mainLayout.addWidget(self.handCheckboxGroup, 0, 3, 1, 1)
        mainLayout.addWidget(self.c1h1Group, 1, 0, 1, 1)
        mainLayout.addWidget(self.c1h2Group, 1, 1, 1, 1)
        mainLayout.addWidget(self.c2h1Group, 1, 2, 1, 1)
        mainLayout.addWidget(self.c2h2Group, 1, 3, 1, 1)
        mainLayout.addWidget(self.logicPanel, 2, 0, 1, 1)
        mainLayout.addWidget(self.searchModePanel, 2, 1, 1, 1)
        mainLayout.addWidget(self.otherGroup, 2, 2, 1, 2)
        mainLayout.addWidget(self.unmarkedGroup, 3, 0, 1, 4)
        mainLayout.addWidget(self.markedGroup, 4, 0, 1, 4)
        mainLayout.addWidget(self.notePanel, 5, 0, 1, 4)
        container.setLayout(mainLayout)

        #####This part should be removed later#####
        #self.testButton = QPushButton('test')
        #mainLayout.addWidget(self.testButton, 6, 0, 1, 1)
        #self.testButton.clicked.connect(self.test)
        #####This part should be removed later#####
        self.layout().insertWidget(0, scroll)
예제 #22
0
    def __init__(self, corpus, parent, settings, recent):
        super().__init__(parent, settings, TSWorker())

        self.corpus = corpus
        self.recent = recent

        globalFrame = QGroupBox('Global options')
        globalFrame.setFixedWidth(500)
        globalLayout = QHBoxLayout()
        globalFrame.setLayout(globalLayout)

        self.forearmLogic = LogicRadioButtonGroup('vertical',
                                                  'e',
                                                  title='Forearm',
                                                  y='Yes',
                                                  n='No',
                                                  e='Either')
        self.estimateLogic = LogicRadioButtonGroup('vertical',
                                                   'e',
                                                   title='Estimated',
                                                   y='Yes',
                                                   n='No',
                                                   e='Either')
        self.uncertainLogic = LogicRadioButtonGroup('vertical',
                                                    'e',
                                                    title='Uncertain',
                                                    y='Yes',
                                                    n='No',
                                                    e='Either')
        self.incompleteLogic = LogicRadioButtonGroup('vertical',
                                                     'e',
                                                     title='Incomplete',
                                                     y='Yes',
                                                     n='No',
                                                     e='Either')

        self.configLogic = LogicRadioButtonGroup('vertical',
                                                 'e',
                                                 title='Configuration',
                                                 one='One-config signs',
                                                 two='Two-config signs',
                                                 e='Either')
        #self.configLogic.setFixedWidth(150)

        self.handCheckboxGroup = QGroupBox('Hand')
        self.box1 = QCheckBox('One-hand signs')
        self.box2 = QCheckBox('Two-hand signs (H1 == H2)')
        self.box3 = QCheckBox('Two-hand signs (H1 != H2)')

        self.box1.setChecked(True)
        self.box2.setChecked(True)
        self.box3.setChecked(True)

        vBox = QVBoxLayout()
        vBox.addWidget(self.box1)
        vBox.addWidget(self.box2)
        vBox.addWidget(self.box3)
        self.handCheckboxGroup.setLayout(vBox)
        # TODO: implement function to handle the hand widget
        #self.handCheckboxGroup.setFixedWidth(150)

        #self.handLogic = LogicRadioButtonGroup('vertical', 'e', title='Hand', one='One-hand signs', two='Two-hand signs', e='Either')
        #self.handLogic.setFixedWidth(150)

        frequencyGroup = QGroupBox('Frequency')
        frequencyGroup.setFixedWidth(100)
        freqeuncyLayout = QVBoxLayout()
        frequencyGroup.setLayout(freqeuncyLayout)
        self.minLineEdit = QLineEdit(str(self.corpus.getFrequencyRange()[0]))
        self.maxLineEdit = QLineEdit(str(self.corpus.getFrequencyRange()[1]))
        freqeuncyLayout.addWidget(QLabel('From:'))
        freqeuncyLayout.addWidget(self.minLineEdit)
        freqeuncyLayout.addWidget(QLabel('To:'))
        freqeuncyLayout.addWidget(self.maxLineEdit)

        globalLayout.addWidget(self.forearmLogic)
        globalLayout.addWidget(self.estimateLogic)
        globalLayout.addWidget(self.uncertainLogic)
        globalLayout.addWidget(self.incompleteLogic)

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

        self.config1 = TransConfigTab()
        self.config1.setFixedWidth(1250)
        config1Layout.addWidget(self.config1)

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

        self.config2 = TransConfigTab()
        self.config2.setFixedWidth(1250)
        config2Layout.addWidget(self.config2)

        self.notePanel = QLineEdit()
        self.notePanel.setPlaceholderText('Enter notes here...')

        metaInfoGroup = QGroupBox()
        metaInfoLayout = QHBoxLayout()
        metaInfoGroup.setLayout(metaInfoLayout)
        self.coderSlot = CoderSlot(self.corpus)
        self.lastUpdatedSlot = LastUpdateSlot(self.corpus)
        metaInfoLayout.addWidget(QLabel('Coder:'))
        metaInfoLayout.addWidget(self.coderSlot)
        metaInfoLayout.addWidget(QLabel('Last updated:'))
        metaInfoLayout.addWidget(self.lastUpdatedSlot)

        mainLayout = QGridLayout()
        #self.setLayout(mainLayout)
        mainLayout.addWidget(globalFrame, 0, 0, 1, 1)
        mainLayout.addWidget(frequencyGroup, 0, 1, 1, 1)
        mainLayout.addWidget(self.configLogic, 0, 2, 1, 1)
        #mainLayout.addWidget(self.handLogic, 0, 3, 1, 1)
        mainLayout.addWidget(self.handCheckboxGroup, 0, 3, 1, 1)
        mainLayout.addWidget(config1Frame, 1, 0, 1, 4)
        mainLayout.addWidget(config2Frame, 2, 0, 1, 4)
        mainLayout.addWidget(metaInfoGroup, 3, 0, 1, 2)
        mainLayout.addWidget(self.notePanel, 3, 2, 1, 2)

        #self.testButton = QPushButton('test')
        #mainLayout.addWidget(self.testButton, 4, 0)
        #self.testButton.clicked.connect(self.test)
        self.layout().insertLayout(0, mainLayout)
예제 #23
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)
예제 #24
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)
예제 #25
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)