Exemple #1
0
    def __init__(self):
        QMainWindow.__init__(self)

        # -- instance attributes --
        self.setWindowTitle("Mantid Workbench")
        self.setObjectName("Mantid Workbench")

        # widgets
        self.messagedisplay = None
        self.ipythonconsole = None
        self.workspacewidget = None
        self.editor = None
        self.algorithm_selector = None
        self.plot_selector = None
        self.widgets = []

        # Widget layout map: required for use in Qt.connection
        self._layout_widget_info = None

        # Menus
        self.file_menu = None
        self.file_menu_actions = None
        self.editor_menu = None
        self.view_menu = None
        self.view_menu_actions = None
        self.interfaces_menu = None

        # Allow splash screen text to be overridden in set_splash
        self.splash = SPLASH

        # Layout
        self.setDockOptions(self.DOCKOPTIONS)

        # Project
        self.project = None
Exemple #2
0
def create_figure_window(title=''):
    """Creates a figure in a Qt window. Returns the tuple (window, mplfigure)"""
    win = QMainWindow()
    mplfig = MPLFigure()
    win.setCentralWidget(mplfig.canvas)
    win.setWindowTitle(title)
    return win, mplfig
    def __init__(self, parent=None):
        QMainWindow.__init__(self,parent)
        self.ui = load_ui(__file__, 'converter.ui', baseinstance=self)
        self.ui.InputVal.setValidator(QDoubleValidator(self.ui.InputVal))
        self.ui.totalFlightPathInput.setValidator(QDoubleValidator(self.ui.totalFlightPathInput))
        self.ui.scatteringAngleInput.setValidator(QDoubleValidator(self.ui.scatteringAngleInput))
        self.ui.convertButton.clicked.connect(self.convert)
        self.ui.helpButton.clicked.connect(self.helpClicked)
        self.ui.inputUnits.currentIndexChanged.connect(self.setInstrumentInputs)
        self.ui.outputUnits.currentIndexChanged.connect(self.setInstrumentInputs)
        self.setInstrumentInputs()

        ##defaults
        self.flightpath = -1.0
        self.Theta = -1.0
        self.output = 0.0

        #help
        self.assistant_process = QtCore.QProcess(self)
        # pylint: disable=protected-access
        import mantid
        self.mantidplot_name='TOF Converter'
        self.collection_file = os.path.join(mantid._bindir, '../docs/qthelp/MantidProject.qhc')
        version = ".".join(mantid.__version__.split(".")[:2])
        self.qt_url = 'qthelp://org.sphinx.mantidproject.' + version + '/doc/interfaces/TOF Converter.html'
        self.external_url = 'http://docs.mantidproject.org/nightly/interfaces/TOF Converter.html'

        try:
            import mantid
            #register startup
            mantid.UsageService.registerFeatureUsage("Interface","TofConverter",False)
        except ImportError:
            pass
Exemple #4
0
 def closeEvent(self, event):
     """Reimplement Qt method."""
     self.plugin.dockwidget.setWidget(self.plugin)
     self.plugin.dockwidget.setVisible(True)
     self.plugin.undock_action.setDisabled(False)
     self.plugin.switch_to_plugin()
     QMainWindow.closeEvent(self, event)
def create_window():
    # Create app and widgets
    app = QApplication(sys.argv)
    win = QMainWindow()
    main_area = QWidget()
    button_area = QWidget()
    scroll_area = QScrollArea()
    button = QPushButton("Start Video")
    btn_grab = QPushButton("Grab Frame")

    # Create layouts
    vbox = QVBoxLayout()
    hbox = QHBoxLayout()

    # Fill Layouts
    vbox.addWidget(scroll_area)
    vbox.addWidget(button_area)
    hbox.addStretch()
    hbox.addWidget(button)
    hbox.addWidget(btn_grab)

    # Assign layouts to widgets
    main_area.setLayout(vbox)
    button_area.setLayout(hbox)
    scroll_area.setLayout(QVBoxLayout())

    # Attach some child widgets directly
    win.setCentralWidget(main_area)

    return app, win, button, btn_grab, scroll_area
Exemple #6
0
 def __init__(self, *args, **kwargs):
     ui_module = MyWidgetUI
     try: self.ui = ui_module.Ui_Form()  #enable autocomplete
     except: pass
     QMainWindow.__init__(self, *args, **kwargs)
     self.widget = QtWidgetLoader(ui_module=ui_module, parent=self, action_receiver=self)
     self.widget.ui.lineEdit.setText("MyWidget")
     self.show()
    def __init__(self, parent=None):
        self.parent = parent

        QMainWindow.__init__(self, parent=parent)
        self.ui = load_ui('jobStatus.ui', baseinstance=self)

        self.init_table()
        self.launch_table_update_thread()
    def __init__(self, parent=None):
        self.parent = parent

        QMainWindow.__init__(self, parent=parent)
        self.ui = load_ui('advanced_window.ui', baseinstance=self)

        self.setWindowTitle("Advanced Window for Super User Only !")
        self.init_widgets()
    def __init__(self, main_window=None, key=None):
        self.main_window = main_window
        self.key = key

        QMainWindow.__init__(self, parent=main_window)
        self.ui = load_ui('manual_key_value_input.ui', baseinstance=self)

        self.init_widgets()
 def __init__(self):
     QMainWindow.__init__(self)
     self.mplwidget = MatplotlibWidget(self, title='Example',
                                       xlabel='Linear scale',
                                       ylabel='Log scale',
                                       hold=True, yscale='log')
     self.mplwidget.setFocus()
     self.setCentralWidget(self.mplwidget)
     self.plot(self.mplwidget.axes)
    def __init__(self, parent=None, key=None, data_type='sample'):
        self.parent = parent
        self.key = key
        self.data_type = data_type

        QMainWindow.__init__(self, parent=parent)
        self.ui = load_ui('mass_density.ui', baseinstance=self)
        self.init_widgets()
        self.set_column_index()
