Пример #1
0
    def __init__(self, parent=None):
        super(LinkEquation, self).__init__(parent)
        from glue.config import link_function, link_helper

        # Set up mapping of function/helper name -> function/helper tuple. For the helpers, we use the 'display' name if available.
        def get_name(item):
            if hasattr(item, 'display') and item.display is not None:
                return item.display
            else:
                return item.__name__
        f = [f for f in link_function.members if len(f.output_labels) == 1]
        self._functions = OrderedDict((get_name(l[0]), l) for l in
                                      f + link_helper.members)
        self._argument_widgets = []
        self.spacer = None
        self._output_widget = ArgumentWidget("")

        # pyqt4 can't take self as second argument here
        # for some reason. Manually embed
        self._ui = load_ui('link_equation', None)
        l = QtGui.QHBoxLayout()
        l.addWidget(self._ui)
        self.setLayout(l)

        self._init_widgets()
        self._populate_function_combo()
        self._connect()
        self._setup_editor()
Пример #2
0
    def choose_vmin_vmax(self):
        dialog = load_ui('contrastlimits', None)
        v = QtGui.QDoubleValidator()
        dialog.vmin.setValidator(v)
        dialog.vmax.setValidator(v)

        vmin, vmax = self.get_vmin_vmax()
        if vmin is not None:
            dialog.vmin.setText(str(vmin))
        if vmax is not None:
            dialog.vmax.setText(str(vmax))

        def _apply():
            try:
                vmin = float(dialog.vmin.text())
                vmax = float(dialog.vmax.text())
                self.set_vmin_vmax(vmin, vmax)
                if self._move_callback is not None:
                    self._move_callback(self)
            except ValueError:
                pass

        bb = dialog.buttonBox
        bb.button(bb.Apply).clicked.connect(_apply)
        dialog.accepted.connect(_apply)
        dialog.show()
Пример #3
0
    def __init__(self, collection, parent=None):

        # Load in ui file to set up widget
        self.ui = load_ui('custom_component_widget', parent)

        # In the ui file we do not create the text field for the expression
        # because we want to use a custom widget that supports auto-complete.
        self.ui.expression = ColorizedCompletionTextEdit()
        self.ui.verticalLayout_3.addWidget(self.ui.expression)
        self.ui.expression.setAlignment(Qt.AlignCenter)
        self.ui.expression.setObjectName("expression")
        self.ui.expression.setToolTip("Define a new component. You can either "
                                      "type out the full name of a component\n"
                                      "with the data:component syntax, or "
                                      "start typing and press TAB to use "
                                      "tab-completion.\n Blue-colored "
                                      "components are valid, while "
                                      "Red-colored components are invalid.")

        self._labels = {}
        self._data = {}
        self._collection = collection
        self._gather_components()
        self._gather_data()
        self._init_widgets()
        self._connect()

        # Set up auto-completion. While the auto-complete window is open, we
        # cannot add/remove datasets or other components, so we can populate
        # the auto_completer straight off.
        self.ui.expression.set_word_list(list(self._labels.keys()))
Пример #4
0
    def __init__(self, collection, functions=None, parent=None):
        self._collection = collection

        self._ui = load_ui('link_editor', parent)
        self._init_widgets()
        self._connect()
        if len(collection) > 1:
            self._ui.right_components.set_data_row(1)
        self._size = None
