Exemplo n.º 1
0
    def __init__(self, text='', clearable = True, parent=None):
        QLineEdit.__init__(self, text=text, parent=parent)

        searchPixmap = QPixmap(str(path("icons/search.png")))

        clearPixmap = QPixmap(str(path("icons/clear.png")))
        self.clearButton = QToolButton(self)
        self.clearButton.setIcon(QIcon(clearPixmap))
        self.clearButton.setIconSize(QSize(16, 16))
        self.clearButton.setCursor(Qt.ArrowCursor)
        self.clearButton.setStyleSheet("QToolButton { border: none; padding: 0 px;}")
        self.clearButton.hide()

        if clearable:
            self.clearButton.clicked.connect(self.clear)
            self.textChanged.connect(self.updateCloseButton)

        self.searchButton = QToolButton(self)
        self.searchButton.setIcon(QIcon(searchPixmap))
        self.searchButton.setIconSize(QSize(16, 16))
        self.searchButton.setStyleSheet("QToolButton { border: none; padding: 0 px;}")

        frameWidth = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth)
        self.setStyleSheet("QLineEdit { padding-left: %spx; padding - right: % spx;} " %
                           (self.searchButton.sizeHint().width() + frameWidth + 1,
                            self.clearButton.sizeHint().width() + frameWidth + 1))
        msz = self.minimumSizeHint()
        self.setMinimumSize(max(msz.width(),
                                self.searchButton.sizeHint().width() +
                                self.clearButton.sizeHint().width() +
                                frameWidth * 2 + 2),
                            max(msz.height(), self.clearButton.sizeHint().height() + frameWidth * 2 + 2))
Exemplo n.º 2
0
    def __init__(self, workflowview: QAbstractItemView):
        super(WorkflowWidget, self).__init__()

        self.view = workflowview

        self.toolbar = QToolBar()
        addfunctionmenu = QToolButton()
        functionmenu = QMenu()
        for plugin in pluginmanager.getPluginsOfCategory('ProcessingPlugin'):
            functionmenu.addAction(
                plugin.name,
                partial(self.addProcess,
                        plugin.plugin_object,
                        autoconnectall=True))
        addfunctionmenu.setMenu(functionmenu)
        addfunctionmenu.setIcon(QIcon(path('icons/addfunction.png')))
        addfunctionmenu.setText('Add Function')
        addfunctionmenu.setPopupMode(QToolButton.InstantPopup)
        self.toolbar.addWidget(addfunctionmenu)
        # self.toolbar.addAction(QIcon(path('icons/up.png')), 'Move Up')
        # self.toolbar.addAction(QIcon(path('icons/down.png')), 'Move Down')
        self.toolbar.addAction(QIcon(path('icons/folder.png')),
                               'Load Workflow')
        self.toolbar.addAction(QIcon(path('icons/trash.png')),
                               'Clear Workflow')

        v = QVBoxLayout()
        v.addWidget(self.view)
        v.addWidget(self.toolbar)
        v.setContentsMargins(0, 0, 0, 0)
        self.setLayout(v)
Exemplo n.º 3
0
def mk_enableicon():
    enableicon = QIcon()
    enableicon.addPixmap(QPixmap(path("icons/enable.png")),
                         state=enableicon.Off)
    enableicon.addPixmap(QPixmap(path("icons/disable.png")),
                         state=enableicon.On)
    return enableicon
Exemplo n.º 4
0
    def __init__(self, browserview):
        super(DataBrowser, self).__init__()

        hbox = QHBoxLayout()
        vbox = QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        hbox.setContentsMargins(0, 0, 0, 0)
        hbox.setSpacing(0)
        self.setContentsMargins(0, 0, 0, 0)

        self.browserview = browserview
        self.browserview.sigOpen.connect(self.sigOpen)
        self.browserview.sigPreview.connect(self.sigPreview)
        self.browserview.sigOpenExternally.connect(self.openExternally)
        self.browserview.sigURIChanged.connect(self.uri_to_text)
        self.toolbar = QToolBar()
        self.toolbar.addAction(QIcon(QPixmap(str(path("icons/up.png")))), "Move up directory", self.moveUp)
        # self.toolbar.addAction(QIcon(QPixmap(str(path('icons/filter.png')))), 'Filter')
        self.toolbar.addAction(QIcon(QPixmap(str(path("icons/refresh.png")))), "Refresh", self.hardRefreshURI)
        self.toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly)
        self.URILineEdit = SearchLineEdit("", clearable=False)
        self.uri_to_text()

        hbox.addWidget(self.toolbar)
        hbox.addWidget(self.URILineEdit)
        vbox.addLayout(hbox)
        vbox.addWidget(self.browserview)
        self.setLayout(vbox)

        self.URILineEdit.textChanged.connect(self.softRefreshURI)
        self.URILineEdit.returnPressed.connect(self.softRefreshURI)  # hard refresh
        self.URILineEdit.focusOutEvent = self.softRefreshURI  # hard refresh

        self.hardRefreshURI()