Exemple #12
0
    def __init__(self, canvas, parent=None):
        QMainWindow.__init__(self, parent=parent)
        # attributes
        self._canvas = weakref.proxy(canvas)
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setWindowIcon(QIcon(':/images/MantidIcon.ico'))

        self.close_signal.connect(self._run_close)
        self.setAcceptDrops(True)
Exemple #13
0
    def __init__(self, parent=None, button_name=''):
        QMainWindow.__init__(self, parent)
        self.parent = parent
        self.button_name = button_name

        self.ui = load_ui('helpGui.ui', baseinstance=self)

        self.init_global_gui()
        self.init_table()
Exemple #14
0
    def __init__(self, parent=None, key=None, data_type='sample'):
        self.parent = parent
        self.data_type = data_type
        self.key = key

        QMainWindow.__init__(self, parent=parent)
        self.ui = load_ui('placzek.ui', baseinstance=self)

        self.init_widgets()
        self.set_column()
    def __init__(self, parent=None, text=None, filename=None):
        self.parent = parent

        QMainWindow.__init__(self, parent=parent)
        self.ui = load_ui('preview_ascii.ui', baseinstance=self)

        _title = filename
        self.setWindowTitle(_title)

        self.ui.preview_ascii_text_edit.setText(text)
    def dropEvent(self, event):
        """
        If the event data contains a workspace reference then
        request a plot of the workspace.

        :param event: A QDropEvent containing the MIME
                      data of the action
        """
        self._plot_on_here(event.mimeData().text().split('\n'))
        QMainWindow.dropEvent(self, event)
Exemple #17
0
    def __init__(self, parent=None, json_conflicts={}):
        self.parent = parent
        self.json_conflicts = json_conflicts

        QMainWindow.__init__(self, parent=parent)
        self.ui = load_ui('solve_import_conflicts.ui', baseinstance=self)
        #self.ui = UiMainWindow()
        #self.ui.setupUi(self)

        self.init_widgets()
Exemple #18
0
    def dropEvent(self, event):
        """
        If the event data contains a workspace reference then
        request a plot of the workspace.

        :param event: A QDropEvent containing the MIME
                      data of the action
        """
        self._plot_on_here(event.mimeData().text().split('\n'))
        QMainWindow.dropEvent(self, event)
Exemple #19
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.setWindowIcon(get_icon("python.png"))
        self.setWindowTitle("Application example")

        # Instantiate dataset-related widgets:
        self.groupbox1 = DataSetShowGroupBox("Activable dataset",
                                             ExampleDataSet,
                                             comment="")
        self.groupbox2 = DataSetShowGroupBox("Standard dataset",
                                             AnotherDataSet,
                                             comment="")
        self.groupbox3 = DataSetEditGroupBox("Standard dataset",
                                             OtherDataSet,
                                             comment="")
        self.groupbox4 = DataSetEditGroupBox("Standard dataset",
                                             ExampleMultiGroupDataSet,
                                             comment="")
        self.groupbox3.SIG_APPLY_BUTTON_CLICKED.connect(self.update_window)
        self.update_groupboxes()

        splitter = QSplitter(self)
        splitter.addWidget(self.groupbox1)
        splitter.addWidget(self.groupbox2)
        splitter.addWidget(self.groupbox3)
        splitter.addWidget(self.groupbox4)
        self.setCentralWidget(splitter)
        self.setContentsMargins(10, 5, 10, 5)

        # File menu
        file_menu = self.menuBar().addMenu("File")
        quit_action = create_action(
            self,
            "Quit",
            shortcut="Ctrl+Q",
            icon=get_std_icon("DialogCloseButton"),
            tip="Quit application",
            triggered=self.close,
        )
        add_actions(file_menu, (quit_action, ))

        # Edit menu
        edit_menu = self.menuBar().addMenu("Edit")
        editparam1_action = create_action(self,
                                          "Edit dataset 1",
                                          triggered=self.edit_dataset1)
        editparam2_action = create_action(self,
                                          "Edit dataset 2",
                                          triggered=self.edit_dataset2)
        editparam4_action = create_action(self,
                                          "Edit dataset 4",
                                          triggered=self.edit_dataset4)
        add_actions(edit_menu,
                    (editparam1_action, editparam2_action, editparam4_action))
Exemple #20
0
    def __init__(self):
        QMainWindow.__init__(self)
        self.setWindowTitle("Signal filtering 2 (guiqwt)")
        self.setWindowIcon(get_icon("guiqwt.svg"))

        hlayout = QHBoxLayout()
        central_widget = QWidget(self)
        central_widget.setLayout(hlayout)
        self.setCentralWidget(central_widget)
        # ---guiqwt plot manager
        self.manager = PlotManager(self)
