Пример #1
0
def pyFAI_calib2_main():
    # It have to be done before loading Qt
    # --help must also work without Qt
    options = parse_options()

    if options.debug:
        logging.root.setLevel(logging.DEBUG)

    # Then we can load Qt
    if options.opengl:
        silx.config.DEFAULT_PLOT_BACKEND = "opengl"

    pyFAI.resources.silx_integration()
    settings = qt.QSettings(qt.QSettings.IniFormat, qt.QSettings.UserScope,
                            "pyfai", "pyfai-calib2", None)

    context = CalibrationContext(settings)
    context.restoreSettings()

    setup_model(context.getCalibrationModel(), options)
    window = CalibrationWindowXdart(context)
    window.setVisible(True)
    window.setAttribute(qt.Qt.WA_DeleteOnClose, True)

    context.saveSettings()
Пример #2
0
def main():
    # It have to be done before loading Qt
    # --help must also work without Qt
    options = parse_options()

    if options.debug:
        logging.root.setLevel(logging.DEBUG)

    # Then we can load Qt
    import silx
    from silx.gui import qt
    if options.opengl:
        silx.config.DEFAULT_PLOT_BACKEND = "opengl"

    # Make sure matplotlib is loaded first by silx
    import silx.gui.plot.matplotlib
    from pyFAI.gui.CalibrationWindow import CalibrationWindow
    from pyFAI.gui.CalibrationContext import CalibrationContext

    sys.excepthook = logUncaughtExceptions
    if options.qtargs is None:
        qtArgs = []
    else:
        qtArgs = options.qtargs.split()
    app = qt.QApplication(qtArgs)
    pyFAI.resources.silx_integration()

    settings = qt.QSettings(qt.QSettings.IniFormat,
                            qt.QSettings.UserScope,
                            "pyfai",
                            "pyfai-calib2",
                            None)

    context = CalibrationContext(settings)
    context.restoreSettings()

    setup_model(context.getCalibrationModel(), options)
    window = CalibrationWindow(context)
    window.setVisible(True)
    window.setAttribute(qt.Qt.WA_DeleteOnClose, True)

    result = app.exec_()
    context.saveSettings()

    # remove ending warnings relative to QTimer
    app.deleteLater()

    return result
Пример #3
0
def main():
    # It have to be done before loading Qt
    # --help must also work without Qt
    options = parse_options()

    if options.debug:
        logging.root.setLevel(logging.DEBUG)

    # Then we can load Qt
    import silx
    from silx.gui import qt
    if options.opengl:
        silx.config.DEFAULT_PLOT_BACKEND = "opengl"

    # Make sure matplotlib is loaded first by silx
    import silx.gui.plot.matplotlib
    from pyFAI.gui.CalibrationWindow import CalibrationWindow
    from pyFAI.gui.CalibrationContext import CalibrationContext

    sys.excepthook = logUncaughtExceptions
    if options.qtargs is None:
        qtArgs = []
    else:
        qtArgs = options.qtargs.split()
    app = qt.QApplication(qtArgs)
    pyFAI.resources.silx_integration()

    settings = qt.QSettings(qt.QSettings.IniFormat, qt.QSettings.UserScope,
                            "pyfai", "pyfai-calib2", None)

    context = CalibrationContext(settings)
    context.restoreSettings()

    setup_model(context.getCalibrationModel(), options)
    window = CalibrationWindow(context)
    window.setVisible(True)
    window.setAttribute(qt.Qt.WA_DeleteOnClose, True)

    result = app.exec_()
    context.saveSettings()

    # remove ending warnings relative to QTimer
    app.deleteLater()

    return result
Пример #4
0
def main():
    # It have to be done before loading Qt
    # --help must also work without Qt
    options = parse_options()

    if options.debug:
        logging.root.setLevel(logging.DEBUG)

    # Then we can load Qt
    import silx
    from silx.gui import qt

    if options.opengl:
        silx.config.DEFAULT_PLOT_BACKEND = "opengl"

    # Make sure matplotlib is loaded first by silx
    import silx.gui.plot.matplotlib
    from pyFAI.gui.CalibrationWindow import CalibrationWindow
    from pyFAI.gui.CalibrationContext import CalibrationContext

    sys.excepthook = logUncaughtExceptions
    if options.qtargs is None:
        qtArgs = []
    else:
        qtArgs = options.qtargs.split()
    app = qt.QApplication(qtArgs)
    pyFAI.resources.silx_integration()

    settings = qt.QSettings(
        qt.QSettings.IniFormat, qt.QSettings.UserScope, "pyfai", "pyfai-calib2", None
    )

    context = CalibrationContext(settings)
    context.restoreSettings()

    setup_model(context.getCalibrationModel(), options)
    window = CalibrationWindow(context)

    # Begin modifications for bluesky_widgets

    from qtpy.QtWidgets import QDialog
    from bluesky_widgets.components.search.searches import Search
    from bluesky_widgets.qt.searches import QtSearch
    from bluesky_widgets.examples.utils.generate_msgpack_data import get_catalog
    from bluesky_widgets.examples.utils.add_search_mixin import columns

    from qtpy.QtWidgets import QAction, QHBoxLayout, QPushButton, QVBoxLayout, QWidget

    example_catalog = get_catalog()

    class SearchDialog(QDialog):
        """
        Combine the QtSearches widget with a button that processes selected Runs.
        """

        def __init__(self, model, *args, **kwargs):
            super().__init__(*args, **kwargs)
            layout = QVBoxLayout()
            self.setLayout(layout)
            self.setModal(True)
            layout.addWidget(QtSearch(model))

            accept = QPushButton("Open")
            reject = QPushButton("Cancel")
            # We'll just slip this into an existing widget --- not great form, but
            # this is just a silly example.
            accept.clicked.connect(self.accept)
            reject.clicked.connect(self.reject)
            buttons_widget = QWidget()
            buttons_layout = QHBoxLayout()
            buttons_widget.setLayout(buttons_layout)
            buttons_layout.addWidget(accept)
            buttons_layout.addWidget(reject)
            layout.addWidget(buttons_widget)

    def launch_dialog():
        model = Search(example_catalog, columns=columns)
        dialog = SearchDialog(model)

        def open_catalog():
            catalog = model.selection_as_catalog
            # TODO Extract the data from this.
            print(f"Open {len(catalog)} runs")

        dialog.accepted.connect(open_catalog)
        dialog.exec()

    menu = window.menuBar().addMenu("&Data Broker")
    launch_dialog_action = QAction("&Search")
    menu.addAction(launch_dialog_action)
    launch_dialog_action.triggered.connect(launch_dialog)
    # End modifications for bluesky_widgets

    window.setVisible(True)
    window.setAttribute(qt.Qt.WA_DeleteOnClose, True)

    result = app.exec_()
    context.saveSettings()

    # remove ending warnings relative to QTimer
    app.deleteLater()

    return result