Exemplo n.º 5
0
    def __init__(self, workflowview: QAbstractItemView):
        super(WorkflowWidget, self).__init__()

        self.view = workflowview

        self.toolbar = QToolBar()
        self.addfunctionmenu = QToolButton()
        self.addfunctionmenu.setIcon(QIcon(path("icons/addfunction.png")))
        self.addfunctionmenu.setText("Add Function")
        # Defer menu population to once the plugins have been loaded; otherwise, the menu may not contain anything
        # if this widget is init'd before all plugins have been loaded.
        self.functionmenu = QMenu()
        self.functionmenu.aboutToShow.connect(self.populateFunctionMenu)
        self.addfunctionmenu.setMenu(self.functionmenu)
        self.addfunctionmenu.setPopupMode(QToolButton.InstantPopup)
        self.toolbar.addWidget(self.addfunctionmenu)
        # self.toolbar.addAction(QIcon(path('icons/up.png')), 'Move Up')
        # self.toolbar.addAction(QIcon(path('icons/down.png')), 'Move Down')
        self.toolbar.addAction(QIcon(path("icons/folder.png")), "Load Workflow")
        self.toolbar.addAction(QIcon(path("icons/trash.png")), "Delete Operation", self.deleteProcess)

        v = QVBoxLayout()
        v.addWidget(self.view)
        v.addWidget(self.toolbar)
        v.setContentsMargins(0, 0, 0, 0)
        self.setLayout(v)
Exemplo n.º 6
0
    def __init__(self, parent=None):
        super(TomoToolbar, self).__init__(parent)

        self.addAction(QIcon(path('icons/run.png')), 'Full Reconstruction',
                       self.sigFullReconstruction.emit)
        self.addAction(QIcon(path('icons/slice.png')), 'Slice Reconstruction',
                       self.sigSliceReconstruction.emit)
        self.addAction(QIcon(path('icons/multislice.png')),
                       'Multi-Slice Reconstruction',
                       self.sigMultiSliceReconstruction.emit)
        self.addAction(QIcon(path('icons/3dpreview.png')),
                       '3D Preview Reconstruction',
                       self.sig3DPreviewReconstruction.emit)
Exemplo n.º 7
0
    def __init__(self):
        # Setup UI
        self.widget = QWidget()
        self.widget.setLayout(QHBoxLayout())
        self.listview = QListView()
        self.connectionsmodel = QStandardItemModel()
        self.listview.setModel(self.connectionsmodel)

        self.plugintoolbar = QToolBar()
        self.plugintoolbar.setOrientation(Qt.Vertical)
        self.plugintoolbar.addAction(QIcon(str(path("icons/plus.png"))), "Add plugin", self.add_credential)
        self.plugintoolbar.addAction(QIcon(str(path("icons/minus.png"))), "Remove plugin", self.remove_credential)
        self.widget.layout().addWidget(self.listview)
        self.widget.layout().addWidget(self.plugintoolbar)
        super(ConnectionSettingsPlugin, self).__init__(QIcon(str(path("icons/server.png"))), "Connections", self.widget)