Exemple #21
0
    def __init__(self, qt_viewer: QtViewer, *, show: bool = True):

        self.qt_viewer = qt_viewer

        self._qt_window = QMainWindow()
        self._qt_window.setAttribute(Qt.WA_DeleteOnClose)
        self._qt_window.setUnifiedTitleAndToolBarOnMac(True)
        self._qt_center = QWidget(self._qt_window)

        self._qt_window.setCentralWidget(self._qt_center)
        self._qt_window.setWindowTitle(self.qt_viewer.viewer.title)
        self._qt_center.setLayout(QHBoxLayout())
        self._status_bar = QStatusBar()
        self._qt_window.setStatusBar(self._status_bar)

        self._add_menubar()

        self._add_file_menu()
        self._add_view_menu()
        self._add_window_menu()
        self._add_plugins_menu()
        self._add_help_menu()

        self._status_bar.showMessage('Ready')
        self._help = QLabel('')
        self._status_bar.addPermanentWidget(self._help)

        self._qt_center.layout().addWidget(self.qt_viewer)
        self._qt_center.layout().setContentsMargins(4, 0, 4, 0)

        self._update_palette()

        self._add_viewer_dock_widget(self.qt_viewer.dockConsole)
        self._add_viewer_dock_widget(self.qt_viewer.dockLayerControls)
        self._add_viewer_dock_widget(self.qt_viewer.dockLayerList)

        self.qt_viewer.viewer.events.status.connect(self._status_changed)
        self.qt_viewer.viewer.events.help.connect(self._help_changed)
        self.qt_viewer.viewer.events.title.connect(self._title_changed)
        self.qt_viewer.viewer.events.palette.connect(self._update_palette)

        if perf.USE_PERFMON:
            # Add DebugMenu if using perfmon. The DebugMenu is intended to
            # contain non-perfmon stuff as well. When it does we will want
            # a separate env variable for it.
            self._debug_menu = DebugMenu(self)

            # The QtPerformance widget only exists if we are using perfmon.
            self._add_viewer_dock_widget(self.qt_viewer.dockPerformance)
        else:
            self._debug_menu = None

        if show:
            self.show()
    def __init__(self, parent=None, text=None, filename=None):
        self.parent = parent

        QMainWindow.__init__(self, parent=parent)
        self.ui = UiMainWindow()
        self.ui.setupUi(self)

        _title = filename
        self.setWindowTitle(_title)

        self.ui.preview_ascii_text_edit.setText(text)
    def __init__(self, parent=None, next_ui='from_database_ui', next_function=None):
        QMainWindow.__init__(self, parent=parent)
        self.parent = parent
        self.next_ui = next_ui
        self.next_function = next_function

        self.ui = load_ui('oncat_authentication.ui', baseinstance=self)

        self.center()
        self.init_widgets()
        self.ui.password.setFocus()
Exemple #24
0
    def __init__(self, config_file, storage_client, parent):
        QMainWindow.__init__(self, parent)

        if storage_client:
            self._api = storage_client
        else:
            self._api = PlotApi(ERT.enkf_facade)

        self.setMinimumWidth(850)
        self.setMinimumHeight(650)

        self.setWindowTitle("Plotting - {}".format(config_file))
        self.activateWindow()
        self._key_definitions = self._api.all_data_type_keys()
        self._plot_customizer = PlotCustomizer(self, self._key_definitions)

        self._plot_customizer.settingsChanged.connect(self.keySelected)

        self._central_tab = QTabWidget()

        central_widget = QWidget()
        central_layout = QVBoxLayout()
        central_layout.setContentsMargins(0, 0, 0, 0)
        central_widget.setLayout(central_layout)

        central_layout.addWidget(self._central_tab)

        self.setCentralWidget(central_widget)

        self._plot_widgets = []
        """:type: list of PlotWidget"""

        self.addPlotWidget(ENSEMBLE, EnsemblePlot())
        self.addPlotWidget(STATISTICS, StatisticsPlot())
        self.addPlotWidget(HISTOGRAM, HistogramPlot())
        self.addPlotWidget(GAUSSIAN_KDE, GaussianKDEPlot())
        self.addPlotWidget(DISTRIBUTION, DistributionPlot())
        self.addPlotWidget(CROSS_CASE_STATISTICS, CrossCaseStatisticsPlot())

        self._central_tab.currentChanged.connect(self.currentPlotChanged)

        cases = self._api.get_all_cases_not_running()
        case_names = [case["name"] for case in cases if not case["hidden"]]

        self._data_type_keys_widget = DataTypeKeysWidget(self._key_definitions)
        self._data_type_keys_widget.dataTypeKeySelected.connect(self.keySelected)
        self.addDock("Data types", self._data_type_keys_widget)
        self._case_selection_widget = CaseSelectionWidget(case_names)
        self._case_selection_widget.caseSelectionChanged.connect(self.keySelected)
        self.addDock("Plot case", self._case_selection_widget)

        current_plot_widget = self._plot_widgets[self._central_tab.currentIndex()]
        self._data_type_keys_widget.selectDefault()
        self._updateCustomizer(current_plot_widget)
