本文整理汇总了Python中pyface.api.GUI.process_events方法的典型用法代码示例。如果您正苦于以下问题:Python GUI.process_events方法的具体用法?Python GUI.process_events怎么用?Python GUI.process_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyface.api.GUI
的用法示例。
在下文中一共展示了GUI.process_events方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_coreg_gui
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def test_coreg_gui():
"""Test CoregFrame."""
_check_ci()
home_dir = _TempDir()
os.environ['_MNE_GUI_TESTING_MODE'] = 'true'
os.environ['_MNE_FAKE_HOME_DIR'] = home_dir
try:
assert_raises(ValueError, mne.gui.coregistration, subject='Elvis',
subjects_dir=subjects_dir)
from pyface.api import GUI
gui = GUI()
# avoid modal dialog if SUBJECTS_DIR is set to a directory that
# does not contain valid subjects
ui, frame = mne.gui.coregistration(subjects_dir='')
frame.model.mri.subjects_dir = subjects_dir
frame.model.mri.subject = 'sample'
assert_false(frame.model.mri.fid_ok)
frame.model.mri.lpa = [[-0.06, 0, 0]]
frame.model.mri.nasion = [[0, 0.05, 0]]
frame.model.mri.rpa = [[0.08, 0, 0]]
assert_true(frame.model.mri.fid_ok)
frame.raw_src.file = raw_path
# grow hair (high-res head has no norms)
assert_true(frame.model.mri.use_high_res_head)
frame.model.mri.use_high_res_head = False
frame.model.grow_hair = 40.
# scale
frame.coreg_panel.n_scale_params = 3
frame.coreg_panel.scale_x_inc = True
assert_equal(frame.model.scale_x, 1.01)
frame.coreg_panel.scale_y_dec = True
assert_equal(frame.model.scale_y, 0.99)
# reset parameters
frame.coreg_panel.reset_params = True
assert_equal(frame.model.grow_hair, 0)
assert_false(frame.model.mri.use_high_res_head)
# configuration persistence
assert_true(frame.model.prepare_bem_model)
frame.model.prepare_bem_model = False
frame.save_config(home_dir)
ui.dispose()
gui.process_events()
ui, frame = mne.gui.coregistration(subjects_dir=subjects_dir)
assert_false(frame.model.prepare_bem_model)
assert_false(frame.model.mri.use_high_res_head)
ui.dispose()
gui.process_events()
finally:
del os.environ['_MNE_GUI_TESTING_MODE']
del os.environ['_MNE_FAKE_HOME_DIR']
示例2: set_view
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def set_view(self, s):
"""Sets the view correctly."""
#s.scene.reset_zoom()
s.scene.z_plus_view()
c = s.scene.camera
c.azimuth(30)
c.elevation(30)
s.render()
GUI.process_events()
示例3: force_draw
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def force_draw(self):
r"""
Method for forcing the current figure to render. This is useful for
the widgets animation.
"""
from pyface.api import GUI
_gui = GUI()
orig_val = _gui.busy
_gui.set_busy(busy=True)
_gui.set_busy(busy=orig_val)
_gui.process_events()
示例4: force_render
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def force_render( figure=None ):
from mayavi import mlab
figure.scene.render()
mlab.draw(figure=figure)
from pyface.api import GUI
_gui = GUI()
orig_val = _gui.busy
_gui.set_busy(busy=True)
_gui.process_events()
_gui.set_busy(busy=orig_val)
_gui.process_events()
示例5: close_scene
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def close_scene(self, scene):
"""Given a VTK scene instance, this method closes it.
"""
active_window = self.window
s = scene.scene
for editor in active_window.editors[:]:
if isinstance(editor, scene_editor.SceneEditor):
if id(editor.scene) == id(s):
editor.close()
break
# Flush the UI.
GUI.process_events()
示例6: new_scene
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def new_scene(self):
"""Creates a new TVTK scene, sets its size to that prescribed
and returns the scene.
"""
script = self.script
# Create a new VTK scene.
script.new_scene()
# Set its background.
if self.standalone:
GUI.process_events()
s = script.engine.current_scene
s.scene.background = (0.5, 0.5, 0.5)
return s
示例7: new_scene
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def new_scene(self, viewer=None, name=None, **kwargs):
""" Creates a new VTK scene window.
For the time being the extra kwargs are ignored with the
envisage engine.
"""
action = NewScene(window=self.window)
editor = action.perform(None)
if name is not None:
editor.name = name
# Flush the UI.
GUI.process_events()
return self.scenes[-1]
示例8: compare_image_raw
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def compare_image_raw(renwin, img_fname, threshold=10, allow_resize=True):
"""Compares renwin's (a tvtk.RenderWindow) contents with the image
file whose name is given in the second argument. If the image
file does not exist the image is generated and stored. If not the
image in the render window is compared to that of the figure.
This function also handles multiple images and finds the best
matching image. If `allow_resize` is True then the images are
rescaled if they are not of the same size.
"""
# If this is not done the window may not be parented correctly.
GUI.process_events()
w2if = tvtk.WindowToImageFilter(read_front_buffer=False, input=renwin)
w2if.update()
return compare_image_with_saved_image(w2if.output, img_fname,
threshold, allow_resize)
示例9: run
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def run(self):
"""This starts everything up and runs the test. Call main to
run the test."""
# Calls the users test code.
try:
if self.profile:
memory_assistant = MemoryAssistant()
memory_assistant.assertReturnsMemory(self.do_profile,
slack = 1.0)
else:
self.do()
except Exception as e:
type, value, tb = sys.exc_info()
if is_running_with_nose():
self.exception_info = type, value, tb
else:
# To mimic behavior of unittest.
sys.stderr.write('\nfailures=1\n')
info = traceback.extract_tb(tb)
filename, lineno, function, text = info[-1] # last line only
exc_msg = "%s\nIn %s:%d\n%s: %s (in %s)" %\
('Exception', filename, lineno, type.__name__, str(value),
function)
sys.stderr.write(exc_msg + '\n')
# Log the message.
logger.exception(exc_msg)
if not self.interact:
sys.exit(1)
finally:
if not self.interact:
if self.standalone:
# Close all existing viewers.
e = self.script.engine
for scene in e.scenes:
viewer = e.get_viewer(scene)
if viewer is not None:
if self.offscreen:
viewer.scene.close()
else:
viewer.close()
GUI.process_events()
# Shut down the app and the event loop.
self.app_window.close()
self.gui.stop_event_loop()
else:
self.application.gui.invoke_later(self.application.exit)
示例10: run_mlab_examples
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def run_mlab_examples():
from mayavi import mlab
from mayavi.tools.animator import Animator
############################################################
# run all the "test_foobar" functions in the mlab module.
for name, func in getmembers(mlab):
if not callable(func) or not name[:4] in ('test', 'Test'):
continue
if sys.platform == 'win32' and name == 'test_mesh_mask_custom_colors':
# fixme: This test does not seem to work on win32, disabling for now.
continue
mlab.clf()
GUI.process_events()
obj = func()
if isinstance(obj, Animator):
obj.delay = 10
# Close the animation window.
obj.close()
while is_timer_running(obj.timer):
GUI.process_events()
sleep(0.05)
# Mayavi has become too fast: the operator cannot see if the
# Test function was succesful.
GUI.process_events()
sleep(0.1)
示例11: test_kit2fiff_gui
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def test_kit2fiff_gui():
"""Test Kit2Fiff GUI."""
_check_ci()
home_dir = _TempDir()
os.environ['_MNE_GUI_TESTING_MODE'] = 'true'
os.environ['_MNE_FAKE_HOME_DIR'] = home_dir
try:
from pyface.api import GUI
gui = GUI()
gui.process_events()
ui, frame = mne.gui.kit2fiff()
assert_false(frame.model.can_save)
assert_equal(frame.model.stim_threshold, 1.)
frame.model.stim_threshold = 10.
frame.model.stim_chs = 'save this!'
frame.save_config(home_dir)
ui.dispose()
gui.process_events()
# test setting persistence
ui, frame = mne.gui.kit2fiff()
assert_equal(frame.model.stim_threshold, 10.)
assert_equal(frame.model.stim_chs, 'save this!')
frame.model.markers.mrk1.file = mrk_pre_path
frame.marker_panel.mrk1_obj.label = True
frame.marker_panel.mrk1_obj.label = False
ui.dispose()
gui.process_events()
finally:
del os.environ['_MNE_GUI_TESTING_MODE']
del os.environ['_MNE_FAKE_HOME_DIR']
示例12: test_kit2fiff_gui
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def test_kit2fiff_gui():
"""Test Kit2Fiff GUI."""
_check_ci()
home_dir = _TempDir()
os.environ['_MNE_GUI_TESTING_MODE'] = 'true'
os.environ['_MNE_FAKE_HOME_DIR'] = home_dir
try:
from pyface.api import GUI
gui = GUI()
gui.process_events()
ui, frame = mne.gui.kit2fiff()
assert not frame.model.can_save
assert frame.model.stim_threshold == 1.
frame.model.stim_threshold = 10.
frame.model.stim_chs = 'save this!'
frame.save_config(home_dir)
ui.dispose()
gui.process_events()
# test setting persistence
ui, frame = mne.gui.kit2fiff()
assert frame.model.stim_threshold == 10.
assert frame.model.stim_chs == 'save this!'
# set and reset marker file
points = [[-0.084612, 0.021582, -0.056144],
[0.080425, 0.021995, -0.061171],
[-0.000787, 0.105530, 0.014168],
[-0.047943, 0.091835, 0.010240],
[0.042976, 0.094380, 0.010807]]
assert_array_equal(frame.marker_panel.mrk1_obj.points, 0)
assert_array_equal(frame.marker_panel.mrk3_obj.points, 0)
frame.model.markers.mrk1.file = mrk_pre_path
assert_allclose(frame.marker_panel.mrk1_obj.points, points, atol=1e-6)
assert_allclose(frame.marker_panel.mrk3_obj.points, points, atol=1e-6)
frame.marker_panel.mrk1_obj.label = True
frame.marker_panel.mrk1_obj.label = False
frame.kit2fiff_panel.clear_all = True
assert_array_equal(frame.marker_panel.mrk1_obj.points, 0)
assert_array_equal(frame.marker_panel.mrk3_obj.points, 0)
ui.dispose()
gui.process_events()
finally:
del os.environ['_MNE_GUI_TESTING_MODE']
del os.environ['_MNE_FAKE_HOME_DIR']
示例13: do
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def do(self):
############################################################
# Imports.
script = self.script
from mayavi.sources.array_source import ArraySource
from mayavi.modules.outline import Outline
from mayavi.modules.image_plane_widget import ImagePlaneWidget
############################################################
# Create a new scene and set up the visualization.
s = self.new_scene()
d = ArraySource()
sc = self.make_data()
d.scalar_data = sc
script.add_source(d)
# Create an outline for the data.
o = Outline()
script.add_module(o)
# ImagePlaneWidgets for the scalars
ipw = ImagePlaneWidget()
script.add_module(ipw)
ipw_y = ImagePlaneWidget()
script.add_module(ipw_y)
ipw_y.ipw.plane_orientation = 'y_axes'
ipw_z = ImagePlaneWidget()
script.add_module(ipw_z)
ipw_z.ipw.plane_orientation = 'z_axes'
# Set the scene to a suitable view.
self.set_view(s)
self.check()
############################################################
# Test if saving a visualization and restoring it works.
# Save visualization.
f = BytesIO()
f.name = abspath('test.mv2') # We simulate a file.
script.save_visualization(f)
f.seek(0) # So we can read this saved data.
# Remove existing scene.
engine = script.engine
engine.close_scene(s)
# Load visualization
script.load_visualization(f)
s = engine.current_scene
# Set the scene to a suitable view.
self.set_view(s)
GUI.process_events()
self.check()
############################################################
# Test if the MayaVi2 visualization can be deepcopied.
# Pop the source object.
sources = s.children
s.children = []
# Add it back to see if that works without error.
s.children.extend(sources)
self.set_view(s)
GUI.process_events()
self.check()
# Now deepcopy the source and replace the existing one with
# the copy. This basically simulates cutting/copying the
# object from the UI via the right-click menu on the tree
# view, and pasting the copy back.
sources1 = copy.deepcopy(sources)
s.children[:] = sources
self.set_view(s)
GUI.process_events()
self.check()
示例14: parse_command_line
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
logger.exception(exc_msg)
if not self.interact:
sys.exit(1)
finally:
if not self.interact:
if self.standalone:
# Close all existing viewers.
e = self.script.engine
for scene in e.scenes:
viewer = e.get_viewer(scene)
if viewer is not None:
if self.offscreen:
viewer.scene.close()
else:
viewer.close()
GUI.process_events()
# Shut down the app and the event loop.
self.app_window.close()
self.gui.stop_event_loop()
else:
self.application.gui.invoke_later(self.application.exit)
def parse_command_line(self, argv):
"""Parse command line options."""
usage = "usage: %prog [options]"
parser = OptionParser(usage)
parser.add_option("-v", "--verbose", action="store_true",
dest="verbose", help="Print verbose output")
parser.add_option("-i", "--interact", action="store_true",
dest="interact", default=False,
help="Allow interaction after test (default: False)")
示例15: do
# 需要导入模块: from pyface.api import GUI [as 别名]
# 或者: from pyface.api.GUI import process_events [as 别名]
def do(self):
############################################################
# Imports.
from mayavi.modules.api import ScalarCutPlane
from mayavi.modules.labels import Labels
from mayavi.sources.vtk_xml_file_reader import VTKXMLFileReader
############################################################
# Create a new scene and set up the visualization.
s = self.new_scene()
script = mayavi = self.script
# Read a VTK (old style) data file.
r = VTKXMLFileReader()
r.initialize(get_example_data('fire_ug.vtu'))
script.add_source(r)
# Create the filters.
cp = ScalarCutPlane()
script.add_module(cp)
l = Labels(object=cp)
script.add_module(l)
s.scene.isometric_view()
GUI.process_events()
self.check(saved=False)
############################################################
# Test if saving a visualization and restoring it works.
# Save visualization.
f = BytesIO()
f.name = abspath('test.mv2') # We simulate a file.
script.save_visualization(f)
f.seek(0)
# Remove existing scene.
engine = script.engine
engine.close_scene(s)
# Load visualization
script.load_visualization(f)
s = engine.current_scene
s.scene.isometric_view()
# Seems to be needed for the test to pass. :( Just flushes the
# pipeline.
s.children[0].pipeline_changed = True
GUI.process_events()
# Check.
# Now do the check.
self.check(saved=True)
############################################################
# Test if the Mayavi2 visualization can be deep-copied.
# Pop the source object.
source = s.children.pop()
# Add it back to see if that works without error.
s.children.append(source)
GUI.process_events()
# Now do the check.
s.scene.isometric_view()
self.check(saved=True)
# Now deepcopy the source and replace the existing one with
# the copy. This basically simulates cutting/copying the
# object from the UI via the right-click menu on the tree
# view, and pasting the copy back.
source1 = copy.deepcopy(source)
s.children[0] = source1
GUI.process_events()
# Now do the check.
s.scene.isometric_view()
self.check(saved=True)
GUI.process_events()