Exemplo n.º 8
0
    def __init__(self):
        self._happi_db_dirs = [happi_site_dir, happi_user_dir]
        self._device_view = HappiClientTreeView()
        self._client_model = HappiClientModel()
        self._device_view.setModel(self._client_model)
        for db_dir in self._happi_db_dirs:
            for db_file in Path(db_dir).glob('*.json'):
                client = Client(path=str(db_file))
                self._client_model.add_client(client)
        try:
            mongo_client = Client(
                MongoBackend(host='127.0.0.1',
                             db='happi',
                             collection='labview_static',
                             user=USER_MONGO,
                             pw=PW_MONGO,
                             timeout=None))
            self._client_model.add_client(mongo_client)
        except Exception as e:  #TODO catch exception properly
            msg.logError(e)

        widget = QWidget()
        layout = QVBoxLayout()
        layout.addWidget(self._device_view)
        widget.setLayout(layout)

        icon = QIcon(str(static.path('icons/calibrate.png')))
        name = "Devices"
        super(HappiSettingsPlugin, self).__init__(icon, name, widget)
        self._device_view.expandAll()
        self.restore()
Exemplo n.º 9
0
    def __init__(self):
        self.headermodel = None
        self.selectionmodel = None
        self.multiAI = MultiGeometry([])
        self.AIs = dict()

        widget = ParameterTree()
        energy = SimpleParameter(name='Energy',
                                 type='float',
                                 value=10000,
                                 siPrefix=True,
                                 suffix='eV')
        wavelength = SimpleParameter(name='Wavelength',
                                     type='float',
                                     value=1.239842e-6 / 10000,
                                     siPrefix=True,
                                     suffix='m')
        self.parameter = Parameter(name="Device Profiles",
                                   type='group',
                                   children=[energy, wavelength])
        widget.setParameters(self.parameter, showTop=False)
        icon = QIcon(str(path('icons/calibrate.png')))
        super(DeviceProfiles, self).__init__(icon, "Device Profiles", widget)

        self.parameter.sigValueChanged.connect(self.sigRequestRedraw)
        self.parameter.sigValueChanged.connect(self.sigRequestReduce)
        self.parameter.sigTreeStateChanged.connect(self.simulateCalibrant)
        self.parameter.sigTreeStateChanged.connect(self.genAIs)

        self.parameter.sigValueChanged.connect(self.simulateCalibrant)
Exemplo n.º 10
0
    def __init__(self, headermodel: QStandardItemModel, selectionmodel: QItemSelectionModel):
        super(SAXSToolbar, self).__init__()

        self.results = []

        self.headermodel = headermodel
        self.selectionmodel = selectionmodel
        self.headermodel.dataChanged.connect(self.updatedetectorcombobox)

        self.detectorcombobox = QComboBox()
        self.detectorcombobox.currentTextChanged.connect(self.sigDeviceChanged)

        self.addWidget(self.detectorcombobox)
        self.addSeparator()
        self.modegroup = QActionGroup(self)
        self.rawaction = self.mkAction('icons/raw.png', 'Raw', checkable=True, group=self.modegroup, checked=True)
        self.addAction(self.rawaction)
        self.cakeaction = self.mkAction('icons/cake.png', 'Cake (q/chi plot)', checkable=True, group=self.modegroup)
        self.addAction(self.cakeaction)
        self.remeshaction = self.mkAction('icons/remesh.png', 'Remesh (GIWAXS)', checkable=True, group=self.modegroup)
        self.addAction(self.remeshaction)
        self.addSeparator()

        self.multiplot = QAction(self)
        self.multiplot.setIcon(QIcon(str(path('icons/multiplot.png'))))
        self.multiplot.setText('Plot Series')
        self.multiplot.setCheckable(True)
        self.multiplot.triggered.connect(self.sigDoWorkflow)
        self.addAction(self.multiplot)
Exemplo n.º 11
0
    def __init__(self, *args, **kwargs):
        super(SplitGridView, self).__init__(*args, **kwargs)

        self.top_splitter = QSplitter(Qt.Horizontal)
        self.top_splitter.setSizes([100, 200])

        self.bottom_splitter = QSplitter(Qt.Horizontal)
        self.bottom_splitter.setSizes([100, 200])

        # connect splitter1 and splitter2 to move together
        # TODO which version is desired? connect splitter or free moving?
        # self.top_splitter.splitterMoved.connect(self.moveSplitter)
        # self.bottom_splitter.splitterMoved.connect(self.moveSplitter)
        # self._spltA = self.top_splitter
        # self._spltB = self.bottom_splitter

        self.outer_splitter = QSplitter(Qt.Vertical)
        self.outer_splitter.insertWidget(0, self.top_splitter)
        self.outer_splitter.insertWidget(1, self.bottom_splitter)
        self.outer_splitter.setSizes([200, 400])

        self.layout.addWidget(self.outer_splitter)
        self.setLayout(self.layout)
        QApplication.setStyle(QStyleFactory.create('Cleanlooks'))
        self.setGeometry(300, 300, 300, 200)

        self.max_canvases = 4

        # Set attrs for when the buttons are created
        self.icon = QIcon(path('icons/2x2grid.png'))
        self.tool_tip = "2x2 Grid View"
        self.whats_this = "Displays up to four visualized data items in a grid layout."