Exemple #25
0
    def test_move_to_error_wrong_params(self, qtbot):
        window = QMainWindow()
        qtbot.addWidget(window)
        widget = QWidget()
        window.setCentralWidget(widget)
        popup = QtPopup(widget)
        with pytest.raises(ValueError):
            popup.move_to("dummy_text")

        with pytest.raises(ValueError):
            popup.move_to({})
Exemple #26
0
def launch_suite(suite):
    """Creates a main window and execs the application."""
    window = QMainWindow()
    window.setCentralWidget(suite)
    window.setWindowTitle(suite.windowTitle())
    window.setUnifiedTitleAndToolBarOnMac(True)
    window.show()
    logger.info("Launching application ...")
    get_qapp().exec_()
    logger.info("Execution complete!")
    return window
Exemple #27
0
def pixel_ratio():
    """Get the pixel ratio."""
    from mne.viz.backends.tests._utils import has_pyvista
    if not has_pyvista() or not _check_qt_version():
        return 1.
    from qtpy.QtWidgets import QApplication, QMainWindow
    _ = QApplication.instance() or QApplication([])
    window = QMainWindow()
    ratio = float(window.devicePixelRatio())
    window.close()
    return ratio
Exemple #28
0
    def __init__(self, canvas, parent=None, window_flags=None):
        if window_flags is not None:
            QMainWindow.__init__(self, parent, window_flags)
        else:
            QMainWindow.__init__(self, parent)
        # attributes
        self._canvas = weakref.proxy(canvas)
        self.setAttribute(Qt.WA_DeleteOnClose, True)
        self.setWindowIcon(QIcon(':/images/MantidIcon.ico'))

        self.close_signal.connect(self._run_close)
        self.setAcceptDrops(True)
Exemple #29
0
 def __init__(
     self,
     parent: Optional[QWidget] = None,
     title: Optional[str] = None,
     size: Optional[Tuple[int, int]] = None,
 ) -> None:
     """Initialize the main window."""
     QMainWindow.__init__(self, parent=parent)
     if title is not None:
         self.setWindowTitle(title)
     if size is not None:
         self.resize(*size)
Exemple #30
0
 def closeEvent(self, event):
     """Reimplement Qt method."""
     self.plugin.set_ancestor(self.plugin.main)
     self.plugin.dockwidget.setWidget(self.plugin)
     self.plugin.dockwidget.setVisible(True)
     self.plugin.switch_to_plugin()
     QMainWindow.closeEvent(self, event)
     # Qt might want to do something with this soon,
     # So it should not be deleted by python yet.
     # Fixes spyder-ide/spyder#10704
     self.plugin.__unsafe__window = self
     self.plugin._undocked_window = None
Exemple #31
0
def status_bar(qtbot):
    """Set up StatusBarWidget."""
    win = QMainWindow()
    win.setWindowTitle("Status widgets test")
    win.resize(900, 300)
    statusbar = win.statusBar()
    win.show()
    qtbot.addWidget(win)
    return (win, statusbar)
Exemple #32
0
    def __init__(self, arr, mgr):
        QMainWindow.__init__(self)
        self.setWindowTitle('skimage')
        self.mgr = mgr
        self.main_widget = QWidget()
        self.layout = QGridLayout(self.main_widget)
        self.setCentralWidget(self.main_widget)

        self.label = ImageLabel(self, arr)
        self.layout.addWidget(self.label, 0, 0)
        self.layout.addLayout
        self.mgr.add_window(self)
        self.main_widget.show()
Exemple #33
0
def main():
    # create the application
    app = QApplication(sys.argv)
    # create the main window
    window = QMainWindow()
    # setup the UI
    setup_ui(window)
    # wire signals to slots
    connect_signals_to_slots(window)
    # show the window
    window.show()
    # start the Qt main loop execution
    sys.exit(app.exec_())
Exemple #34
0
    def __init__(self, arr, mgr):
        QMainWindow.__init__(self)
        self.setWindowTitle('skimage')
        self.mgr = mgr
        self.main_widget = QWidget()
        self.layout = QGridLayout(self.main_widget)
        self.setCentralWidget(self.main_widget)

        self.label = ImageLabel(self, arr)
        self.layout.addWidget(self.label, 0, 0)
        self.layout.addLayout
        self.mgr.add_window(self)
        self.main_widget.show()
Exemple #35
0
    def __init__(self):
        QMainWindow.__init__(self)

        self.setState(self.stateInit)
        self.setState(self.stateIdle)

        self._timerPlotUpdate = QTimer()
        self._timerPlotUpdate.timeout.connect(self.on_timerPlotUpdate_expired)

        self._enabled = False

        # TODO: should be done asynchronously!
        self.loadServos()
