How to use the pyface.qt.QtCore function in pyface

To help you get started, we’ve selected a few pyface examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ChileanVirtualObservatory / acalib / test / core / Visualizador de fits - Germán Ortega.py View on Github external
#l1=cube.wcs_limints(0)
#l2=cube.wcs_limits(1)
#l3=cube.wcs_limits(2)
#iw=cube.index_to_wcs((20,300,300))

############### Create the windows and add the container. ###############
#########################################################################
app = QtGui.QApplication.instance()
container = QtGui.QWidget()
container.setWindowTitle("Embedding Mayavi in a PyQt4 Application")
layout = QtGui.QGridLayout(container)

# Initialize the window and the main widgets.
label = QtGui.QLabel(container)
label.setText("Vista de volumen")
label.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
layout.addWidget(label, 0, 4)
mayavi_widget = MayaviQWidget()
layout.addWidget(mayavi_widget, 1, 2, 1, 5)
# Number of countours to show
contours = 10

label = QtGui.QLabel(container)
label.setText("Espectro de VEL")
label.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
layout.addWidget(label, 3, 0)
matplotlib_spectre = MatplotlibQWidget('spectre')
layout.addWidget(matplotlib_spectre, 4, 0, 7, 7)

label = QtGui.QLabel(container)
label.setText("Vista acumulada")
label.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
github enthought / pyface / pyface / ui / qt4 / init.py View on Github external
# Thanks for using Enthought open source!


import sys

from traits.trait_notifiers import set_ui_handler, ui_handler

from pyface.qt import QtCore, QtGui, qt_api
from pyface.base_toolkit import Toolkit
from .gui import GUI

if qt_api == "pyqt":
    # Check the version numbers are late enough.
    if QtCore.QT_VERSION < 0x040200:
        raise RuntimeError(
            "Need Qt v4.2 or higher, but got v%s" % QtCore.QT_VERSION_STR
        )

    if QtCore.PYQT_VERSION < 0x040100:
        raise RuntimeError(
            "Need PyQt v4.1 or higher, but got v%s" % QtCore.PYQT_VERSION_STR
        )

# It's possible that it has already been initialised.
_app = QtGui.QApplication.instance()

if _app is None:
    _app = QtGui.QApplication(sys.argv)


# create the toolkit object
toolkit_object = Toolkit("pyface", "qt4", "pyface.ui.qt4")
github enthought / traitsui / traitsui / qt4 / date_editor.py View on Github external
def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        self.control = QtGui.QCalendarWidget()

        if not self.factory.allow_future:
            self.control.setMaximumDate(QtCore.QDate.currentDate())

        signal = QtCore.SIGNAL('clicked(QDate)')
        QtCore.QObject.connect(self.control, signal, self.update_object)
github NMGRL / pychron / pychron / git_archive / diff_editor.py View on Github external
def _create_control(self, parent):
        ctrl = QDiffEdit(parent)
        QtCore.QObject.connect(ctrl.left,
                               QtCore.SIGNAL('textChanged()'), self.update_left_object)
        QtCore.QObject.connect(ctrl.right,
                               QtCore.SIGNAL('textChanged()'), self.update_right_object)

        return ctrl
github enthought / envisage / examples / plugins / tasks / ipython_kernel / python_editor.py View on Github external
return control

    def _on_dirty_changed(self, dirty):
        """ Called whenever a change is made to the dirty state of the
            document.
        """
        self.dirty = dirty

    def _on_text_changed(self):
        """ Called whenever a change is made to the text of the document.
        """
        self.changed = True


class PythonEditorEventFilter(QtCore.QObject):
    """ A thin wrapper around the advanced code widget to handle the
    key_pressed Event.
    """

    def __init__(self, editor, parent):
        super(PythonEditorEventFilter, self).__init__(parent)
        self.__editor = editor

    def eventFilter(self, obj, event):
        """ Reimplemented to trap key presses.
        """
        if (
            self.__editor.control
            and obj == self.__editor.control
            and event.type() == QtCore.QEvent.FocusOut
        ):
github enthought / traitsui / traitsui / qt4 / list_str_model.py View on Github external
if role == QtCore.Qt.DisplayRole and text == '':
                # FIXME: This is a hack to make empty strings editable.
                text = ' '
            return text

        elif role == QtCore.Qt.DecorationRole:
            if editor.is_auto_add(index):
                image = adapter.get_default_image(editor.object,
                                                  editor.name, index)
            else:
                image = adapter.get_image(editor.object, editor.name, index)
            image = editor.get_image(image)
            if image is not None:
                return image

        elif role == QtCore.Qt.BackgroundRole:
            if editor.is_auto_add(index):
                color = adapter.get_default_bg_color(
                    editor.object, editor.name)
            else:
                color = adapter.get_bg_color(editor.object, editor.name, index)
            if color is not None:
                if isinstance(color, SequenceTypes):
                    q_color = QtGui.QColor(*color)
                else:
                    q_color = QtGui.QColor(color)
                return QtGui.QBrush(q_color)

        elif role == QtCore.Qt.ForegroundRole:
            if editor.is_auto_add(index):
                color = adapter.get_default_text_color(editor.object,
                                                       editor.name)