Exemplo n.º 12
0
    def __init__(self, tabwidget: QTabWidget):
        super(BrowserTabBar, self).__init__()

        self.tabwidget = tabwidget
        self.tabwidget.setTabBar(self)

        self.setExpanding(False)
        self.setTabsClosable(True)

        plusPixmap = QPixmap(str(path("icons/plus.png")))
        self.plusIcon = QIcon(plusPixmap)
        # self.plus_button.setToolTip('Open a new browser')
        # self.plus_button.setParent(self)
        # self.plus_button.setMaximumSize(32, 32)
        # self.plus_button.setMinimumSize(32, 32)
        # self.plus_button.clicked.connect(self.sigAddBrowser.emit)
        tab = self.addTab(self.plusIcon, '')
        try:
            self.tabButton(tab, QTabBar.RightSide).resize(0, 0)
            self.tabButton(tab, QTabBar.RightSide).hide()
        except AttributeError:
            self.tabButton(tab, QTabBar.LeftSide).resize(0, 0)
            self.tabButton(tab, QTabBar.LeftSide).hide()
        # self.movePlusButton()  # Move to the correct location
        # self.setDocumentMode(True)
        self.currentChanged.connect(self.tabwidget.setCurrentIndex)
        self.installEventFilter(self)
Exemplo n.º 13
0
    def paint(self, painter, option, index):
        if not self._parent.indexWidget(index):
            button = QToolButton(self.parent())
            button.setText('i')
            button.setAutoRaise(True)
            icon = QIcon()
            icon.addPixmap(QPixmap(path('icons/enable.png')), state=icon.Off)
            icon.addPixmap(QPixmap(path('icons/disable.png')), state=icon.On)
            button.setIcon(icon)
            button.setCheckable(True)
            sp = QSizePolicy()
            sp.setWidthForHeight(True)
            button.setSizePolicy(sp)
            button.clicked.connect(index.data())

            self._parent.setIndexWidget(index, button)
Exemplo n.º 14
0
    def __init__(self):
        self.headermodel = None
        self.selectionmodel = None
        self.multiAI = MultiGeometry([])
        self.AIs = dict()
        self._changes = []
        self.isSilent = False

        energy = SimpleParameter(name='Energy',
                                 type='float',
                                 value=10000,
                                 siPrefix=True,
                                 suffix='eV')
        wavelength = SimpleParameter(name='Wavelength',
                                     type='float',
                                     value=1.239842e-6 / 10000,
                                     siPrefix=True,
                                     suffix='m')

        icon = QIcon(str(path('icons/calibrate.png')))
        super(DeviceProfiles, self).__init__(icon,
                                             "Device Profiles",
                                             [energy, wavelength],
                                             addText='New Device')

        self.sigTreeStateChanged.connect(self.stateChanged)
Exemplo n.º 15
0
 def __init__(self, *args, **kwargs):
     super(DisablableListView, self).__init__(*args, **kwargs)
     # TODO: find an icon for indeterminate stae
     self.setStyleSheet("""
     QListView::indicator:checked {
         image: url(""" + path('icons/enable.png').replace('\\', '/') +
                        """);
     }
     QListView::indicator:indeterminate {
         image: url(""" + path('icons/enable.png').replace('\\', '/') +
                        """);
     }
     QListView::indicator:unchecked {
         image: url(""" + path('icons/disable.png').replace('\\', '/') +
                        """);
     }""")