Пример #5
0
    def __init__(self, label='', pix2world=None, lo=0, hi=10,
                 parent=None, aggregation=None):
        super(SliceWidget, self).__init__(parent)
        if aggregation is not None:
            raise NotImplemented("Aggregation option not implemented")
        if pix2world is not None:
            raise NotImplemented("Pix2world option not implemented")

        layout = QtGui.QVBoxLayout()
        layout.setContentsMargins(3, 1, 3, 1)
        layout.setSpacing(0)

        top = QtGui.QHBoxLayout()
        top.setContentsMargins(3, 3, 3, 3)
        label = QtGui.QLabel(label)
        top.addWidget(label)

        mode = QtGui.QComboBox()
        mode.addItem('x', 'x')
        mode.addItem('y', 'y')
        mode.addItem('slice', 'slice')
        mode.currentIndexChanged.connect(lambda x:
                                         self.mode_changed.emit(self.mode))
        mode.currentIndexChanged.connect(self._update_mode)
        top.addWidget(mode)

        layout.addLayout(top)

        slider = load_ui('cube_slider')
        slider.slider

        slider.slider.setMinimum(lo)
        slider.slider.setMaximum(hi)
        slider.slider.setValue((lo + hi) / 2)
        slider.slider.valueChanged.connect(lambda x:
                                           self.slice_changed.emit(self.mode))
        slider.slider.valueChanged.connect(lambda x: slider.label.setText(str(x)))

        slider.label.setMinimumWidth(50)
        slider.label.setText(str(slider.slider.value()))
        slider.label.textChanged.connect(lambda x: slider.slider.setValue(int(x)))

        slider.first.clicked.connect(nonpartial(self._browse_slice, 'first'))
        slider.prev.clicked.connect(nonpartial(self._browse_slice, 'prev'))
        slider.next.clicked.connect(nonpartial(self._browse_slice, 'next'))
        slider.last.clicked.connect(nonpartial(self._browse_slice, 'last'))

        layout.addWidget(slider)

        self.setLayout(layout)

        self._ui_label = label
        self._ui_slider = slider
        self._ui_mode = mode
        self._update_mode()
        self._frozen = False
Пример #6
0
    def __init__(self, installed=None):

        self.ui = load_ui('plugin_manager.ui', None)

        self.ui.cancel.clicked.connect(self.reject)
        self.ui.confirm.clicked.connect(self.finalize)

        self._checkboxes = {}

        self.update_list(installed=installed)
Пример #7
0
    def _setup_widgets(self):
        self.central_widget = self.make_central_widget()
        self.label_widget = QtGui.QLabel("", self.central_widget)
        self.setCentralWidget(self.central_widget)
        self.ui = load_ui('imagewidget', None)
        self.option_widget = self.ui
        self.ui.slice = DataSlice()
        self.ui.slice_layout.addWidget(self.ui.slice)
        self._tweak_geometry()

        self.ui.aspectCombo.addItem("Square Pixels", userData='equal')
        self.ui.aspectCombo.addItem("Automatic", userData='auto')
Пример #8
0
    def __init__(self, feedback='', parent=None):
        """
        :param feedback: The default feedback report
        :type feedback: str

        Feedback will be supplemented with diagnostic system information.
        The user can modify or add to any of this
        """
        self._ui = load_ui('feedbackwidget', None)
        feedback = '\n'.join(['-' * 80,
                              feedback,
                              _diagnostics()])
        self._ui.report_area.insertPlainText('\n' + feedback)
        self._ui.report_area.moveCursor(QtGui.QTextCursor.Start)
Пример #9
0
    def __init__(self, session, parent=None):
        super(HistogramWidget, self).__init__(session, parent)

        self.central_widget = MplWidget()
        self.setCentralWidget(self.central_widget)
        self.option_widget = QtGui.QWidget()
        self.ui = load_ui("histogramwidget", self.option_widget)
        self._tweak_geometry()
        self.client = HistogramClient(
            self._data, self.central_widget.canvas.fig, layer_artist_container=self._layer_artist_container
        )
        self._init_limits()
        self.make_toolbar()
        self._connect()
        # maps _hash(componentID) -> componentID
        self._component_hashes = {}
Пример #10
0
    def __init__(self, session, parent=None):
        super(DendroWidget, self).__init__(session, parent)

        self.central_widget = MplWidget()
        self.option_widget = QtGui.QWidget()
        self.setCentralWidget(self.central_widget)

        self.ui = load_ui('dendrowidget', self.option_widget)
        self.client = DendroClient(self._data,
                                   self.central_widget.canvas.fig,
                                   layer_artist_container=self._layer_artist_container)

        self._connect()

        self.make_toolbar()
        self.statusBar().setSizeGripEnabled(False)
