Exemple #1
0
    def _showPopupMenu(self, event):
        """
        Shows the popup menu that allows the user to retake or delete the
        selected measurements.
        """
        UNUSED, rows = self._treeView.get_selection().get_selected_rows()
        currents = self._currentsFromRows(rows)

        retakeText = ngettext(
            '_Retake Selected Measurement',
            '_Retake Selected Measurements', len(currents))
        deleteText = ngettext(
            '_Delete Selected Measurement',
            '_Delete Selected Measurements', len(currents))

        menu = gtk.Menu()
        retakeItem = addMenuItem(menu, retakeText, gtk.STOCK_REFRESH,
            self._retakeSelectedMeasurementsActivated, currents)
        deleteItem = addMenuItem(menu, deleteText, gtk.STOCK_DELETE,
            self._deleteSelectedMeasurementsActivated, currents)
        menu.show_all()

        if len(currents) == 0 or self._system.isLocked:
            retakeItem.set_sensitive(False)
            deleteItem.set_sensitive(False)

        # The first three parameters are only relevant for submenus.
        menu.popup(None, None, None, event.button, event.time)

        return menu   # For testing purposes.
Exemple #2
0
def getMessage(status, used, unused, calibrated, wasCalibrated):
    """
    """
    if status == STATUS_ABORTED:
        text = gettext('The calibration procedure has been aborted.')
    elif len(used) > 0:
        text = gettext('The calibration procedure has finished')
        if not calibrated:
            text += gettext(
                ', but too few measurements have been taken to fit'
                ' the estimation functions')
        text += gettext('.')
    else:
        text = ''

    text += '\n\n'

    if len(used) == 0:
        text += gettext('No measurements have been taken')
        if status == STATUS_INVALID_CURRENT:
            text += ngettext(
                ' because the current exceeds the system\'s maximum current',
                ' because all currents exceed the system\'s maximum current',
                len(unused))
        elif status == STATUS_SAFE_MODE_TRIGGERED:
            text += gettext(
                ' because the temperature sensor voltage recorded while '
                ' heating with %s exceeds the system\'s safety threshold')
            text = text % ngettext(
                'the current', 'the first current', len(unused))
        elif status == STATUS_FINISHED:
            text += gettext(' because there were no currents to use')
        text += gettext('.')
    else:
        text += ngettext(
            'A measurement has been taken for the current %s mA.',
            'Measurements have been taken for the currents %s mA.',
            len(used))
        text = text % makeList(used)

        if len(unused) > 0:
            text += '\n\n'

            text += ngettext(
                'No measurement has been taken for the current %s mA',
                'No measurements have been taken for the currents %s mA',
                len(unused))
            text = text % makeList(unused)
            if status == STATUS_INVALID_CURRENT:
                text += ngettext(
                    ' because it exceeds the system\'s maximum current',
                    ', because they exceed the system\'s maximum current',
                    len(unused))
            elif status == STATUS_SAFE_MODE_TRIGGERED:
                text += gettext(
                    ' because the temperature sensor voltage recorded while '
                    ' heating with %s exceeds the system\'s safety threshold')
                text = text % ngettext(
                    'that current', 'the first of these currents', len(unused))
            text += gettext('.')

        if calibrated:
            text += '\n\n'
            if wasCalibrated:
                text += gettext('The estimation functions have been updated.')
            else:
                text += gettext('The estimation functions have been fitted.')

    return text.strip()