示例#1
0
 def setUpClass(cls):
     QCoreApplication.setApplicationName("test1")
     QCoreApplication.setOrganizationName("org1")
     QSettings.setDefaultFormat(QSettings.IniFormat)
     cls.settings_dir = tempfile.TemporaryDirectory()
     QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
                       cls.settings_dir.name)
示例#2
0
    def test_first_time_focus_uses_correct_default_save_directory(self, mock_load_cal,
                                                                  mock_enggutils_focus_run, mock_get_output_path):

        default_save_location = path.join(path.expanduser("~"), "Engineering_Mantid")
        QCoreApplication.setApplicationName("Engineering_Diffraction_test_calib_model")
        presenter = settings_presenter.SettingsPresenter(mock.create_autospec(settings_model.SettingsModel),
                                                         mock.create_autospec(settings_view.SettingsView))
        presenter.settings = {  # "save_location" is not defined
                              "full_calibration": "cal",
                              "logs": "some,logs",
                              "primary_log": "some",
                              "sort_ascending": True,
                              "default_peak": "BackToBackExponential"
                              }
        presenter._validate_settings()  # save_location now set to the default value at runtime
        self.assertEqual(presenter.settings['save_location'], default_save_location)

        # this is the runtime return from output_settings.get_output_path()
        # if called at define time in a default parameter value then this value is not used
        mock_get_output_path.return_value = default_save_location

        mock_load_cal.return_value = "full_calibration"
        self.calibration.group = GROUP.BOTH

        self.model.focus_run(["305761"], "fake/van/path", plot_output=False, rb_num=None,
                             calibration=self.calibration)  # save_dir not given

        mock_enggutils_focus_run.assert_called_once_with(["305761"], "fake/van/path", False, None, self.calibration,
                                                         default_save_location, "full_calibration")
        # sample_paths, vanadium_path, plot_output, rb_num, calibration, save_dir, full_calib
        QCoreApplication.setApplicationName(APPNAME)  # reset to 'mantidworkbench' in case required by other tests
示例#3
0
def main():
    from qtpy.QtCore import QCoreApplication
    from qtpy.QtWidgets import QApplication
    from qtpy import API

    import hyperspyui.info
    from hyperspyui.settings import Settings

    # Need to set early to make QSettings accessible
    QCoreApplication.setApplicationName("HyperSpyUI")
    QCoreApplication.setOrganizationName("Hyperspy")
    QCoreApplication.setApplicationVersion(hyperspyui.info.version)

    # First, clear all default settings!
    # TODO: This will cause a concurrency issue with multiple launch
    Settings.clear_defaults()
    # Setup default for single/multi-instance
    settings = Settings(group="General")
    settings.set_default('allow_multiple_instances', False)
    if settings['allow_multiple_instances', bool]:
        # Using multiple instances, get a new application
        app = QApplication(sys.argv)
    else:
        # Make sure we only have a single instance
        from hyperspyui.singleapplication import get_app
        app = get_app('hyperspyui')

    splash = get_splash()

    log_file = _get_logfile()
    if log_file:
        sys.stdout = sys.stderr = log_file
    else:

        @contextmanager
        def dummy_context_manager(*args, **kwargs):
            yield

        log_file = dummy_context_manager()

    with log_file:
        # Need to have import here, since QApplication needs to be called first
        from hyperspyui.mainwindow import MainWindow

        form = MainWindow(splash=splash)
        if not settings['allow_multiple_instances', bool]:
            if "pyqt" in API:
                app.messageAvailable.connect(form.handleSecondInstance)
            elif API == 'pyside':
                app.messageReceived.connect(form.handleSecondInstance)
        form.showMaximized()

        form.splash.hide()
        form.load_complete.emit()
        # Ensure logging is OK
        import hyperspy.api as hs
        hs.set_log_level(LOGLEVEL)

        app.exec_()
示例#4
0
def init_qt_info():
    QCoreApplication.setOrganizationName('busimus')
    QCoreApplication.setOrganizationDomain('busz.me')
    QCoreApplication.setApplicationName('cutelog')
    version = get_distribution(QCoreApplication.applicationName()).version
    QCoreApplication.setApplicationVersion(version)
    if not QT55_COMPAT:  # this attribute was introduced in Qt 5.6
        QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