Exemplo n.º 16
0
    def __init__(self, *args, **kwargs):
        super(SplitGridView, self).__init__(*args, **kwargs)

        self.top_splitter = QSplitter(Qt.Horizontal)
        self.top_splitter.setSizes([100, 200])

        self.bottom_splitter = QSplitter(Qt.Horizontal)
        self.bottom_splitter.setSizes([100, 200])

        # connect splitter1 and splitter2 to move together
        # TODO which version is desired? connect splitter or free moving?
        # self.top_splitter.splitterMoved.connect(self.moveSplitter)
        # self.bottom_splitter.splitterMoved.connect(self.moveSplitter)
        # self._spltA = self.top_splitter
        # self._spltB = self.bottom_splitter

        self.outer_splitter = QSplitter(Qt.Vertical)
        self.outer_splitter.insertWidget(0, self.top_splitter)
        self.outer_splitter.insertWidget(1, self.bottom_splitter)
        self.outer_splitter.setSizes([200, 400])

        self.layout.addWidget(self.outer_splitter)
        self.setLayout(self.layout)
        QApplication.setStyle(QStyleFactory.create('Cleanlooks'))
        self.setGeometry(300, 300, 300, 200)

        self.max_canvases = 4

        self.icon = QIcon(path('icons/2x2grid.png'))
Exemplo n.º 17
0
def test_EZPlugin(qtbot):
    from xicam.plugins import EZPlugin
    from xicam.gui.static import path
    from xicam.core.data import NonDBHeader

    def runtest():
        import numpy as np

        img = np.random.random((100, 100, 100))
        EZTest.instance.setImage(img)

        hist = np.histogram(img, 100)
        EZTest.instance.plot(hist[1][:-1], hist[0])

    def appendcatalog(header: NonDBHeader):
        img = header.meta_array(list(header.fields())[0])
        EZTest.instance.setImage(img)

    EZTest = EZPlugin(
        name="EZTest",
        toolbuttons=[(str(path("icons/calibrate.png")), runtest)],
        parameters=[{"name": "Test", "value": 10, "type": "int"}, {"name": "Fooo", "value": True, "type": "bool"}],
        appendcatalog=appendcatalog,
    )
    return EZTest
Exemplo n.º 18
0
    def __init__(self):

        self._model = BrokerModel()
        self._model.add_catalogs()

        self._view = BrokerView()
        self._view.setModel(self._model)

        self._selected_broker = QLabel("(None)")
        self._selected_broker.setFrameStyle(QFrame.Box)

        def update_current_configuration_text(broker):
            self._selected_broker.setText(broker.name)

        self._view.sigCurrentBrokerChanged.connect(update_current_configuration_text)

        layout = QVBoxLayout()
        layout.addWidget(self._view)

        inner_layout = QHBoxLayout()
        label = QLabel("active broker:")
        label.setAlignment(Qt.AlignRight)
        inner_layout.addWidget(label)
        inner_layout.addWidget(self._selected_broker)

        layout.addLayout(inner_layout)

        self._widget = QWidget()
        self._widget.setLayout(layout)

        name = "Broker Configuration"
        icon = QIcon(static.path("icons/z.png"))
        super(DatabrokerSettingsPlugin, self).__init__(icon, name, self._widget)
        self.restore()
Exemplo n.º 19
0
def test_EZPlugin():
    def runtest():
        import numpy as np

        img = np.random.random((100, 100, 100))
        EZTest.instance.setImage(img)

        hist = np.histogram(img, 100)
        EZTest.instance.plot(hist[1][:-1], hist[0])

    def appendheadertest(header: NonDBHeader):
        img = header.meta_array(list(header.fields())[0])
        EZTest.instance.setImage(img)

    EZTest = EZPlugin(
        name="EZTest",
        toolbuttons=[(str(path("icons/calibrate.png")), runtest)],
        parameters=[{
            "name": "Test",
            "value": 10,
            "type": "int"
        }, {
            "name": "Fooo",
            "value": True,
            "type": "bool"
        }],
        appendheadertest=appendheadertest,
    )
Exemplo n.º 20
0
 def mkGroupToggle(self, iconpath: str = None, text=None, receiver=None):
     actn = QAction(self)
     if iconpath: actn.setIcon(QIcon(QPixmap(str(path(iconpath)))))
     if text: actn.setText(text)
     if receiver: actn.triggered.connect(receiver)
     actn.setCheckable(True)
     actn.setActionGroup(self.modeActionGroup)
     return actn
