예제 #1
0
    def set_max_results(self, value=None):
        """
        Set maximum amount of results to add to the result browser.

        Parameters
        ----------
        value: int, optional
            Number of results. If None an input dialog will be used.
            Default is None.
        """
        if value is None:
            # Create dialog
            dialog = QInputDialog(self)

            # Set dialog properties
            dialog.setModal(False)
            dialog.setWindowTitle(self.get_name())
            dialog.setLabelText(_('Set maximum number of results: '))
            dialog.setInputMode(QInputDialog.IntInput)
            dialog.setIntRange(1, 10000)
            dialog.setIntStep(1)
            dialog.setIntValue(self.get_option('max_results'))

            # Connect slot
            dialog.intValueSelected.connect(
                lambda value: self.set_option('max_results', value))

            dialog.show()
        else:
            self.set_option('max_results', value)
예제 #2
0
    def change_history_depth(self, value=None):
        """
        Set history maximum entries.

        Parameters
        ----------
        value: int or None, optional
            The valur to set  the maximum history depth. If no value is
            provided, an input dialog will be launched. Default is None.
        """
        if value is None:
            dialog = QInputDialog(self)

            # Set dialog properties
            dialog.setModal(False)
            dialog.setWindowTitle(_("History"))
            dialog.setLabelText(_("Maximum entries"))
            dialog.setInputMode(QInputDialog.IntInput)
            dialog.setIntRange(MIN_HISTORY_ENTRIES, MAX_HISTORY_ENTRIES)
            dialog.setIntStep(1)
            dialog.setIntValue(self.get_option("max_entries"))

            # Connect slot
            dialog.intValueSelected.connect(
                lambda value: self.set_option("max_entries", value))

            dialog.show()
        else:
            self.set_option("max_entries", value)
예제 #3
0
    def GetInputOptions(
        self, message='', options='', default='', address='', addressType=''
    ):
        # Construct the list of options if options are given
        ok = False
        item = ''
        if options != '':
            input_dialog = QInputDialog()
            input_dialog.setComboBoxItems(options)
            input_dialog.setComboBoxEditable(False)
            if default:  # of there is no default, the first item will be the default
                input_dialog.setTextValue(default)
            input_dialog.setWindowTitle("Input")
            input_dialog.setLabelText(message)
            input_dialog.setModal(False)
            input_dialog.show()
            while input_dialog.isVisible():
                QCoreApplication.processEvents()
            ok = input_dialog.result()
            item = input_dialog.textValue()
        response = item if ok and item else 'stop'

        if response == 'stop':
            self.addlog(response)
            raise Exception('User requested stop')
        self.StoreMeasurement(address, addressType, response)
        self.addlog(response)
        return self.returnlog()
예제 #4
0
    def GetInput(self, message='', default='', address='', addressType=''):
        input_dialog = QInputDialog()
        input_dialog.setTextEchoMode(QLineEdit.Normal)
        input_dialog.setTextValue(default)
        input_dialog.setWindowTitle("Input")
        input_dialog.setLabelText(message)
        input_dialog.setModal(False)
        input_dialog.show()
        while input_dialog.isVisible():
            QCoreApplication.processEvents()
        ok = input_dialog.result()
        item = input_dialog.textValue()
        response = item if ok else 'stop'

        if response == '':
            response = default
        elif response == 'stop':
            self.addlog(response)
            raise Exception('User requested stop')
        self.StoreMeasurement(address, addressType, response)
        self.addlog(response)
        return self.returnlog()