How to use pyface - 10 common examples

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 ChileanVirtualObservatory / acalib / test / core / Visualizador de fits - Germán Ortega.py View on Github external
def __init__(self, parent=None):
		QtGui.QWidget.__init__(self, parent)
		layout = QtGui.QVBoxLayout(self)
		layout.setContentsMargins(0,0,0,0)
		layout.setSpacing(0)
		self.visualization = MayaviVisualization()
		self.ui = self.visualization.edit_traits(parent=self,kind='subpanel').control
		layout.addWidget(self.ui)
		self.ui.setParent(self)
github enthought / mayavi / integrationtests / mayavi / common.py View on Github external
def run_standalone(self):
        from mayavi.core.engine import Engine
        from mayavi.plugins.script import Script
        from pyface.api import ApplicationWindow, GUI

        self.setup_logger()
        if self.offscreen:
            engine = Engine(scene_factory=off_screen_viewer)
        else:
            engine = Engine()
        engine.start()

        self.exception_info = None
        self.script = Script(engine=engine)
        self.gui = g = GUI()
        self.app_window = a = ApplicationWindow()
        a.open()
        a.show(False)
        g.invoke_later(self.run)
        g.start_event_loop()
        if self.exception_info is not None:
            type, value, tb = self.exception_info
            if sys.version_info[0] > 2:
                raise type(value).with_traceback(tb)
            else:
                raise type(value)
github ChileanVirtualObservatory / acalib / test / core / Visualizador de fits - Germán Ortega.py View on Github external
header_text.setText(str(header))
header_text.setReadOnly(True)
layout.addWidget(header_text, 1, 0, 1, 2)

# Buttons to change between a volume and a contour.
def change_volume_type(type):
	global volume_type
	if(type != volume_type):
		volume_type = type
		mayavi_widget.visualization.update_volume()
		mayavi_widget.visualization.create_wireframe()

volume_button = QtGui.QPushButton("Volumen", window)
volume_button.clicked.connect(lambda: change_volume_type('volume'))
layout.addWidget(volume_button, 2, 1)
contour_button = QtGui.QPushButton("Contorno", window)
contour_button.clicked.connect(lambda: change_volume_type('contour'))
layout.addWidget(contour_button, 3, 1)

# Function to update the number of contours.
def contours_text_change():
	global contours
	contours = int(contours_text.text())
	if(volume_type == 'contour'):
		mayavi_widget.visualization.update_volume()
		mayavi_widget.visualization.create_wireframe()
		
# Label for the contours number.
label = QtGui.QLabel(container)
label.setText("Contornos")
label.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
layout.addWidget(label, 3, 2)
github enthought / pyface / pyface / ui / qt4 / tasks / test_advanced_editor_area_pane.py View on Github external
parent : parent of the returned root
		"""
		# setup leftchild
		left = EditorAreaWidget(editor_area=AdvancedEditorAreaPane(), parent=None)
		btn0 = QtGui.QPushButton('btn0')
		btn1 = QtGui.QPushButton('btn1')
		tabwidget = left.tabwidget()
		tabwidget.addTab(btn0, '0')
		tabwidget.addTab(btn1, '1')
		tabwidget.setCurrentIndex(1)
		
		# setup rightchild
		right = EditorAreaWidget(editor_area=left.editor_area, parent=None)
		btn2 = QtGui.QPushButton('btn2')
		btn3 = QtGui.QPushButton('btn3')
		tabwidget = right.tabwidget()
		tabwidget.addTab(btn2, '2')
		tabwidget.addTab(btn3, '3')
		tabwidget.setCurrentIndex(0)
		
		# setup root
		root = EditorAreaWidget(editor_area=left.editor_area, parent=parent)
		tabwidget = root.tabwidget()
		tabwidget.setParent(None)
		root.addWidget(left)
		root.addWidget(right)
		root.leftchild = left
		root.rightchild = right

		return root, left, right
github enthought / pyface / pyface / ui / qt4 / tasks / test_advanced_editor_area_pane.py View on Github external
def _setUp_collapse(self, parent=None):
		""" Creates a root, its leftchild and rightchild, so that collapse can be tested on
		one of the children.

		Returns the root, leftchild and rightchild of such layout.

		parent : parent of the returned root
		"""
		# setup leftchild
		left = EditorAreaWidget(editor_area=AdvancedEditorAreaPane(), parent=None)
		btn0 = QtGui.QPushButton('btn0')
		btn1 = QtGui.QPushButton('btn1')
		tabwidget = left.tabwidget()
		tabwidget.addTab(btn0, '0')
		tabwidget.addTab(btn1, '1')
		tabwidget.setCurrentIndex(1)
		
		# setup rightchild
		right = EditorAreaWidget(editor_area=left.editor_area, parent=None)
		btn2 = QtGui.QPushButton('btn2')
		btn3 = QtGui.QPushButton('btn3')
		tabwidget = right.tabwidget()
		tabwidget.addTab(btn2, '2')
		tabwidget.addTab(btn3, '3')
		tabwidget.setCurrentIndex(0)
		
		# setup root
		root = EditorAreaWidget(editor_area=left.editor_area, parent=parent)
github enthought / pyface / pyface / ui / qt4 / tasks / test_advanced_editor_area_pane.py View on Github external
Returns the root, leftchild and rightchild of such layout.

		parent : parent of the returned root
		"""
		# setup leftchild
		left = EditorAreaWidget(editor_area=AdvancedEditorAreaPane(), parent=None)
		btn0 = QtGui.QPushButton('btn0')
		btn1 = QtGui.QPushButton('btn1')
		tabwidget = left.tabwidget()
		tabwidget.addTab(btn0, '0')
		tabwidget.addTab(btn1, '1')
		tabwidget.setCurrentIndex(1)
		
		# setup rightchild
		right = EditorAreaWidget(editor_area=left.editor_area, parent=None)
		btn2 = QtGui.QPushButton('btn2')
		btn3 = QtGui.QPushButton('btn3')
		tabwidget = right.tabwidget()
		tabwidget.addTab(btn2, '2')
		tabwidget.addTab(btn3, '3')
		tabwidget.setCurrentIndex(0)
		
		# setup root
		root = EditorAreaWidget(editor_area=left.editor_area, parent=parent)
		tabwidget = root.tabwidget()
		tabwidget.setParent(None)
		root.addWidget(left)
		root.addWidget(right)
		root.leftchild = left
		root.rightchild = right

		return root, left, right
github aestrivex / cvu / cvu / custom_file_editor.py View on Github external
def qt4_editor_factory(parent, editor, use_dir=False, *args):
    from pyface.qt import QtCore, QtGui
    from traitsui.qt4.helper import IconButton

    editor.control = panel =  QtGui.QWidget()
    layout = QtGui.QHBoxLayout( panel )
    layout.setContentsMargins(0,0,0,0)

    editor.use_dir = use_dir

    editor.text_control = text_control = QtGui.QLineEdit()
    layout.addWidget(text_control)
    signal = QtCore.SIGNAL('editingFinished()')
    QtCore.QObject.connect(text_control, signal, lambda:update_file_obj(editor))

    button = IconButton(QtGui.QStyle.SP_DirIcon, lambda:button_click(editor))
    layout.addWidget(button)

    return panel
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)