示例#5
0
def main():
    from qtpy.QtCore import Qt, QCoreApplication
    from qtpy.QtWidgets import QApplication
    from qtpy import API

    import hyperspyui.info
    from hyperspyui.settings import Settings

    QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
    # Need to set early to make QSettings accessible
    QCoreApplication.setApplicationName("HyperSpyUI")
    QCoreApplication.setOrganizationName("Hyperspy")
    QCoreApplication.setApplicationVersion(hyperspyui.info.__version__)

    # First, clear all default settings!
    # TODO: This will cause a concurrency issue with multiple launch
    Settings.clear_defaults()
    # Setup default for single/multi-instance
    settings = Settings(group="General")
    settings.set_default('allow_multiple_instances', False)
    if settings['allow_multiple_instances', bool]:
        # Using multiple instances, get a new application
        app = QApplication(sys.argv)
    else:
        # Make sure we only have a single instance
        from hyperspyui.singleapplication import get_app
        app = get_app('hyperspyui')

    splash = get_splash()

    log_file = _get_logfile()
    if log_file:
        sys.stdout = sys.stderr = log_file
    else:
        @contextmanager
        def dummy_context_manager(*args, **kwargs):
            yield
        log_file = dummy_context_manager()

    with log_file:
        # Need to have import here, since QApplication needs to be called first
        from hyperspyui.mainwindow import MainWindow

        form = MainWindow(splash=splash)
        if not settings['allow_multiple_instances', bool]:
            if "pyqt" in API:
                app.messageAvailable.connect(form.handleSecondInstance)
            elif API == 'pyside':
                app.messageReceived.connect(form.handleSecondInstance)
        form.showMaximized()

        form.splash.hide()
        form.load_complete.emit()
        # Ensure logging is OK
        import hyperspy.api as hs
        hs.set_log_level(LOGLEVEL)

        app.exec_()
示例#6
0
def patchSettings(monkeypatch):
    appName = "Cycle Tracks"
    orgName = "Tracks"
    d = os.path.dirname(__file__)
    # if conf file exists in test dir, remove it, so we're always testing with
    # defaults, unless changed in te test
    confFile = os.path.join(d, ".config", orgName, appName + ".conf")
    if os.path.exists(confFile):
        os.remove(confFile)
    monkeypatch.setenv("HOME", d)
    QCoreApplication.setApplicationName(appName)
    QCoreApplication.setOrganizationName(orgName)
示例#7
0
    def __init__(self):
        # settings config
        QCoreApplication.setApplicationName(DEFAULT_SETTINGS[APP_NAME])
        QCoreApplication.setOrganizationDomain(
            DEFAULT_SETTINGS[ORGANIZATION_DOMAIN])
        QCoreApplication.setOrganizationName(
            DEFAULT_SETTINGS[ORGANIZATION_NAME])

        self.settings = QSettings()

        # Fill defaults
        if self.settings.value(APP_NAME,
                               type=str) != DEFAULT_SETTINGS[APP_NAME]:
            for key, value in DEFAULT_SETTINGS.items():
                self.set(key, value)
def set_application_name(interface_script_name):
    app_name = APP_NAME_SWITCHER.get(interface_script_name, "mantid")
    QCoreApplication.setOrganizationName(" ")
    QCoreApplication.setApplicationName(app_name)
示例#9
0
            self.plotWidget.ymax = self.ymax
            self.plotWidget.draw()

    @property
    def xmin(self):
        return self.xminSpinBox.value()

    @property
    def xmax(self):
        return self.xmaxSpinBox.value()

    @property
    def ymin(self):
        return self.yminSpinBox.value()

    @property
    def ymax(self):
        return self.ymaxSpinBox.value()

    @property
    def autoscale(self):
        return self.autoscaleButtonGroup.checkedId()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    QCoreApplication.setApplicationName("USTempCtrl")
    QCoreApplication.setOrganizationName("KUZ")
    w = PlotSettingsWidget()
    w.show()
    app.exec_()
示例#10
0
    import zipfile

    zip_ref = zipfile.ZipFile(os.path.dirname(os.__file__), "r")
    zip_ref.extractall(os.path.dirname(os.path.dirname(os.__file__)))
    zip_ref.close()

os.environ["QT_API"] = "pyqt5"
import qtpy
from qtpy.QtWidgets import QApplication, QErrorMessage
from qtpy.QtCore import QCoreApplication, QProcess

if qtpy.API_NAME == "PyQt5" and "PySide" in sys.modules:
    del sys.modules["PySide"]

