示例#1
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.setCentralWidget(self._qt_center)
        self._qt_window.setWindowTitle(self.qt_viewer.viewer.title)
        self._qt_center.setLayout(QHBoxLayout())
        self._status_bar = self._qt_window.statusBar()

        self._add_menubar()

        self._add_file_menu()
        self._add_view_menu()
        self._add_window_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)

        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()
示例#2
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)
示例#3
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)
示例#4
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)

        # since we initialize canvas before window, we need to manually connect them again.
        if self._qt_window.windowHandle() is not None:
            self._qt_window.windowHandle().screenChanged.connect(
                self.qt_viewer.canvas._backend.screen_changed)
        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 and dockPerformance if using perfmon.
            self._debug_menu = DebugMenu(self)
            self._add_viewer_dock_widget(self.qt_viewer.dockPerformance)
        else:
            self._debug_menu = None

        if self.qt_viewer.dockRender is not None:
            self._add_viewer_dock_widget(self.qt_viewer.dockRender)

        if show:
            self.show()
示例#5
0
def main():
    # create the application
    app = QApplication(sys.argv)
    # create the main window
    window = QMainWindow()
    # display the main window
    window.show()
    # start the Qt main loop execution
    sys.exit(app.exec_())
示例#6
0
 def test_construction_creates_inprocess_console_widget(self):
     main_window = QMainWindow()
     widget = JupyterConsole(main_window)
     self.assertTrue(hasattr(widget, "console"))
     self.assertTrue(isinstance(widget.console, InProcessJupyterConsole))
     console = widget.console
     console.kernel_manager.shutdown_kernel()
     widget.console = None
     del console
示例#7
0
 def setUpClass(cls):
     cls.ws_widget = WorkspaceWidget(QMainWindow())
     mat_ws = CreateSampleWorkspace()
     table_ws = CreateEmptyTableWorkspace()
     group_ws = GroupWorkspaces([mat_ws, table_ws])
     cls.w_spaces = [mat_ws, table_ws, group_ws]
     cls.ws_names = ['MatWS', 'TableWS', 'GroupWS']
     for ws_name, ws in zip(cls.ws_names, cls.w_spaces):
         cls.ws_widget._ads.add(ws_name, ws)
示例#8
0
def start_viewer():
    matplotlib.use('Qt5Agg')
    _create_qApp()
    main_window = QMainWindow()
    viewer = Viewer()
    main_window.setCentralWidget(viewer)
    main_window.show()
    # Avoid letting main_window be garbage collected.
    viewer._main_window = main_window
    return viewer
示例#9
0
 def setUpClass(cls):
     cls.ws_widget = WorkspaceWidget(QMainWindow())
     cls.ahw_type_name = 'AlgorithmHistoryWindow'
     mat_ws = CreateWorkspace([1], [2])
     table_ws = CreateEmptyTableWorkspace()
     group_ws = GroupWorkspaces([mat_ws, table_ws])
     cls.w_spaces = [mat_ws, table_ws, group_ws]
     cls.ws_names = ['MatWS', 'TableWS', 'GroupWS']
     for ws_name, ws in zip(cls.ws_names, cls.w_spaces):
         cls.ws_widget._ads.add(ws_name, ws)
示例#10
0
def testsample():
    from spyder.utils.qthelpers import qapplication
    app = qapplication(test_time=5)
    win = QMainWindow(None)
    codewidget = MxCodeListWidget(win)
    win.setCentralWidget(codewidget)
    codewidget.setWidgetResizable(True)
    codewidget.setModel(CodeListModel(win, sampletexts))
    win.show()
    sys.exit(app.exec_())
示例#11
0
def test_add_flash_animation(qtbot):
    widget = QMainWindow()
    qtbot.addWidget(widget)
    assert widget.graphicsEffect() is None
    add_flash_animation(widget)
    assert widget.graphicsEffect() is not None
    assert hasattr(widget, "_flash_animation")
    qtbot.wait(350)
    assert widget.graphicsEffect() is None
    assert not hasattr(widget, "_flash_animation")