Exemplo n.º 21
0
    def __init__(self):
        super(SAXSSpectraToolbar, self).__init__()

        layout = QVBoxLayout()
        modetoolbar = QToolBar()
        optionstoolbar = QToolBar()
        layout.addWidget(modetoolbar)
        layout.addWidget(optionstoolbar)
        self.setLayout(layout)
        layout.setStretch(0, 2)
        layout.setStretch(1, 1)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)

        self.modeActionGroup = QActionGroup(self)
        qbtn = self.mkGroupToggle('icons/q.png', text='q (Azimuthal) Integration', receiver=self.sigPlotCache.emit)
        qbtn.setChecked(True)
        modetoolbar.addAction(qbtn)
        modetoolbar.addAction(
            self.mkGroupToggle('icons/chi.png', text='χ (chi/Radial) Integration', receiver=self.sigPlotCache.emit))
        modetoolbar.addAction(
            self.mkGroupToggle('icons/x.png', text='X (Horizontal) Integration', receiver=self.sigPlotCache.emit))
        modetoolbar.addAction(
            self.mkGroupToggle('icons/z.png', text='Z (Vertical) Integration', receiver=self.sigPlotCache.emit))
        modetoolbar.addAction(self.mkGroupToggle('icons/G.png', text='Guinier Plot', receiver=self.sigPlotCache.emit))
        modetoolbar.addAction(self.mkGroupToggle('icons/P.png', text='Porod Plot', receiver=self.sigPlotCache.emit))
        modetoolbar.addAction(self.mkGroupToggle('icons/Iq2.png', text='I×q\u00B2', receiver=self.sigPlotCache.emit))
        modetoolbar.addAction(self.mkGroupToggle('icons/Iq3.png', text='I×q\u00B3', receiver=self.sigPlotCache.emit))
        modetoolbar.addAction(self.mkGroupToggle('icons/Iq4.png', text='I×q\u0074', receiver=self.sigPlotCache.emit))
        modetoolbar.addAction(self.mkGroupToggle('icons/gofr.png', text='Electron Density Correlation Function',
                                                 receiver=self.sigPlotCache.emit))
        modetoolbar.addAction(
            self.mkGroupToggle('icons/gofrvec.png', text='Pair Distribution Function', receiver=self.sigPlotCache.emit))

        self.multiplot = QAction(self)
        self.multiplot.setIcon(QIcon(str(path('icons/multiplot.png'))))
        self.multiplot.setText('Plot Series')
        self.multiplot.setCheckable(True)
        self.multiplot.triggered.connect(self.sigDoWorkflow)
        optionstoolbar.addSeparator()
        optionstoolbar.addAction(self.multiplot)
        optionstoolbar.addAction(QIcon(str(path('icons/blackwhite.png'))), 'Toggle Theme')
        optionstoolbar.addAction(QIcon(str(path('icons/configure.png'))), 'Configure Plot')

        optionstoolbar.setOrientation(Qt.Vertical)
        modetoolbar.setOrientation(Qt.Vertical)
Exemplo n.º 22
0
 def __init__(self, *args, **kwargs):
     super(MultiPlot, self).__init__(*args, **kwargs)
     self.multiplot = QAction(self)
     self.multiplot.setIcon(QIcon(str(path('icons/multiplot.png'))))
     self.multiplot.setText('Plot Series')
     self.multiplot.setCheckable(True)
     self.multiplot.triggered.connect(self.sigDoWorkflow)
     self.addAction(self.multiplot)
     self.addSeparator()