QCoreApplication.setOrganizationName("Camera")
QCoreApplication.setApplicationName("Xi-cam")


def _main(args, exec=True):
    # import pydm
    # app = QApplication([])
    # app = pydm.PyDMApplication()
    app = QApplication.instance() or QApplication([])
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    from xicam.gui.windows import splash
    from xicam.core import msg

    if getattr(args, 'verbose', False):
        QErrorMessage.qtHandler()
示例#11
0
 def setUpClass(cls):
     QCoreApplication.setApplicationName("test1")
     QCoreApplication.setOrganizationName("org1")
     QSettings.setDefaultFormat(QSettings.IniFormat)
示例#12
0
            self.plotWidget.draw()

    @property
    def xmin(self):
        return self.xminSpinBox.value()

    @property
    def xmax(self):
        return self.xmaxSpinBox.value()

    @property
    def ymin(self):
        return self.yminSpinBox.value()

    @property
    def ymax(self):
        return self.ymaxSpinBox.value()

    @property
    def autoscale(self):
        return self.autoscaleButtonGroup.checkedId()


if __name__ == "__main__":
    app = QApplication(sys.argv)
    QCoreApplication.setApplicationName("USTempCtrl")
    QCoreApplication.setOrganizationName("KUZ")
    w = PlotSettingsWidget()
    w.show()
    app.exec_()
示例#13
0
def main():
    from qtpy.QtCore import Qt, QCoreApplication
    from qtpy.QtWidgets import QApplication
    from qtpy import API

    import hyperspyui.info
    from hyperspyui.settings import Settings

    # QtWebEngineWidgets must be imported before a QCoreApplication instance
    # is created (used in eelsdb plugin)
    # Avoid a bug in Qt: https://bugreports.qt.io/browse/QTBUG-46720
    from qtpy import QtWebEngineWidgets

    # Need to set early to make QSettings accessible
    QCoreApplication.setApplicationName("HyperSpyUI")
    QCoreApplication.setOrganizationName("Hyperspy")
    QCoreApplication.setApplicationVersion(hyperspyui.info.__version__)
    # To avoid the warning:
    # Qt WebEngine seems to be initialized from a plugin. Please set
    # Qt::AA_ShareOpenGLContexts using QCoreApplication::setAttribute before
    # constructing QGuiApplication.
    # Only available for pyqt>=5.4
    if hasattr(Qt, "AA_ShareOpenGLContexts"):
        QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)

    # First, clear all default settings!
    # TODO: This will cause a concurrency issue with multiple launch
    Settings.clear_defaults()
    # Setup default for single/multi-instance
    settings = Settings(group="General")
    settings.set_default('allow_multiple_instances', False)
    if settings['allow_multiple_instances', bool]:
        # Using multiple instances, get a new application
        app = QApplication(sys.argv)
    else:
        # Make sure we only have a single instance
        from hyperspyui.singleapplication import get_app
        app = get_app('hyperspyui')

    splash = get_splash()

    log_file = _get_logfile()
    if log_file:
        sys.stdout = sys.stderr = log_file
    else:

        @contextmanager
        def dummy_context_manager(*args, **kwargs):
            yield

        log_file = dummy_context_manager()

    with log_file:
        # Need to have import here, since QApplication needs to be called first
        from hyperspyui.mainwindow import MainWindow

        form = MainWindow(splash=splash)
        if not settings['allow_multiple_instances', bool]:
            if "pyqt" in API:
                app.messageAvailable.connect(form.handleSecondInstance)
            elif API == 'pyside':
                app.messageReceived.connect(form.handleSecondInstance)
        form.showMaximized()

        form.splash.hide()
        form.load_complete.emit()
        # Ensure logging is OK
        import hyperspy.api as hs
        hs.set_log_level(LOGLEVEL)

        app.exec_()
示例#14
0
from qtpy.QtCore import QCoreApplication, QSettings

ORGANIZATION_NAME = 'Thaka'
ORGANIZATION_DOMAIN = 'Thaka.sd'
APPLICATION_NAME = 'Byakugan'

QCoreApplication.setOrganizationName(ORGANIZATION_NAME)
QCoreApplication.setOrganizationDomain(ORGANIZATION_DOMAIN)
QCoreApplication.setApplicationName(APPLICATION_NAME)

settings = QSettings()
settings.setValue('t', True)
s = settings.value('t', type=bool)
print(s)
print(type(s))
# settings.clear()