def __init__(self, tag: str):
        """
        Init self with a tag given as a str. See self.__doc__.

        :param tag: One of '+', '=', '≠'.
        """

        icons_base_dir = cvars.get('icons.path')
        icons_type = cvars.get('icons.context')  # e.g. 'blue'
        icons_dir = path_helper(icons_base_dir) / icons_type

        if tag not in ['=', '+', '≠']:
            # TODO: catch the exception below?
            raise ValueError('tag must be one of "=", "+", "≠". tag: {tag}.')
        elif tag == '=':
            super().__init__('')  # No icon, empty icon trick
            return None
        elif tag == '+':
            icon_path = icons_dir / 'tag_plus.png'
        elif tag == '≠':
            icon_path = icons_dir / 'tag_different.png'

        # TODO: this overwrites previous code
        icon_path = path_helper(icons_base_dir) / 'checked.png'
        super().__init__(str(icon_path.resolve()))
    def __init__(self, parent):
        super().__init__(parent)

        # Icon
        self.iconWidget = QLabel(self)
        icons_base_dir = cvars.get("icons.path")
        error_icon_path = fs.path_helper(icons_base_dir) / 'cancel.png'
        success_icon_path = fs.path_helper(icons_base_dir) / 'checked.png'
        self.error_pixmap = QPixmap(str(error_icon_path.resolve()))
        self.success_pixmap = QPixmap(str(success_icon_path.resolve()))
        self.iconWidget.setScaledContents(True)
        self.iconWidget.setMaximumSize(self.height(), self.height())

        # Message
        self.messageWidget = QLabel("", self)

        # Insert icon and message
        self.insertWidget(0, self.iconWidget)
        self.insertWidget(1, self.messageWidget)
        self.show_success_icon()  # Trick: the status bar adapts its height
        self.hide_icon()

        # Verbose mode
        self.display_success_msgs = cvars.get(
            'display.display_success_messages', True)
    def __init__(self):
        super().__init__(_('Toolbar'))
        icons_base_dir = cvars.get("icons.path")
        icons_dir = fs.path_helper(icons_base_dir)
        self.rewind = QAction(
                QIcon(str((icons_dir / 'goback-begining.png').resolve())),
                _('Go back to beginning of proof'), self)
        self.undo_action = QAction(
                QIcon(str((icons_dir / 'undo_action.png').resolve())),
                _('Undo action'), self)
        self.redo_action = QAction(
                QIcon(str((icons_dir / 'redo_action.png').resolve())),
                _('Redo action'), self)

        self.toggle_lean_editor_action = QAction(
                QIcon(str((icons_dir / 'lean_editor.png').resolve())),
                _('Toggle L∃∀N'), self)

        self.change_exercise_action = QAction(
                QIcon(str((icons_dir / 'change_exercise.png').resolve())),
                _('Change exercise'), self)

        self.addAction(self.rewind)
        self.addAction(self.undo_action)
        self.addAction(self.redo_action)
        self.addAction(self.toggle_lean_editor_action)
        self.addSeparator()
        self.addAction(self.change_exercise_action)
Example #4
0
    def write_lean_path(self, dst_path: Path):
        """
        Writes the leanpkg.path file to the pointed
        file path.
        """

        with open(str(fs.path_helper(dst_path)), "w") as fhandle:
            for pp in self.lean_libs:
                print(f"path {str(pp)}", file=fhandle)
Example #5
0
    def __init__(self, path: Path,
                 archive_url: str,
                 archive_checksum: str = None,
                 archive_hlist: Path   = None,
                 archive_root: Path    = None,        # Root folder
                 archive_type: str     = "tar"):      # can be "tar" or "zip"
                 

        super().__init__(path)

        self.archive_url      = archive_url
        self.archive_checksum = archive_checksum
        self.archive_hlist    = fs.path_helper(archive_hlist)
        self.archive_root     = archive_root
        self.archive_type     = archive_type
Example #6
0
def init():
    global _

    log.info("Init i18n")

    available_languages = cvars.get("i18n.available_languages", "en")
    #available_languages = available_languages.split(", ")

    select_language = cvars.get('i18n.select_language', "en")

    log.info(f"available_languages = {available_languages}")
    log.info(f"select_language     = {select_language}")

    language_dir_path = fs.path_helper(cdirs.share / "locales")
    language = gettext.translation('deaduction',
                                   localedir=str(language_dir_path),
                                   languages=[select_language])
    language.install()

    _ = language.gettext
    def __init__(self, statement: Statement):
        """
        Init self with an instance of the class (or child of) Statement.

        :param statement: The instance of the class (or child) one wants
            to associate to self.
        """
        if StatementsTreeWidget.show_lean_name_for_statements:
            to_display = [statement.pretty_name, statement.lean_name]
        else:
            to_display = [statement.pretty_name]

        super().__init__(None, to_display)

        self.statement = statement

        # Print second col. in gray
        self.setForeground(1, QBrush(QColor('gray')))
        # TODO: use mono font for lean name column (column 1)

        # Print icon (D for definition, T for theorem, etc)
        icons_base_dir = cvars.get("icons.path")
        icons_type = cvars.get("icons.letter_type")

        icons_dir = fs.path_helper(icons_base_dir) / icons_type
        if isinstance(statement, Definition):
            path = icons_dir / 'd.png'
        elif isinstance(statement, Exercise):
            path = icons_dir / 'e.png'
        elif isinstance(statement, Theorem):
            path = icons_dir / 't.png'
        self.setIcon(0, QIcon(str(path.resolve())))

        # Set tooltip
        self.setToolTip(0, statement.caption)
        # These tooltips contain maths
        # math_font_name = 'Default'  # FIXME!!
        math_font_name = cvars.get('display.mathematics_font', 'Default')
        QToolTip.setFont(math_font_name)
Example #8
0
 def __init__(self, path: Path):
     self.path   = fs.path_helper(path)