Exemplo n.º 23
0
    def __init__(self):
        def msg_levels(recommended=""):
            """Returns a dictionary mapping logging level names to their respective integer values.

            Note that `msg.levels` gives us the reverse mapping that we want, from level to level name.

            Parameters
            ----------
            recommended
                Optional string which will mark a logging level as recommended (for use in the list parameter)
                (default is "", which will not mark any levels).

            Returns
            -------
                Dictionary that maps log level names to their values, optionally with one name marked as recommended.

            """
            levels = dict()  #{v: k for k, v in msg.levels.items()}
            for level, level_name in msg.levels.items():
                if recommended and recommended == level_name:
                    levels[level_name + " (recommended)"] = level
                else:
                    levels[level_name] = level
            return levels

        super(LoggingSettingsPlugin, self).__init__(
            QIcon(str(path("icons/ellipsis.png"))),
            msg.LOGGING_SETTINGS_NAME,
            [
                # Show users where the log directory is, don't let them modify it though
                dict(name="Log Directory",
                     value=msg.log_dir,
                     type='str',
                     readonly=True,
                     tip="Location where Xi-CAM writes its logs to."),
                # Allow users to configure the default log level for the xicam logger's FileHandler
                dict(
                    name=msg.FILE_LOG_LEVEL_SETTINGS_NAME,
                    values=msg_levels(recommended="DEBUG"),
                    value=msg.DEFAULT_FILE_LOG_LEVEL,
                    type="list",
                    tip=
                    "Changes how much information is logged to the log file in 'Log Directory.'"
                ),
                # Allow users to configure the default log level for the xicam logger's StreamHandler
                dict(
                    name=msg.STREAM_LOG_LEVEL_SETTINGS_NAME,
                    values=msg_levels(),
                    value=msg.DEFAULT_STREAM_LOG_LEVEL,
                    type="list",
                    tip=
                    "Changes how much information is logged to the system console / terminal.",
                ),
            ],
        )
        msg.file_handler.setLevel(self[msg.FILE_LOG_LEVEL_SETTINGS_NAME])
        msg.stream_handler.setLevel(self[msg.STREAM_LOG_LEVEL_SETTINGS_NAME])
Exemplo n.º 24
0
 def mkAction(self, iconpath: str = None, text=None, receiver=None, group=None, checkable=False, checked=False):
     actn = QAction(self)
     if iconpath: actn.setIcon(QIcon(QPixmap(str(path(iconpath)))))
     if text: actn.setText(text)
     if receiver: actn.triggered.connect(receiver)
     actn.setCheckable(checkable)
     if checked: actn.setChecked(checked)
     if group: actn.setActionGroup(group)
     return actn
Exemplo n.º 25
0
    def __init__(self):
        # Setup UI
        self.widget = QWidget()
        self.widget.setLayout(QHBoxLayout())
        self.listview = QListView()
        self.packagesmodel = QStandardItemModel()
        self.listview.setModel(self.packagesmodel)

        self.plugintoolbar = QToolBar()
        self.plugintoolbar.setOrientation(Qt.Vertical)
        self.plugintoolbar.addAction(QIcon(str(path("icons/plus.png"))), "Add plugin", self.addplugin)
        self.plugintoolbar.addAction(QIcon(str(path("icons/minus.png"))), "Remove plugin", self.removeplugin)
        self.widget.layout().addWidget(self.listview)
        self.widget.layout().addWidget(self.plugintoolbar)
        super(CamMartSettingsPlugin, self).__init__(QIcon(str(path("icons/box.png"))), "Plugins", self.widget)

        # Refresh packages list
        self.refresh()
Exemplo n.º 26
0
    def __init__(self, *args, **kwargs):
        super(SplitVertical, self).__init__(*args, **kwargs)

        self.splitter.setOrientation(Qt.Horizontal)

        # Set attrs for when the buttons are created
        self.icon = QIcon(path('icons/1x1vert.png'))
        self.tool_tip = "Vertical Split View"
        self.whats_this = "Displays up to two visualized data items in a vertical layout."
    def __init__(self,
                 workflowview: QAbstractItemView,
                 operation_filter: Callable[[OperationPlugin], bool] = None):
        super(WorkflowWidget, self).__init__()

        self.operation_filter = operation_filter
        self.view = workflowview

        self.autorun_checkbox = QCheckBox("Run Automatically")
        self.autorun_checkbox.setCheckState(Qt.Unchecked)
        self.autorun_checkbox.stateChanged.connect(self._autorun_state_changed)
        self.run_button = QPushButton("Run Workflow")
        self.run_button.clicked.connect(self.sigRunWorkflow.emit)
        self.view.model().workflow.attach(self._autorun)
        # TODO -- actually hook up the auto run OR dependent class needs to connect (see SAXSGUIPlugin)

        self.toolbar = QToolBar()
        self.addfunctionmenu = QToolButton()
        self.addfunctionmenu.setIcon(QIcon(path("icons/addfunction.png")))
        self.addfunctionmenu.setText("Add Function")
        # Defer menu population to once the plugins have been loaded; otherwise, the menu may not contain anything
        # if this widget is init'd before all plugins have been loaded.
        self.functionmenu = QMenu()
        self.functionmenu.aboutToShow.connect(self.populateFunctionMenu)
        self.addfunctionmenu.setMenu(self.functionmenu)
        self.addfunctionmenu.setPopupMode(QToolButton.InstantPopup)
        self.toolbar.addWidget(self.addfunctionmenu)
        # self.toolbar.addAction(QIcon(path('icons/up.png')), 'Move Up')
        # self.toolbar.addAction(QIcon(path('icons/down.png')), 'Move Down')
        self.toolbar.addAction(QIcon(path("icons/folder.png")),
                               "Load Workflow")
        self.toolbar.addAction(QIcon(path("icons/trash.png")),
                               "Delete Operation", self.deleteOperation)

        v = QVBoxLayout()
        v.addWidget(self.view)
        h = QHBoxLayout()
        h.addWidget(self.autorun_checkbox)
        h.addWidget(self.run_button)
        v.addLayout(h)
        v.addWidget(self.toolbar)
        v.setContentsMargins(0, 0, 0, 0)
        self.setLayout(v)
