How to use the pyface.qt.QtGui.QApplication 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 enthought / traits / traits / util / guisupport.py View on Github external
def get_app_qt4(*args, **kwargs):
    """Create a new qt4 app or return an existing one."""
    from pyface.qt import QtGui
    app = QtGui.QApplication.instance()
    if app is None:
        if not args:
            args = ([''],)
        app = QtGui.QApplication(*args, **kwargs)
    return app
github enthought / traitsui / traitsui / qt4 / extra / checkbox_renderer.py View on Github external
def sizeHint(self, option, index):
        """ Reimplemented to provide size hint based on a checkbox
        """
        box = QtGui.QStyleOptionButton()
        style = QtGui.QApplication.instance().style()
        return style.sizeFromContents(QtGui.QStyle.CT_CheckBox, box,
                                      QtCore.QSize(), None)
github enthought / pyface / pyface / ui / qt4 / gui.py View on Github external
# Save the instance.
        self._calls_mutex.lock()
        try:
            self._calls.append(self)
        finally:
            self._calls_mutex.unlock()

        # Move to the main GUI thread.
        self.moveToThread(QtGui.QApplication.instance().thread())

        # Post an event to be dispatched on the main GUI thread. Note that
        # we do not call QTimer.singleShot here, which would be simpler, because
        # that only works on QThreads. We want regular Python threads to work.
        event = QtCore.QEvent(self._pyface_event)
        QtGui.QApplication.postEvent(self, event)
github enthought / jigna / examples / person_example_web.py View on Github external
def main():
    def listener(obj, traitname, old, new):
        print obj, traitname, old, new

    fred  = Person(name='Fred', age=42)
    fred.on_trait_change(listener)
    def update_fred():
        fred.name = "Wilma"
        fred.age = 4

    app = QtGui.QApplication.instance() or QtGui.QApplication([])
    person_view.show(model=fred)
    do_after(2000, update_fred)
    app.exec_()
    print fred.name
    print fred.age
github enthought / pyface / pyface / ui / qt4 / gui.py View on Github external
def _busy_changed(self, new):
        """ The busy trait change handler. """

        if new:
            QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        else:
            QtGui.QApplication.restoreOverrideCursor()
github enthought / chaco / chaco / tools / toolbars / toolbar_buttons.py View on Github external
def _perform_qt(self):
        from pyface.qt import QtGui

        indices, values = self._get_data_from_plots()
        data_str = self._serialize_data(indices, values)

        QtGui.QApplication.clipboard().setText(data_str)
github NMGRL / pychron / pychron / core / ui / qt / tabular_editor.py View on Github external
def __init__(self, event):
        self.text = event.text().strip()
        mods = QtGui.QApplication.keyboardModifiers()
        self.shift = mods == QtCore.Qt.ShiftModifier
github enthought / pyface / pyface / ui / qt4 / console / console_widget.py View on Github external
elif key in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return):
            new_event = QtGui.QKeyEvent(
                QtCore.QEvent.KeyPress,
                QtCore.Qt.Key_PageDown,
                QtCore.Qt.NoModifier,
            )
            QtGui.QApplication.sendEvent(self._page_control, new_event)
            return True

        elif key == QtCore.Qt.Key_Backspace:
            new_event = QtGui.QKeyEvent(
                QtCore.QEvent.KeyPress,
                QtCore.Qt.Key_PageUp,
                QtCore.Qt.NoModifier,
            )
            QtGui.QApplication.sendEvent(self._page_control, new_event)
            return True

        return False
github enthought / pyface / pyface / ui / qt4 / tasks / split_editor_area_pane.py View on Github external
def mouseMoveEvent(self, event):
        """ Re-implemented to create a drag event when the mouse is moved for a
        sufficient distance while holding down mouse button.
        """
        # go into the drag logic only if a drag_obj is active
        if self.drag_obj:
            # is the left mouse button still pressed?
            if not event.buttons() == QtCore.Qt.LeftButton:
                pass
            # has the mouse been dragged for sufficient distance?
            elif (
                event.pos() - self.drag_obj.start_pos
            ).manhattanLength() < QtGui.QApplication.startDragDistance():
                pass
            # initiate drag
            else:
                drag = QtGui.QDrag(self.drag_obj.widget)
                mimedata = PyMimeData(data=self.drag_obj, pickle=False)
                drag.setPixmap(self.drag_obj.get_pixmap())
                drag.setHotSpot(self.drag_obj.get_hotspot())
                drag.setMimeData(mimedata)
                drag.exec_()
                self.drag_obj = None  # deactivate the drag_obj again
                return
        return super(DraggableTabBar, self).mouseMoveEvent(event)
github enthought / pyface / pyface / ui / qt4 / tasks / split_editor_area_pane.py View on Github external
def create(self, parent):
        """ Create and set the toolkit-specific control that represents the
            pane.
        """
        # Create and configure the Editor Area Widget.
        self.control = SplitAreaWidget(self, parent)
        self.active_tabwidget = self.control.tabwidget()
        self.drag_info = {}

        # handle application level focus changes
        QtGui.QApplication.instance().focusChanged.connect(self._focus_changed)

        # handle context menu events to display split/collapse actions
        em = self.task.window.application.get_service(BaseEventManager)
        em.connect(ContextMenuEvent, func=self.on_context_menu)

        # set key bindings
        self.set_key_bindings()