Exemple #36
0
    def __init__(self, arr, mgr):
        QMainWindow.__init__(self)

        self.arr = arr

        self.mgr = mgr
        self.main_widget = QWidget()
        self.layout = QGridLayout(self.main_widget)
        self.setCentralWidget(self.main_widget)

        self.label = ImageLabel(self, arr)
        self.label_container = QFrame()
        self.label_container.setFrameShape(QFrame.StyledPanel | QFrame.Sunken)
        self.label_container.setLineWidth(1)

        self.label_container.layout = QGridLayout(self.label_container)
        self.label_container.layout.setContentsMargins(0, 0, 0, 0)
        self.label_container.layout.addWidget(self.label, 0, 0)
        self.layout.addWidget(self.label_container, 0, 0)

        self.mgr.add_window(self)
        self.main_widget.show()

        self.setWindowTitle('Skivi - The skimage viewer.')

        self.mixer_panel = MixerPanel(self.arr)
        self.layout.addWidget(self.mixer_panel, 0, 2)
        self.mixer_panel.show()
        self.mixer_panel.set_callback(self.refresh_image)

        self.rgbv_hist = QuadHistogram(self.arr)
        self.layout.addWidget(self.rgbv_hist, 0, 1)
        self.rgbv_hist.show()

        self.rgb_hsv_disp = RGBHSVDisplay()
        self.layout.addWidget(self.rgb_hsv_disp, 1, 0)
        self.rgb_hsv_disp.show()

        self.layout.setColumnStretch(0, 1)
        self.layout.setRowStretch(0, 1)

        self.save_file = QtWidgets.QPushButton('Save to File')
        self.save_file.clicked.connect(self.save_to_file)
        self.save_stack = QtWidgets.QPushButton('Save to Stack')
        self.save_stack.clicked.connect(self.save_to_stack)
        self.save_file.show()
        self.save_stack.show()

        self.layout.addWidget(self.save_stack, 1, 1)
        self.layout.addWidget(self.save_file, 1, 2)
Exemple #37
0
    def __init__(self, arr, mgr):
        QMainWindow.__init__(self)

        self.arr = arr

        self.mgr = mgr
        self.main_widget = QWidget()
        self.layout = QGridLayout(self.main_widget)
        self.setCentralWidget(self.main_widget)

        self.label = ImageLabel(self, arr)
        self.label_container = QFrame()
        self.label_container.setFrameShape(QFrame.StyledPanel | QFrame.Sunken)
        self.label_container.setLineWidth(1)

        self.label_container.layout = QGridLayout(self.label_container)
        self.label_container.layout.setContentsMargins(0, 0, 0, 0)
        self.label_container.layout.addWidget(self.label, 0, 0)
        self.layout.addWidget(self.label_container, 0, 0)

        self.mgr.add_window(self)
        self.main_widget.show()

        self.setWindowTitle('Skivi - The skimage viewer.')

        self.mixer_panel = MixerPanel(self.arr)
        self.layout.addWidget(self.mixer_panel, 0, 2)
        self.mixer_panel.show()
        self.mixer_panel.set_callback(self.refresh_image)

        self.rgbv_hist = QuadHistogram(self.arr)
        self.layout.addWidget(self.rgbv_hist, 0, 1)
        self.rgbv_hist.show()

        self.rgb_hsv_disp = RGBHSVDisplay()
        self.layout.addWidget(self.rgb_hsv_disp, 1, 0)
        self.rgb_hsv_disp.show()

        self.layout.setColumnStretch(0, 1)
        self.layout.setRowStretch(0, 1)

        self.save_file = QtWidgets.QPushButton('Save to File')
        self.save_file.clicked.connect(self.save_to_file)
        self.save_stack = QtWidgets.QPushButton('Save to Stack')
        self.save_stack.clicked.connect(self.save_to_stack)
        self.save_file.show()
        self.save_stack.show()

        self.layout.addWidget(self.save_stack, 1, 1)
        self.layout.addWidget(self.save_file, 1, 2)
Exemple #38
0
    def __init__(self, config_file, parent):
        QMainWindow.__init__(self, parent)

        self.resize(900, 900)

        self.__position = None
        self.__geometry = None

        self.__configuration_panel = ConfigurationPanel(config_file)
        self.__configuration_panel.reloadApplication.connect(
            self.reloadTriggered)
        self.setCentralWidget(self.__configuration_panel)
        self.setWindowTitle("Configuration - {}".format(config_file))
        self.activateWindow()
Exemple #39
0
    def __init__(self, parent=None, database_window=None, key=None, data_type='sample'):

        self.parent = parent
        self.database_window = database_window
        self.key = key
        self.data_type = data_type

        QMainWindow.__init__(self, parent=parent)
        self.ui = load_ui('periodic_table.ui', baseinstance=self)
        self.setWindowTitle("Define Chemical Formula")

        self.init_ui_color_dictionary()
        self.init_widgets()
        self.set_column_index()
Exemple #40
0
def run_widget(queue, window_type, name, topic, addr):

    app = QApplication(sys.argv)
    loop = asyncqt.QEventLoop(app)
    asyncio.set_event_loop(loop)
    win = QMainWindow()

    if window_type == 'AreaDetector':
        widget = AreaDetWidget(name, topic, addr, win)

    elif window_type == 'WaveformDetector':
        widget = WaveformWidget(name, topic, addr, win)

    elif window_type == 'HistogramDetector':
        widget = HistogramWidget(name, topic, addr, win)

    elif window_type == 'ScalarDetector':
        widget = ScalarWidget(name, topic, addr, win)

    else:
        raise ValueError('%s not valid window_type' % window_type)

    win.setCentralWidget(widget)
    win.setWindowTitle(name)
    win.show()

    return app.exec_()