示例#12
0
 def setUp(self):
     self.ws_widget = WorkspaceWidget(QMainWindow())
     mat_ws = CreateSampleWorkspace()
     table_ws = CreateEmptyTableWorkspace()
     group_ws = GroupWorkspaces([mat_ws, table_ws])
     single_val_ws = CreateSingleValuedWorkspace(5, 6)
     self.w_spaces = [mat_ws, table_ws, group_ws, single_val_ws]
     self.ws_names = ['MatWS', 'TableWS', 'GroupWS', 'SingleValWS']
     for ws_name, ws in zip(self.ws_names, self.w_spaces):
         self.ws_widget._ads.add(ws_name, ws)
示例#13
0
def build_app(catalog_uri, zmq_address=None):
    catalog = Catalog(catalog_uri)

    app = QApplication([b'Bluesky Browser'])
    app.main_window = QMainWindow()
    central_widget = CentralWidget(catalog=catalog,
                                   zmq_address=zmq_address,
                                   menuBar=app.main_window.menuBar)
    app.main_window.setCentralWidget(central_widget)
    app.main_window.show()
    return app
示例#14
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
示例#15
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()
示例#16
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
示例#17
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({})
示例#18
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_())
示例#19
0
def main():
    # create the application
    app = QApplication(sys.argv)
    # create the main window
    window = QMainWindow()
    # create a label to hold our text
    label = QLabel(text="hello world!", )
    # set the label to align in the center
    label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
    # add our label to the central widget of the window
    window.setCentralWidget(label)
    # display the main window
    window.show()
    # start the Qt main loop execution
    sys.exit(app.exec_())
示例#20
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()
示例#21
0
 def create_mainwindow(self):
     """
     Create a QMainWindow instance containing this plugin
     Note: this method is currently not used
     """
     self.mainwindow = mainwindow = QMainWindow()
     mainwindow.setAttribute(Qt.WA_DeleteOnClose)
     icon = self.get_plugin_icon()
     if is_text_string(icon):
         icon = self.get_icon(icon)
     mainwindow.setWindowIcon(icon)
     mainwindow.setWindowTitle(self.get_plugin_title())
     mainwindow.setCentralWidget(self)
     self.refresh_plugin()
     return mainwindow
示例#22
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_()
示例#23
0
文件: status.py 项目: s-tazawa/crispy
def test():
    from qtpy.QtWidgets import QMainWindow
    from spyderlib.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_()
示例#24
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()
示例#25
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()
示例#26
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()
示例#27
0
def main():
    # create the application
    app = QApplication(sys.argv)
    # create the main window
    window = QMainWindow()
    # create a matplotlib widget and set the window as its parent
    mpl = QtMplWidget(window)
    # set the plot as the central widget of the window
    window.setCentralWidget(mpl)
    # add a simple line (y = x^2) to the plot
    xdata = list(range(1, 100 + 1))
    ydata = [x ** 2 for x in xdata]
    mpl.axes.plot(xdata, ydata)
    # display the main window
    window.show()
    # start the Qt main loop execution
    sys.exit(app.exec_())
示例#28
0
    def __init__(self, qt_viewer, *, show=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_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()
示例#29
0
 def __init__(self, argv):
     # call the parent (QApplication) constructor
     super().__init__(argv)
     # create the main window
     self.window = QMainWindow()
     # create a label to hold our text
     self.label = QLabel(text="Hello world!", )
     # set the label to align in the center
     self.label.setAlignment(
         QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter
     )
     # get the current font and make it a little bigger
     font = self.label.font()
     font.setPointSize(24)
     # reapply the font to the label
     self.label.setFont(font)
     # add our label to the central widget of the window
     self.window.setCentralWidget(self.label)
     # display the main window
     self.window.show()
示例#30
0
def run_test():
    # Third party imports
    from qtpy.QtWidgets import QHBoxLayout, QTableWidget, QMainWindow

    # Local imports
    from spyder.utils.qthelpers import qapplication

    app = qapplication()
    main = QMainWindow()
    widget = PluginMainWidget('test', main)
    widget.get_title = lambda x=None: 'Test title'
    widget._setup()
    layout = QHBoxLayout()
    layout.addWidget(QTableWidget())
    widget.setLayout(layout)
    widget.start_spinner()
    dock, location = widget.create_dockwidget(main)
    main.addDockWidget(location, dock)
    main.setStyleSheet(str(APP_STYLESHEET))
    main.show()
    app.exec_()