コード例 #1
0
ファイル: viewer_widget.py プロジェクト: crawfordsm/glue
    def __init__(self, session, parent=None, widget=None):

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

        self.ui = load_ui('viewer_widget.ui',
                          directory=os.path.dirname(__file__))
        self.setCentralWidget(self.ui)

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

        if is_pyqt5():
            hdr.setSectionResizeMode(hdr.Interactive)
        else:
            hdr.setResizeMode(hdr.Interactive)

        hdr = self.ui.table.verticalHeader()

        if is_pyqt5():
            hdr.setSectionResizeMode(hdr.Interactive)
        else:
            hdr.setResizeMode(hdr.Interactive)

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

        self.model = None
        self.subset = None
        self.selected_rows = []
コード例 #2
0
ファイル: layer_tree_widget_ui.py プロジェクト: rguter/glue
 def retranslateUi(self, LayerTree):
     if is_pyqt5():
         LayerTree.setWindowTitle(
             QtGui.QApplication.translate("LayerTree", "Form", None))
         self.layerAddButton.setToolTip(
             QtGui.QApplication.translate("LayerTree",
                                          "Load a new data set", None))
         self.newSubsetButton.setToolTip(
             QtGui.QApplication.translate("LayerTree",
                                          "Create a new empty subset",
                                          None))
         self.layerRemoveButton.setToolTip(
             QtGui.QApplication.translate("LayerTree", "Delete Layer",
                                          None))
         self.linkButton.setToolTip(
             QtGui.QApplication.translate("LayerTree", "Link data", None))
     else:
         LayerTree.setWindowTitle(
             QtGui.QApplication.translate("LayerTree", "Form", None,
                                          QtGui.QApplication.UnicodeUTF8))
         self.layerAddButton.setToolTip(
             QtGui.QApplication.translate("LayerTree",
                                          "Load a new data set", None,
                                          QtGui.QApplication.UnicodeUTF8))
         self.newSubsetButton.setToolTip(
             QtGui.QApplication.translate("LayerTree",
                                          "Create a new empty subset", None,
                                          QtGui.QApplication.UnicodeUTF8))
         self.layerRemoveButton.setToolTip(
             QtGui.QApplication.translate("LayerTree", "Delete Layer", None,
                                          QtGui.QApplication.UnicodeUTF8))
         self.linkButton.setToolTip(
             QtGui.QApplication.translate("LayerTree", "Link data", None,
                                          QtGui.QApplication.UnicodeUTF8))
コード例 #3
0
def test_flags():
    model, _ = setup_model(1)

    expected = (Qt.ItemIsEditable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled
                | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable)

    if is_pyqt5():
        expected |= Qt.ItemNeverHasChildren

    assert model.flags(model.index(0)) == expected
コード例 #4
0
def test_flags():
    model, _ = setup_model(1)

    expected = (
        Qt.ItemIsEditable | Qt.ItemIsDragEnabled | Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable
    )

    if is_pyqt5():
        expected |= Qt.ItemNeverHasChildren

    assert model.flags(model.index(0)) == expected
コード例 #5
0
    def __init__(self, data_collection, parent=None):
        QtCore.QAbstractItemModel.__init__(self, parent)
        HubListener.__init__(self)

        self.data_collection = data_collection
        self.root = DataCollectionItem(data_collection)
        self._items = {}   # map hashes of Model pointers to model items
        # without this reference, PySide clobbers instance
        # data of model items
        self.register_to_hub(self.data_collection.hub)
        if not is_pyqt5():
            self.setSupportedDragActions(Qt.CopyAction)
コード例 #6
0
ファイル: data_collection_model.py プロジェクト: robintw/glue
    def __init__(self, data_collection, parent=None):
        QtCore.QAbstractItemModel.__init__(self, parent)
        HubListener.__init__(self)

        self.data_collection = data_collection
        self.root = DataCollectionItem(data_collection)
        self._items = {}  # map hashes of Model pointers to model items
        # without this reference, PySide clobbers instance
        # data of model items
        self.register_to_hub(self.data_collection.hub)
        if not is_pyqt5():
            self.setSupportedDragActions(Qt.CopyAction)