Exemple #41
0
    def __init__(self,
                 parent=None,
                 next_ui='from_database_ui',
                 next_function=None):
        QMainWindow.__init__(self, parent=parent)
        self.parent = parent
        self.next_ui = next_ui
        self.next_function = next_function

        self.ui = load_ui('oncat_authentication.ui', baseinstance=self)

        self.center()
        self.init_widgets()
        self.ui.password.setFocus()
Exemple #42
0
    def __init__(self):
        QMainWindow.__init__(self)

        # -- instance attributes --
        self.setWindowTitle(MAIN_WINDOW_TITLE)
        self.setObjectName(MAIN_WINDOW_OBJECT_NAME)

        # widgets
        self.memorywidget = None
        self.messagedisplay = None
        self.ipythonconsole = None
        self.workspacewidget = None
        self.workspacecalculator = None
        self.editor = None
        self.algorithm_selector = None
        self.plot_selector = None
        self.interface_manager = None
        self.script_repository = None
        self.widgets = []

        # Widget layout map: required for use in Qt.connection
        self._layout_widget_info = None

        # Menus
        self.file_menu = None
        self.file_menu_actions = None
        self.view_menu = None
        self.view_menu_actions = None
        self.view_menu_layouts = None
        self.interfaces_menu = None
        self.help_menu = None
        self.help_menu_actions = None

        # Allow splash screen text to be overridden in set_splash
        self.splash = SPLASH

        # Layout
        self.setDockOptions(self.DOCKOPTIONS)

        # Project
        self.project = None
        self.project_recovery = None

        # Interfaces
        self.interface_manager = None
        self.interface_executor = None
        self.interface_list = None

        self.could_restore_state = False
Exemple #43
0
 def __init__(self, argv):
     # call the parent (QApplication) constructor
     super().__init__(argv)
     # create the main window
     self.window = QMainWindow()
     # create a matplotlib widget and set the window as its parent
     self.mpl = QtMplWidget(self.window)
     # add our label to the central widget of the window
     self.window.setCentralWidget(self.mpl)
     # add a simple line (y = x^2) to the plot
     xdata = list(range(1, 100 + 1))
     ydata = [x**2 for x in xdata]
     self.mpl.axes.plot(xdata, ydata)
     # display the main window
     self.window.show()
Exemple #44
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        widget = QWidget(self)
        self.editor = QTextEdit()
        self.editor.setPlainText("0123456789" * 100)
        layout = QGridLayout(widget)
        layout.addWidget(self.editor, 0, 0, 1, 3)
        self.button = QPushButton("Wait")
        layout.addWidget(self.button, 1, 1, 1, 1)

        self.setCentralWidget(widget)
        self.overlay = BusyOverlay(self.centralWidget())
        self.overlay.hide()
        self.button.clicked.connect(self.overlay.show)
Exemple #45
0
 def closeEvent(self, *args, **kwargs):
     self.save_settings()
     # Enable paste of clipboard after termination
     clipboard = QApplication.clipboard()
     event = QEvent(QEvent.Clipboard)
     QApplication.sendEvent(clipboard, event)
     return QMainWindow.closeEvent(self, *args, **kwargs)
Exemple #46
0
 def test_tab_session_restore(self):
     editor = MultiFileEditor(QMainWindow())
     prev_session_tabs = [
         os.path.join(os.path.dirname(__file__), '__init__.py'),
         __file__]
     editor.restore_session_tabs(prev_session_tabs)
     self.assertEqual(2, editor.editors.editor_count)
Exemple #47
0
def build_app(catalog_uri, zmq_address=None):
    from intake import Catalog
    catalog = Catalog(catalog_uri)

    # TODO Make search_result_row configurable.

    def search_result_row(entry):
        start = entry.metadata['start']
        stop = entry.metadata['stop']
        start_time = datetime.fromtimestamp(start['time'])
        duration = datetime.fromtimestamp(stop['time']) - start_time
        str_duration = str(duration)
        return {'Unique ID': start['uid'][:8],
                'Transient Scan ID': str(start.get('scan_id', '-')),
                'Plan Name': start.get('plan_name', '-'),
                'Start Time': start_time.strftime('%Y-%m-%d %H:%M:%S'),
                'Duration': str_duration[:str_duration.index('.')],
                'Exit Status': '-' if stop is None else stop['exit_status']}

    app = QApplication([b'Bluesky Browser'])
    app.main_window = QMainWindow()
    central_widget = CentralWidget(
        catalog=catalog,
        zmq_address=zmq_address,
        search_result_row=search_result_row,
        menuBar=app.main_window.menuBar)
    app.main_window.setCentralWidget(central_widget)
    app.main_window.show()
    return app
Exemple #48
0
    def closeEvent(self, event):
        """ """
        if self.packages.busy:
            answer = QMessageBox.question(
                self,
                'Quit Conda Manager?',
                'Conda is still busy.\n\nDo you want to quit?',
                buttons=QMessageBox.Yes | QMessageBox.No)

            if answer == QMessageBox.Yes:
                QMainWindow.closeEvent(self, event)
                # Do some cleanup?
            else:
                event.ignore()
        else:
            QMainWindow.closeEvent(self, event)
