How to use the enaml.qt.QtGui function in enaml

To help you get started, we’ve selected a few enaml 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 MatthieuDartiailh / HQCMeas / hqc_meas / utils / widgets / qt_line_completer.py View on Github external
self._no_update = False
            
    #---------------------------------------------------------------------------
    #  Updates the editor when the object trait changes external to the editor:
    #---------------------------------------------------------------------------
    @observe('text')
    def update_widget (self, change):
        """ Updates the editor when the object trait changes externally to the
            editor.
        """
        if (not self._no_update) and self.get_widget() :
            self._no_update = True
            self.get_widget().setText(change['value'])
            self._no_update = False

class CompleterLineEdit(QtGui.QLineEdit):
    """
    """
    completionNeeded = QtCore.Signal(str)

    def __init__(self, parent, delimiters, entries, entries_updater):

        self.delimiters = delimiters

        super(CompleterLineEdit, self).__init__(parent)
        self.textChanged[str].connect(self.text_changed)
        self.completer = QtGui.QCompleter(self)
        self.completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.completer.setModel(QtGui.QStringListModel(entries,self.completer))
        
        self.completionNeeded.connect(self.completer.complete)
        self.completer.activated[str].connect(self.complete_text)
github inkcut / inkcut / src / inkcut / plugins / joystick / plugin.py View on Github external
Created on Jul 19, 2015

@author: jrm
'''
from atom.api import Instance,Int,observe
from enaml.qt import QtGui, QtCore
from inkcut.workbench.core.utils import Plugin
from inkcut.workbench.core.device import Device
from inkcut.workbench.ui.plugin import PlotBase
from inkcut.workbench.ui.widgets.plot_view import PainterPathPlotItem

class JoystickPlugin(Plugin,PlotBase):
    
    device = Instance(Device)
    rate = Int(10)
    path = Instance(QtGui.QPainterPath)
    
    def start(self):
        pass
    
    def _observe_device(self,change):
        self.device.init()
            
    @observe('device')
    def _view_changed(self,change):
        view_items = []
        t=QtGui.QTransform.fromScale(1,-1)
        
        self.path = QtGui.QPainterPath()#[#],QtGui.QPainterPath()]
        x,y,z = self.device.position
        r= max(10,self.device.blade_offset)#,self.device.blade_offset
        self.path.addEllipse(QtCore.QPointF(x,-y),r,r)
github MatthieuDartiailh / HQCMeas / hqc_meas / utils / widgets / qt_clipboard.py View on Github external
def _instance_getter(self):
        """ The instance getter.
        """
        md = PyMimeData.coerce(QtGui.QApplication.clipboard().mimeData())
        if md is None:
            return None

        return md.instance()
github MatthieuDartiailh / HQCMeas / hqc_meas / utils / widgets / qt_tree_widget.py View on Github external
def _get_brush(self, color):
        if isinstance(color, list) or isinstance(color, tuple):
            q_color = QtGui.QColor(*color)
        else:
            q_color = QtGui.QColor(color)
        return QtGui.QBrush(q_color)
github MatthieuDartiailh / HQCMeas / hqc_meas / utils / widgets / qt_tree_widget.py View on Github external
def _observe_selection(self, change):
        """ Handles the **selection** event.
        """
        selection = change['value']
        node_control = self._node_control
        try:
            tree = self.get_widget()
            if (not isinstance(selection, basestring) and
                    isinstance(selection, collections.Iterable)):

                item_selection = QtGui.QItemSelection()
                for sel in selection:
                    item = node_control._object_info(sel)[2]
                    idx = tree.indexFromItem(item)
                    item_selection.append(QtGui.QItemSelectionRange(idx))

                tree.selectionModel().select(item_selection,
                                             QtGui.QItemSelectionModel.ClearAndSelect)
            else:
                tree.setCurrentItem(node_control._object_info(selection)[2])
        except Exception:
            raise
github MatthieuDartiailh / HQCMeas / hqc_meas / utils / widgets / qt_tree_widget.py View on Github external
def _get_brush(self, color):
        if isinstance(color, list) or isinstance(color, tuple):
            q_color = QtGui.QColor(*color)
        else:
            q_color = QtGui.QColor(color)
        return QtGui.QBrush(q_color)
github MatthieuDartiailh / HQCMeas / hqc_meas / utils / widgets / qt_autoscroll_html.py View on Github external
def update_widget(self, change):
        """ Updates the editor when the object trait changes externally to the
            editor.
        """
        widget = self.get_widget()
        text = change['value']
        text = text.replace('\n', '<br>')
        if widget:
            widget.setHtml(text)
            widget.moveCursor(QtGui.QTextCursor.End)
github MatthieuDartiailh / HQCMeas / hqc_meas / utils / widgets / qt_tree_widget.py View on Github external
def _get_icon(self, node, obj, is_expanded=False):
        """ Returns the index of the specified object icon.
        """
        tree = self._tree
        if True:
            return QtGui.QIcon()

        icon_name = node.get_icon(obj, is_expanded)
        if isinstance(icon_name, basestring):
            icon = self.STD_ICON_MAP.get(icon_name)

            if icon is not None:
                return tree.style().standardIcon(icon)

            path = node.get_icon_path(obj)
            if isinstance(path, basestring):
                path = [path, node]
            else:
                path.append(node)
            # resource_manager.locate_image( icon_name, path )
            reference = None
            if reference is None:
github inkcut / inkcut / inkcut / job / models.py View on Github external
def _create_copy(self):
        """ Creates a copy of the original graphic applying the given 
        transforms 
        
        """
        bbox = self.path.boundingRect()

        # Create the base copy
        t = QtGui.QTransform()

        t.scale(
            self.scale[0] * (self.mirror[0] and -1 or 1),
            self.scale[1] * (self.mirror[1] and -1 or 1),
            )

        # Rotate about center
        if self.rotation != 0:
            c = bbox.center()
            t.translate(-c.x(), -c.y())
            t.rotate(self.rotation)
            t.translate(c.x(), c.y())

        # Apply transform
        path = self.path * t