def _check_pyface_backend(): """Check the currently selected Pyface backend. Returns ------- backend : str Name of the backend. result : 0 | 1 | 2 0: the backend has been tested and works. 1: the backend has not been tested. 2: the backend not been tested. Notes ----- See also http://docs.enthought.com/pyface/. """ try: from traitsui.toolkit import toolkit from traits.etsconfig.api import ETSConfig except ImportError: return None, 2 toolkit() backend = ETSConfig.toolkit if backend == 'qt4': status = 0 else: status = 1 return backend, status
def main(): """This starts up the mayavi2 application. """ global mayavi # Make sure '.' is in sys.path if '' not in sys.path: sys.path.insert(0, '') # Start the app. if OFFSCREEN: mayavi = MayaviOffscreen() else: from traits.etsconfig.api import ETSConfig # Check that we have a traits backend installed from traitsui.toolkit import toolkit toolkit() # This forces the selection of a toolkit. if ETSConfig.toolkit in ('null', ''): raise ImportError('''Could not import backend for traits ________________________________________________________________________________ Make sure that you have either the TraitsBackendWx or the TraitsBackendQt projects installed. If you installed Mayavi with easy_install, try easy_install <pkg_name>. easy_install Mayavi[app] will also work. If you performed a source checkout, be sure to run 'python setup.py install' in Traits, TraitsGUI, and the Traits backend of your choice. Also make sure that either wxPython or PyQT is installed. wxPython: http://www.wxpython.org/ PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro ''' ) mayavi = MayaviApp() mayavi.main(sys.argv[1:])
def main(): """This starts up the oricreate application. """ global bmcs # Make sure '.' is in sys.path if '' not in sys.path: sys.path.insert(0, '') # Start the app. from traits.etsconfig.api import ETSConfig # Check that we have a traits backend installed from traitsui.toolkit import toolkit toolkit() # This forces the selection of a toolkit. if ETSConfig.toolkit in ('null', ''): raise ImportError('''Could not import backend for traits ________________________________________________________________________________ Make sure that you have either the TraitsBackendWx or the TraitsBackendQt projects installed. If you installed Oricreate with easy_install, try easy_install <pkg_name>. easy_install Oricreate[app] will also work. If you performed a source checkout, be sure to run 'python setup.py install' in Traits, TraitsGUI, and the Traits backend of your choice. Also make sure that either wxPython or PyQT is installed. wxPython: http://www.wxpython.org/ PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro ''') from bmcs.pullout import run_pullout run_pullout()
def main(): """This starts up the oricreate application. """ global oricreate # Make sure '.' is in sys.path if '' not in sys.path: sys.path.insert(0, '') # Start the app. from traits.etsconfig.api import ETSConfig # Check that we have a traits backend installed from traitsui.toolkit import toolkit toolkit() # This forces the selection of a toolkit. if ETSConfig.toolkit in ('null', ''): raise ImportError('''Could not import backend for traits ________________________________________________________________________________ Make sure that you have either the TraitsBackendWx or the TraitsBackendQt projects installed. If you installed Oricreate with easy_install, try easy_install <pkg_name>. easy_install Oricreate[app] will also work. If you performed a source checkout, be sure to run 'python setup.py install' in Traits, TraitsGUI, and the Traits backend of your choice. Also make sure that either wxPython or PyQT is installed. wxPython: http://www.wxpython.org/ PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro ''' ) from main_window import MainWindow oricreate = MainWindow() oricreate.configure_traits()
def check_backend(): """ Check if either we are in test mode, or if there is a suitable traits backend installed. """ from traitsui.toolkit import toolkit from traits.etsconfig.api import ETSConfig from mayavi.tools.engine_manager import options toolkit() # This forces the selection of a toolkit. if (options.backend != "test" and options.offscreen != True) and ETSConfig.toolkit in ("null", ""): raise ImportError( """Could not import backend for traits _______________________________________________________________________________ Make sure that you have either the TraitsBackendWx or the TraitsBackendQt projects installed. If you installed Mayavi with easy_install, try easy_install <pkg_name>. easy_install Mayavi[app] will also work. If you performed a source checkout, be sure to run 'python setup.py install' in Traits, TraitsGUI, and the Traits backend of your choice. Also make sure that either wxPython or PyQT is installed. wxPython: http://www.wxpython.org/ PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro """ )
def ensure_destroyed(ui): """ Ensure the widget is destroyed in the event when test fails.""" try: yield finally: if ui.control is not None: toolkit().destroy_control(ui.control) with reraise_exceptions(): process_cascade_events()
def check_backend(): """ Check if either we are in test mode, or if there is a suitable traits backend installed. """ from traitsui.toolkit import toolkit from traits.etsconfig.api import ETSConfig from mayavi.tools.engine_manager import options toolkit() # This forces the selection of a toolkit. if (options.backend != 'test' and options.offscreen != True) and \ ETSConfig.toolkit in ('null', ''): raise ImportError, '''Could not import backend for traits
def main(): """This starts up the oricreate application. """ global mxn # Make sure '.' is in sys.path if '' not in sys.path: sys.path.insert(0, '') # Start the app. from traits.etsconfig.api import ETSConfig # Check that we have a traits backend installed from traitsui.toolkit import toolkit toolkit() # This forces the selection of a toolkit. if ETSConfig.toolkit in ('null', ''): raise ImportError('''Could not import backend for traits ________________________________________________________________________________ Make sure that you have either the TraitsBackendWx or the TraitsBackendQt projects installed. If you installed Oricreate with easy_install, try easy_install <pkg_name>. easy_install Oricreate[app] will also work. If you performed a source checkout, be sure to run 'python setup.py install' in Traits, TraitsGUI, and the Traits backend of your choice. Also make sure that either wxPython or PyQT is installed. wxPython: http://www.wxpython.org/ PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro ''' ) from mxn.view import \ MxNTreeView from mxn.use_cases import \ UseCaseContainer, UCParametricStudy mxn_ps = UCParametricStudy() mxn_ps.element_to_add = 'mxndiagram' mxn_ps.add_element = True mxn_ps.tree_node_list[-1].content.cs.matrix_cs.geo.height = 0.06 mxn_ps.tree_node_list[-1].node_name = 'Study #1 - height 6 cm' mxn_ps.add_element = True mxn_ps.tree_node_list[-1].linestyle = 'dashed' mxn_ps.tree_node_list[-1].content.cs.matrix_cs.geo.height = 0.07 mxn_ps.tree_node_list[-1].node_name = 'Study #2 - height 7 cm' ucc = UseCaseContainer() ucc.tree_node_list.append(mxn_ps) mxn_ps_view = MxNTreeView(root=ucc) mxn_ps_view.selected_node = mxn_ps mxn_ps_view.replot = True mxn_ps_view.configure_traits()
def main(): """This starts up the oricreate application. """ global mxn # Make sure '.' is in sys.path if '' not in sys.path: sys.path.insert(0, '') # Start the app. from traits.etsconfig.api import ETSConfig # Check that we have a traits backend installed from traitsui.toolkit import toolkit toolkit() # This forces the selection of a toolkit. if ETSConfig.toolkit in ('null', ''): raise ImportError('''Could not import backend for traits ________________________________________________________________________________ Make sure that you have either the TraitsBackendWx or the TraitsBackendQt projects installed. If you installed Oricreate with easy_install, try easy_install <pkg_name>. easy_install Oricreate[app] will also work. If you performed a source checkout, be sure to run 'python setup.py install' in Traits, TraitsGUI, and the Traits backend of your choice. Also make sure that either wxPython or PyQT is installed. wxPython: http://www.wxpython.org/ PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro ''') from mxn.view import \ MxNTreeView from mxn.use_cases import \ UseCaseContainer, UCParametricStudy mxn_ps = UCParametricStudy() mxn_ps.element_to_add = 'mxndiagram' mxn_ps.add_element = True mxn_ps.tree_node_list[-1].content.cs.matrix_cs.geo.height = 0.06 mxn_ps.tree_node_list[-1].node_name = 'Study #1 - height 6 cm' mxn_ps.add_element = True mxn_ps.tree_node_list[-1].linestyle = 'dashed' mxn_ps.tree_node_list[-1].content.cs.matrix_cs.geo.height = 0.07 mxn_ps.tree_node_list[-1].node_name = 'Study #2 - height 7 cm' ucc = UseCaseContainer() ucc.tree_node_list.append(mxn_ps) mxn_ps_view = MxNTreeView(root=ucc) mxn_ps_view.selected_node = mxn_ps mxn_ps_view.replot = True mxn_ps_view.configure_traits()
def check_backend(): """ Check if either we are in test mode, or if there is a suitable traits backend installed. """ from traitsui.toolkit import toolkit from traits.etsconfig.api import ETSConfig from mayavi.tools.engine_manager import options toolkit() # This forces the selection of a toolkit. if (options.backend != 'test' and not options.offscreen) and \ (ETSConfig.toolkit in ('null', '') and env_toolkit != 'null'): msg = '''Could not import backend for traitsui. Make sure you have a suitable UI toolkit like PyQt/PySide or wxPython installed.''' raise ImportError(msg)
def check_backend(): """ Check if either we are in test mode, or if there is a suitable traits backend installed. """ from traitsui.toolkit import toolkit from traits.etsconfig.api import ETSConfig from mayavi.tools.engine_manager import options toolkit() # This forces the selection of a toolkit. if (options.backend != 'test' and not options.offscreen) and \ ETSConfig.toolkit in ('null', ''): msg = '''Could not import backend for traitsui. Make sure you have a suitable UI toolkit like PyQt/PySide or wxPython installed.''' raise ImportError(msg)
def load_tests(loader, standard_tests, pattern): """Custom test loading function that enables test filtering using regex exclusion pattern. Parameters ---------- loader : unittest.TestLoader The instance of test loader standard_tests : unittest.TestSuite Tests that would be loaded by default from this module (no tests) pattern : str An inclusion pattern used to match test files (test*.py default) Returns ------- filtered_package_tests : unittest.TestSuite TestSuite representing all package tests that did not match specified exclusion pattern. """ from os.path import dirname from unittest import TestSuite from traits.etsconfig.api import ETSConfig from traitsui.tests._tools import filter_tests # Make sure the right toolkit is up and running before importing tests from traitsui.toolkit import toolkit toolkit() if ETSConfig.toolkit.startswith("qt"): exclusion_pattern = "wx" elif ETSConfig.toolkit == "wx": exclusion_pattern = "qt" else: exclusion_pattern = "(wx|qt)" this_dir = dirname(__file__) package_tests = loader.discover(start_dir=this_dir, pattern=pattern) if exclusion_pattern is None: return package_tests filtered_package_tests = TestSuite() for test_suite in package_tests: filtered_test_suite = filter_tests(test_suite, exclusion_pattern) filtered_package_tests.addTest(filtered_test_suite) return filtered_package_tests
def _get_pyface_backend(): """Check the currently selected Pyface backend. Returns ------- backend : str Name of the backend. result : 0 | 1 | 2 0: the backend has been tested and works. 1: the backend has not been tested. 2: the backend not been tested. Notes ----- See also http://docs.enthought.com/pyface/. """ from traitsui.toolkit import toolkit from traits.etsconfig.api import ETSConfig toolkit() return ETSConfig.toolkit
def _height_default(self): if self.volume is None: return 0 image = self.volume.image_resource(self.image_name) if image is None: self.width = 0 return 0 self.width, height = toolkit().image_size(image.create_image()) return height
def _height_default ( self ): if self.volume is None: return 0 image = self.volume.image_resource( self.image_name ) if image is None: self.width = 0 return 0 self.width, height = toolkit().image_size( image.create_image() ) return height
def check_backend(): """ Check if either we are in test mode, or if there is a suitable traits backend installed. """ from traitsui.toolkit import toolkit from traits.etsconfig.api import ETSConfig from mayavi.tools.engine_manager import options toolkit() # This forces the selection of a toolkit. if (options.backend != 'test' and options.offscreen != True) and \ ETSConfig.toolkit in ('null', ''): raise ImportError('''Could not import backend for traits _______________________________________________________________________________ Make sure that you have either the TraitsBackendWx or the TraitsBackendQt projects installed. If you installed Mayavi with easy_install, try easy_install <pkg_name>. easy_install Mayavi[app] will also work. If you performed a source checkout, be sure to run 'python setup.py install' in Traits, TraitsGUI, and the Traits backend of your choice. Also make sure that either wxPython or PyQT is installed. wxPython: http://www.wxpython.org/ PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro ''')
def _get_width(self): try: return str(toolkit().image_size(self._cur_image)[0]) + ' pixels' except: return '---'
def _get_height(self): try: return str(toolkit().image_size(self._cur_image)[1]) + ' pixels' except: return '---'
def _get_width ( self ): try: return str( toolkit().image_size( self._cur_image )[0] ) + ' pixels' except: return '---'
def _get_height ( self ): try: return str( toolkit().image_size( self._cur_image )[1] ) + ' pixels' except: return '---'