github enthought / pyface / pyface / ui / qt4 / tasks / split_editor_area_pane.py View on Github external
next_seq = 'Ctrl+}'
            prev_seq = 'Ctrl+{'
        elif sys.platform.startswith('linux'):
            next_seq = 'Ctrl+PgDown'
            prev_seq = 'Ctrl+PgUp'
        else:
            next_seq = 'Alt+n'
            prev_seq = 'Alt+p'
        shortcut = QtGui.QShortcut(QtGui.QKeySequence(next_seq), self.control)
        shortcut.activated.connect(self._next_tab)
        shortcut = QtGui.QShortcut(QtGui.QKeySequence(prev_seq), self.control)
        shortcut.activated.connect(self._previous_tab)

        # Add shortcuts for switching to a specific tab.
        mod = 'Ctrl+' if sys.platform == 'darwin' else 'Alt+'
        mapper = QtCore.QSignalMapper(self.control)
        mapper.mapped.connect(self._activate_tab)
        for i in xrange(1, 10):
            sequence = QtGui.QKeySequence(mod + str(i))
            shortcut = QtGui.QShortcut(sequence, self.control)
            shortcut.activated.connect(mapper.map)
            mapper.setMapping(shortcut, i - 1)
github enthought / pyface / pyface / ui / qt4 / tasks / main_window_layout.py View on Github external
# Now we can recurse.
            for i, item in enumerate(layout.items):
                self.set_layout_for_area(
                    item,
                    q_dock_area,
                    _toplevel_added=True,
                    _toplevel_call=False,
                )

        else:
            raise MainWindowLayoutError("Unknown layout item %r" % layout)

        if is_qt4:
            # Remove the fixed sizes once Qt activates the layout.
            if _toplevel_call:
                QtCore.QTimer.singleShot(0, self._reset_fixed_sizes)
github enthought / pyface / pyface / ui / qt4 / mimedata.py View on Github external
""" Wrap a QMimeData or a python object to a PyMimeData.
        """
        # See if the data is already of the right type.  If it is then we know
        # we are in the same process.
        if isinstance(md, cls):
            return md

        if isinstance(md, PyMimeData):
            # if it is a PyMimeData, migrate all its data, subclasses should
            # override this method if it doesn't do thgs correctly for them
            data = md.instance()
            nmd = cls()
            nmd._local_instance = data
            for format in md.formats():
                nmd.setData(format, md.data(format))
        elif isinstance(md, QtCore.QMimeData):
            # if it is a QMimeData, migrate all its data
            nmd = cls()
            for format in md.formats():
                nmd.setData(format, md.data(format))
        else:
            # by default, try to pickle the coerced object
            pickle = True

            # See if the data is a list, if so check for any items which are
            # themselves of the right type.  If so, extract the instance and
            # track whether we should pickle.
            # XXX lists should suffice for now, but may want other containers
            if isinstance(md, list):
                pickle = not any(
                    item.hasFormat(cls.NOPICKLE_MIME_TYPE)
                    for item in md
github enthought / traitsui / traitsui / qt4 / range_editor.py View on Github external
try:
            fvalue_text = self._format % fvalue
            1 / (low <= fvalue <= high)
        except:
            fvalue_text = ''
            fvalue = low

        if high > low:
            ivalue = int((float(fvalue - low) / (high - low)) * 10000)
        else:
            ivalue = low

        # Lower limit label:
        self.control.label_lo = label_lo = QtGui.QLabel()
        label_lo.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        panel.addWidget(label_lo)

        # Lower limit button:
        self.control.button_lo = IconButton(QtGui.QStyle.SP_ArrowLeft,
                                            self.reduce_range)
        panel.addWidget(self.control.button_lo)

        # Slider:
        self.control.slider = slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        slider.setTracking(factory.auto_set)
        slider.setMinimum(0)
        slider.setMaximum(10000)
        slider.setPageStep(1000)
        slider.setSingleStep(100)
        slider.setValue(ivalue)
        QtCore.QObject.connect(slider, QtCore.SIGNAL('valueChanged(int)'),