コード例 #7
0
ファイル: layertree.py プロジェクト: antonl/glue
 def retranslateUi(self, LayerTree):
     if is_pyqt5():
         LayerTree.setWindowTitle(QtGui.QApplication.translate("LayerTree", "Form", None))
         self.layerAddButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Load a new data set", None))
         self.newSubsetButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Create a new empty subset", None))
         self.layerRemoveButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Delete Layer", None))
         self.linkButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Link data", None))
     else:
         LayerTree.setWindowTitle(QtGui.QApplication.translate("LayerTree", "Form", None, QtGui.QApplication.UnicodeUTF8))
         self.layerAddButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Load a new data set", None, QtGui.QApplication.UnicodeUTF8))
         self.newSubsetButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Create a new empty subset", None, QtGui.QApplication.UnicodeUTF8))
         self.layerRemoveButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Delete Layer", None, QtGui.QApplication.UnicodeUTF8))
         self.linkButton.setToolTip(QtGui.QApplication.translate("LayerTree", "Link data", None, QtGui.QApplication.UnicodeUTF8))
コード例 #8
0
ファイル: _mpl_backend.py プロジェクト: rguter/glue
def set_mpl_backend():

    from matplotlib import rcParams, rcdefaults

    # standardize mpl setup
    rcdefaults()

    from glue.external.qt import is_pyqt5
    if is_pyqt5():
        rcParams['backend'] = 'Qt5Agg'
    else:
        rcParams['backend'] = 'Qt4Agg'

    # The following is a workaround for the fact that Matplotlib checks the
    # rcParams at import time, not at run-time. I have opened an issue with
    # Matplotlib here: https://github.com/matplotlib/matplotlib/issues/5513
    from matplotlib import get_backend
    from matplotlib import backends
    backends.backend = get_backend()
コード例 #9
0
 def invalidate(self):
     self.root = DataCollectionItem(self.data_collection)
     self._items.clear()
     if not is_pyqt5():
         self.reset()
     self.layoutChanged.emit()
コード例 #10
0
ファイル: mpl_widget.py プロジェクト: rguter/glue
#!/usr/bin/env python

from __future__ import absolute_import, division, print_function

from functools import wraps

import matplotlib
from matplotlib.figure import Figure

from glue.external.qt.QtCore import Qt
from glue.external.qt import QtGui, QtCore, is_pyqt5
from glue.utils import DeferredMethod

if is_pyqt5():
    from matplotlib.backends.backend_qt5 import FigureManagerQT as FigureManager
    from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
else:
    try:
        from matplotlib.backends.backend_qt4agg import FigureManagerQT as FigureManager
    except ImportError:  # mpl < 1.4
        from matplotlib.backends.backend_qt4agg import FigureManagerQTAgg as FigureManager
    from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas


def defer_draw(func):
    """
    Decorator that globally defers all MplCanvas draw requests until
    function exit.

    If an MplCanvas instance's draw method is invoked multiple times,
    it will only be called once after the wrapped function returns.
コード例 #11
0
ファイル: data_collection_model.py プロジェクト: robintw/glue
 def invalidate(self):
     self.root = DataCollectionItem(self.data_collection)
     self._items.clear()
     if not is_pyqt5():
         self.reset()
     self.layoutChanged.emit()
コード例 #12
0
ファイル: mpl_widget.py プロジェクト: crawfordsm/glue
#!/usr/bin/env python

from __future__ import absolute_import, division, print_function

from functools import wraps

import matplotlib
from matplotlib.figure import Figure

from glue.external.qt.QtCore import Qt
from glue.external.qt import QtGui, QtCore, is_pyqt5
from glue.utils import DeferredMethod
from glue.config import settings

if is_pyqt5():
    from matplotlib.backends.backend_qt5 import FigureManagerQT as FigureManager
    from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
else:
    try:
        from matplotlib.backends.backend_qt4agg import FigureManagerQT as FigureManager
    except ImportError:  # mpl < 1.4
        from matplotlib.backends.backend_qt4agg import FigureManagerQTAgg as FigureManager
    from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas


def defer_draw(func):
    """
    Decorator that globally defers all MplCanvas draw requests until
    function exit.

    If an MplCanvas instance's draw method is invoked multiple times,