Exemplo n.º 28
0
    def __init__(self):
        # Setup UI
        self.widget = QWidget()
        self.widget.setLayout(QHBoxLayout())
        self.listview = QListView()
        self.devicesmodel = QStandardItemModel()
        self.listview.setModel(self.devicesmodel)

        self.plugintoolbar = QToolBar()
        self.plugintoolbar.setOrientation(Qt.Vertical)
        self.plugintoolbar.addAction(QIcon(str(path('icons/plus.png'))),
                                     'Add device', self.add_device)
        self.plugintoolbar.addAction(QIcon(str(path('icons/minus.png'))),
                                     'Remove device', self.remove_device)
        self.widget.layout().addWidget(self.listview)
        self.widget.layout().addWidget(self.plugintoolbar)
        super(DeviceSettingsPlugin,
              self).__init__(QIcon(str(path('icons/controlpanel.png'))),
                             'Devices', self.widget)
        self.restore()
Exemplo n.º 29
0
    def __init__(self, parent=None):
        super(CanvasDisplayTabWidget, self).__init__(parent)

        self._tabWidget = QTabWidget()
        self._tabWidget.setParent(self)

        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().addWidget(self._tabWidget)

        self.icon = QIcon(path('icons/tabs.png'))
Exemplo n.º 30
0
    def __init__(self, workflowview: QAbstractItemView):
        super(WorkflowWidget, self).__init__()

        self.view = workflowview

        self.toolbar = QToolBar()
        addfunctionmenu = QToolButton()
        functionmenu = QMenu()
        sortingDict = {}
        for plugin in pluginmanager.getPluginsOfCategory("ProcessingPlugin"):
            typeOfProcessingPlugin = plugin.plugin_object.getCategory()
            if not typeOfProcessingPlugin in sortingDict.keys():
                sortingDict[typeOfProcessingPlugin] = []
            sortingDict[typeOfProcessingPlugin].append(plugin)
        for key in sortingDict.keys():
            functionmenu.addSeparator()
            functionmenu.addAction(key)
            functionmenu.addSeparator()
            for plugin in sortingDict[key]:
                functionmenu.addAction(
                    plugin.name,
                    partial(self.addProcess,
                            plugin.plugin_object,
                            autoconnectall=True))
        addfunctionmenu.setMenu(functionmenu)
        addfunctionmenu.setIcon(QIcon(path("icons/addfunction.png")))
        addfunctionmenu.setText("Add Function")
        addfunctionmenu.setPopupMode(QToolButton.InstantPopup)
        self.toolbar.addWidget(addfunctionmenu)
        # self.toolbar.addAction(QIcon(path('icons/up.png')), 'Move Up')
        # self.toolbar.addAction(QIcon(path('icons/down.png')), 'Move Down')
        self.toolbar.addAction(QIcon(path("icons/folder.png")),
                               "Load Workflow")
        self.toolbar.addAction(QIcon(path("icons/trash.png")),
                               "Delete Operation", self.deleteProcess)

        v = QVBoxLayout()
        v.addWidget(self.view)
        v.addWidget(self.toolbar)
        v.setContentsMargins(0, 0, 0, 0)
        self.setLayout(v)