Exemple #49
0
def test_exit_before_thread(qtbot):
    from xicam.core import threads
    import time
    from qtpy.QtWidgets import QMainWindow

    window = QMainWindow()

    def long_thread():
        time.sleep(100000)

    for i in range(1000):
        t = threads.QThreadFuture(long_thread)

        t.start()
    time.sleep(.01)

    window.deleteLater()
Exemple #50
0
def test_qthreads_and_pythreads(qtbot):
    from xicam.core import threads
    import time
    from qtpy.QtWidgets import QMainWindow

    window = QMainWindow()

    @threads.method()
    def long_thread():
        time.sleep(100000)

    for i in range(1000):
        long_thread()

    time.sleep(.01)

    window.deleteLater()
Exemple #51
0
    def setup_figure(self):
        self.figure = Figure()
        self.figure.canvas = FigureCanvas(self.figure)
        self.figure.canvas.mpl_connect('button_press_event', self.mouse_click)
        self.figure.add_subplot(111, projection="mantid")
        self.toolbar = FittingPlotToolbar(self.figure.canvas, self, False)
        self.toolbar.setMovable(False)

        self.dock_window = QMainWindow(self.group_plot)
        self.dock_window.setWindowFlags(Qt.Widget)
        self.dock_window.setDockOptions(QMainWindow.AnimatedDocks)
        self.dock_window.setCentralWidget(self.toolbar)
        self.plot_dock = QDockWidget()
        self.plot_dock.setWidget(self.figure.canvas)
        self.plot_dock.setFeatures(QDockWidget.DockWidgetFloatable
                                   | QDockWidget.DockWidgetMovable)
        self.plot_dock.setAllowedAreas(Qt.BottomDockWidgetArea)
        self.plot_dock.setWindowTitle("Fit Plot")
        self.plot_dock.topLevelChanged.connect(self.make_undocked_plot_larger)
        self.initial_chart_width, self.initial_chart_height = self.plot_dock.width(
        ), self.plot_dock.height()
        self.plot_dock.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding,
                        QSizePolicy.MinimumExpanding))
        self.dock_window.addDockWidget(Qt.BottomDockWidgetArea, self.plot_dock)
        self.vLayout_plot.addWidget(self.dock_window)

        self.fit_browser = EngDiffFitPropertyBrowser(
            self.figure.canvas, ToolbarStateManager(self.toolbar))
        # remove SequentialFit from fit menu (implemented a different way)
        qmenu = self.fit_browser.getFitMenu()
        qmenu.removeAction([
            qact for qact in qmenu.actions() if qact.text() == "Sequential Fit"
        ][0])
        # hide unnecessary properties of browser
        hide_props = [
            'Minimizer', 'Cost function', 'Max Iterations', 'Output',
            'Ignore invalid data', 'Peak Radius', 'Plot Composite Members',
            'Convolve Composite Members', 'Show Parameter Errors',
            'Evaluate Function As'
        ]
        self.fit_browser.removePropertiesFromSettingsBrowser(hide_props)
        self.fit_browser.toggleWsListVisible()
        self.fit_browser.closing.connect(self.toolbar.handle_fit_browser_close)
        self.vLayout_fitprop.addWidget(self.fit_browser)
        self.fit_browser.hide()
Exemple #52
0
    def __init__(self, qt_viewer, *, show=True):

        self.qt_viewer = qt_viewer

        self._qt_window = QMainWindow()
        self._qt_window.setUnifiedTitleAndToolBarOnMac(True)
        self._qt_center = QWidget(self._qt_window)

        self._qt_window.setCentralWidget(self._qt_center)
        self._qt_window.setWindowTitle(self.qt_viewer.viewer.title)
        self._qt_center.setLayout(QHBoxLayout())
        self._status_bar = QStatusBar()
        self._qt_window.setStatusBar(self._status_bar)
        self._qt_window.closeEvent = self.closeEvent
        self.close = self._qt_window.close

        self._add_menubar()

        self._add_file_menu()
        self._add_view_menu()
        self._add_window_menu()
        self._add_help_menu()

        self._status_bar.showMessage('Ready')
        self._help = QLabel('')
        self._status_bar.addPermanentWidget(self._help)

        self._qt_center.layout().addWidget(self.qt_viewer)
        self._qt_center.layout().setContentsMargins(4, 0, 4, 0)

        self._update_palette(qt_viewer.viewer.palette)

        if self.qt_viewer.console.shell is not None:
            self._add_viewer_dock_widget(self.qt_viewer.dockConsole)

        self._add_viewer_dock_widget(self.qt_viewer.dockLayerControls)
        self._add_viewer_dock_widget(self.qt_viewer.dockLayerList)

        self.qt_viewer.viewer.events.status.connect(self._status_changed)
        self.qt_viewer.viewer.events.help.connect(self._help_changed)
        self.qt_viewer.viewer.events.title.connect(self._title_changed)
        self.qt_viewer.viewer.events.palette.connect(
            lambda event: self._update_palette(event.palette))

        if show:
            self.show()
