예제 #1
0
파일: main.py 프로젝트: hf6391964/crispy
    def successful(self, successful):
        # Scroll to the bottom of the logger widget.
        scrollBar = self.parent().loggerWidget.verticalScrollBar()
        scrollBar.setValue(scrollBar.maximum())

        self.calculationPushButton.disconnect()

        path = os.path.join("gui", "icons", "play.svg")
        icon = QIcon(resourceAbsolutePath(path))
        self.calculationPushButton.setIcon(icon)
        self.calculationPushButton.setText("Run")
        self.calculationPushButton.setToolTip("Run Quanty.")
        self.calculationPushButton.clicked.connect(self.run)

        if not successful:
            return

        # If the "Hamiltonian Setup" page is currently selected, when the
        # current widget is set to the "Results Page", the former is not
        # displayed. To avoid this we switch first to the "General Setup" page.
        self.toolBox.setCurrentWidget(self.generalPage)
        self.toolBox.setCurrentWidget(self.resultsPage)

        # Move the state to the results model.
        self.state.setParent(self.resultsPage.model.rootItem())
        self.state.checkState = Qt.Checked
        index = self.state.index()
        self.resultsPage.view.setCurrentIndex(index)

        removeFiles = Config().settings.value("Quanty/RemoveFiles", type=bool)
        if removeFiles:
            self.state.clean()
예제 #2
0
파일: loggers.py 프로젝트: jminar/crispy
def setUpLoggers():
    """Setup the application loggers."""
    logger = logging.getLogger("crispy")
    # Set the top level logger to debug, and refine the handlers.
    # https://stackoverflow.com/questions/17668633/what-is-the-point-of-setlevel-in-a-python-logging-handler
    logger.setLevel(logging.DEBUG)
    # Don't pass events logged by this logger to the handlers of the ancestor loggers.
    # logger.propagate = False

    logfmt = "%(asctime)s.%(msecs)03d | %(name)s | %(levelname)s | %(message)s"
    datefmt = "%Y-%m-%d | %H:%M:%S"
    formatter = logging.Formatter(logfmt, datefmt=datefmt)

    handler = logging.StreamHandler()
    handler.setLevel(logging.DEBUG)
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    logfile = os.path.join(Config().path, "crispy.log")
    handler = logging.FileHandler(logfile)
    handler.setLevel(logging.DEBUG)
    handler.setFormatter(formatter)
    logger.addHandler(handler)

    message = f"Debug log file: {logfile}"
    logger.info(message)
예제 #3
0
파일: main.py 프로젝트: jminar/crispy
def main():
    app = QApplication([])

    # This must be done after the application is instantiated.
    locale = QLocale(QLocale.C)
    locale.setNumberOptions(QLocale.OmitGroupSeparator)
    QLocale.setDefault(locale)

    config = Config()
    config.removeOldFiles()

    setUpLoggers()

    logger.info("Starting the application.")
    window = MainWindow()
    window.show()
    logger.info("Ready.")

    sys.exit(app.exec_())
예제 #4
0
    def executablePath(self):
        path = Config().read().value("Quanty/Path")

        if path is None:
            message = ("The path to the Quanty executable is not set. "
                       "Please use the preferences menu to set it.")
            raise FileNotFoundError(message)

        # Test the executable.
        with open(os.devnull, "w") as fp:
            try:
                subprocess.call(path, stdout=fp, stderr=fp)
            except FileNotFoundError as e:
                message = ("The Quanty executable is not working properly. "
                           "Is the PATH set correctly?")
                logger.error(message)
                raise e
        return path
예제 #5
0
    def successful(self, successful):
        # Scroll to the bottom of the logger widget.
        scrollBar = self.parent().loggerWidget.verticalScrollBar()
        scrollBar.setValue(scrollBar.maximum())

        if not successful:
            return

        # If the "Hamiltonian Setup" page is currently selected, when the
        # current widget is set to the "Results Page", the former is not
        # displayed. To avoid this we switch first to the "General Setup" page.
        self.toolBox.setCurrentWidget(self.generalPage)
        self.toolBox.setCurrentWidget(self.resultsPage)

        # Move the state to the results model.
        self.state.setParent(self.resultsPage.model.rootItem())
        self.state.checkState = Qt.Checked
        index = self.state.index()
        self.resultsPage.view.setCurrentIndex(index)

        removeFiles = Config().settings.value("Quanty/RemoveFiles", type=bool)
        if removeFiles:
            self.state.clean()
예제 #6
0
파일: main.py 프로젝트: hf6391964/crispy
def main():
    setUpLoggers()

    app = QApplication([])

    # This must be done after the application is instantiated.
    locale = QLocale(QLocale.C)
    locale.setNumberOptions(QLocale.OmitGroupSeparator)
    QLocale.setDefault(locale)

    config = Config()
    config.removeOldFiles()
    settings = config.read()
    # Set default values if the config file is empty or was not created.
    if not settings.allKeys():
        logger.debug("Loading default settings.")
        config.loadDefaults()

    logger.info("Starting the application.")
    window = MainWindow()
    window.show()
    logger.info("Ready.")

    sys.exit(app.exec_())
예제 #7
0
파일: details.py 프로젝트: jminar/crispy
# This work is licensed under the terms of the MIT license.       #
# For further information, see https://github.com/mretegan/crispy #
###################################################################
"""Quanty calculation details dialog"""

import os

from PyQt5.QtCore import QPoint, QSize
from PyQt5.QtWidgets import QDialog, QWidget
from PyQt5.uic import loadUi

from crispy import resourceAbsolutePath
from crispy.config import Config
from crispy.gui.utils import fixedFont, setMappings

settings = Config().read()


class AxisWidget(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        uiPath = os.path.join("gui", "uis", "quanty", "details", "axis.ui")
        loadUi(resourceAbsolutePath(uiPath), baseinstance=self, package="crispy.gui")

        self.mappers = list()

    def clear(self):
        if self.mappers:
            for mapper in self.mappers:
                mapper.clearMapping()