Пример #11
0
    def __init__(self, session, parent=None, widget=None):

        super(TableWidget, self).__init__(session, parent)

        self.ui = load_ui('table_widget')
        self.setCentralWidget(self.ui)

        hdr = self.ui.table.horizontalHeader()
        hdr.setStretchLastSection(True)
        hdr.setResizeMode(hdr.Interactive)

        hdr = self.ui.table.verticalHeader()
        hdr.setResizeMode(hdr.Interactive)

        self.ui.table.clicked.connect(self._clicked)

        self.model = None
        self.subset = None
        self.selected_rows = []
Пример #12
0
    def __init__(self, collect, default=None, parent=None):
        """Create a new dialog for subset faceting

        :param collect: The :class:`~glue.core.data_collection.DataCollection` to use
        :param default: The default dataset in the collection (optional)
        """
        self.ui = load_ui('subset_facet', None)
        self.ui.setWindowTitle("Subset Facet")
        self._collect = collect

        self.ui.component_selector.setup(self._collect)
        if default is not None:
            self.ui.component_selector.data = default

        val = QtGui.QDoubleValidator(-1e100, 1e100, 4, None)
        self.ui.component_selector.component_changed.connect(self._set_limits)

        combo = self.ui.color_scale
        for cmap in [cm.cool, cm.RdYlBu, cm.RdYlGn, cm.RdBu, cm.Purples]:
            combo.addItem(QtGui.QIcon(cmap2pixmap(cmap)), cmap.name, cmap)
Пример #13
0
    def __init__(self, session, parent=None):
        super(ScatterWidget, self).__init__(session, parent)
        self.central_widget = MplWidget()
        self.option_widget = QtGui.QWidget()

        self.setCentralWidget(self.central_widget)

        self.ui = load_ui('scatterwidget', self.option_widget)
        self._tweak_geometry()

        self.client = ScatterClient(self._data,
                                    self.central_widget.canvas.fig,
                                    layer_artist_container=self._layer_artist_container)

        self._connect()
        self.unique_fields = set()
        tb = self.make_toolbar()
        cache_axes(self.client.axes, tb)
        self.statusBar().setSizeGripEnabled(False)
        self.setFocusPolicy(Qt.StrongFocus)
Пример #14
0
    def _setup_ui(self):
        self._ui = load_ui('glue_application', None)
        self.setCentralWidget(self._ui)
        self._ui.tabWidget.setTabBar(GlueTabBar())

        lw = LayerTreeWidget()
        lw.set_checkable(False)
        vb = QtGui.QVBoxLayout()
        vb.setContentsMargins(0, 0, 0, 0)
        vb.addWidget(lw)
        self._ui.data_layers.setLayout(vb)
        self._ui.layerWidget = lw

        # log window + status light
        self._ui.log = GlueLogger()
        self._ui.log.window().setWindowTitle("Console Log")
        self._ui.log.resize(550, 550)
        self.statusBar().addPermanentWidget(self._ui.log.status_light)
        self.statusBar().setContentsMargins(2, 0, 20, 2)
        self.statusBar().setSizeGripEnabled(False)
Пример #15
0
    def _choose_merge(data, others):

        w = load_ui('merge')
        w.show()
        w.raise_()

        label = others[0].label if len(others) > 0 else data.label
        w.merged_label.setText(label)

        entries = [QtGui.QListWidgetItem(other.label) for other in others]
        for e in entries:
            e.setCheckState(Qt.Checked)

        for d, item in zip(others, entries):
            w.choices.addItem(item)
        if not w.exec_():
            return None

        result = [layer for layer, entry in zip(others, entries)
                  if entry.checkState() == Qt.Checked]

        if result:
            result[0].label = str(w.merged_label.text())
            return result + [data]
Пример #16
0
 def __init__(self):
     QtGui.QWidget.__init__(self)
     self.ui = load_ui('messagewidget', self)
     self.ui.messageTable.setColumnCount(3)
     labels = ['Time', 'Message', 'Sender']
     self.ui.messageTable.setHorizontalHeaderLabels(labels)
Пример #17
0
 def __init__(self, parent=None):
     super(ComponentSelector, self).__init__(parent)
     self._data = None
     self._ui = load_ui('component_selector', self)
     self._init_widgets()
     self._connect()