Exemple #53
0
def test(nr):
    if nr == 1:
        MyMainWindow().start()
    elif nr == 2:
        MyDialog(None, True).start()
    elif nr == 3:
        app = QApplication(sys.argv)
        w = WidgetWindow()
        print (w)
        app.exec_()
    if nr == 4:
        app = QApplication(sys.argv)
        window = QMainWindow()
        w = MyWidget(window)
        print (w)
        window.show()
        app.exec_()
    if nr == 5:
        MyMainWindowWithMenu().start()
    if nr == 6:
        MyCombinationWindow().start()
Exemple #54
0
    def __init__(self, parent=None):
        """
        Initialization
        :param parent:
        :return:
        """
        # Init
        QMainWindow.__init__(self, parent)

        ui_path ="View3DWidget.ui"
        self.ui = load_ui(__file__, ui_path, baseinstance=self)
        self._promote_widgets()

        # Initialize widgets
        self.ui.lineEdit_baseColorRed.setText('0.5')
        self.ui.lineEdit_baseColorGreen.setText('0.5')
        self.ui.lineEdit_baseColorBlue.setText('0.5')
        self.ui.lineEdit_countsThresholdLower.setText('0')
        self.ui.comboBox_scans.addItem('unclassified')

        # Event handling
        self.ui.pushButton_plot3D.clicked.connect(self.do_plot_3d)
        self.ui.pushButton_checkCounts.clicked.connect(self.do_check_counts)
        self.ui.pushButton_clearPlots.clicked.connect(self.do_clear_plots)
        self.ui.pushButton_quit.clicked.connect(self.do_quit)
        self.ui.comboBox_scans.currentIndexChanged.connect(self.evt_change_scan)

        # Set up
        # list of data keys for management
        self._dataKeyList = list()

        # dictionary for 3D data
        self._mergedDataDict = dict()

        # dictionary for group control, key = str(scan), value = list of data keys
        self._groupDict = dict()
        self._currSessionName = 'unclassified'
        self._groupDict['unclassified'] = []

        return
Exemple #55
0
    def __init__(self, *args, **kwargs):
        QMainWindow.__init__(self, *args, **kwargs)
        QtGuiApplication.__init__(self, self)
        QtUI.__init__(self, self)


        self.menubar = self.menuBar()
        self.fileMenu = self.menubar.addMenu('&File')
        openAction = QAction(QIcon('open.png'), '&Open...', self)
        openAction.setShortcut('Ctrl+O')
        openAction.setStatusTip('Open...')
        openAction.triggered.connect(self.actionOpen)
        exitAction = QAction("&Exit", self, shortcut='Ctrl+Q', statusTip='Exit', triggered=app.exit)
        self.fileMenu.addAction(openAction)
        self.fileMenu.addSeparator()
        sep = self.fileMenu.addSeparator()

        self.fileMenu.addAction(exitAction)

        self.recentInMenu = RecentInMenu(self, self.fileMenu, self.open, sep)

        self.show()
Exemple #56
0
def test():
    from qtpy.QtWidgets import QMainWindow
    from spyder.utils.qthelpers import qapplication

    app = qapplication(test_time=5)
    win = QMainWindow()
    win.setWindowTitle("Status widgets test")
    win.resize(900, 300)
    statusbar = win.statusBar()
    status_widgets = []
    for status_class in (MemoryStatus, CPUStatus):
        status_widget = status_class(win, statusbar)
        status_widgets.append(status_widget)
    win.show()
    app.exec_()
Exemple #57
0
def status_bar(qtbot):
    """Set up StatusBarWidget."""
    win = QMainWindow()
    win.setWindowTitle("Status widgets test")
    win.resize(900, 300)
    statusbar = win.statusBar()
    qtbot.addWidget(win)
    return (win, statusbar)
Exemple #58
0
def test():
    from qtpy.QtWidgets import QMainWindow
    from spyder.utils.qthelpers import qapplication

    app = qapplication(test_time=5)
    win = QMainWindow()
    win.setWindowTitle("Status widgets test")
    win.resize(900, 300)
    statusbar = win.statusBar()
    swidgets = []
    for klass in (ReadWriteStatus, EOLStatus, EncodingStatus,
                  CursorPositionStatus, MemoryStatus, CPUStatus):
        swidget = klass(win, statusbar)
        swidgets.append(swidget)
    win.show()
    app.exec_()
Exemple #59
0
    def __init__(self):
        QMainWindow.__init__(self)

        qapp = QApplication.instance()
        qapp.setAttribute(Qt.AA_UseHighDpiPixmaps)
        if hasattr(Qt, 'AA_EnableHighDpiScaling'):
            qapp.setAttribute(Qt.AA_EnableHighDpiScaling, True)

        self.setWindowTitle("Mantid Workbench")

        # -- instance attributes --
        self.window_size = None
        self.window_position = None
        self.maximized_flag = None
        # widgets
        self.messagedisplay = None
        self.ipythonconsole = None
        self.workspacewidget = None
        self.editor = None
        self.algorithm_selector = None
        self.widgets = []

        # Widget layout map: required for use in Qt.connection
        self._layout_widget_info = None

        # Menus
        self.file_menu = None
        self.file_menu_actions = None
        self.editor_menu = None
        self.view_menu = None
        self.view_menu_actions = None

        # Allow splash screen text to be overridden in set_splash
        self.splash = SPLASH

        # Layout
        self.setDockOptions(self.DOCKOPTIONS)