def _get_custom_editor_class(self): """Creates a custom style of range editor The type of editor depends on the type and extent of the range being edited: * One end of range is unspecified: RangeTextEditor * **mode** is specified and not 'auto': editor corresponding to **mode** * Floating point range: Same as "simple" style * Integer range with extent > 15: Same as "simple" style * Integer range with extent <= 15: CustomEnumEditor """ low, high, is_float = self._low_value, self._high_value, self.is_float if (low is None) or (high is None): return toolkit_object("range_editor:RangeTextEditor") if self.mode != "auto": return toolkit_object("range_editor:CustomEditorMap")[self.mode] if is_float or (abs(high - low) > 15): return self.simple_editor_class return toolkit_object("range_editor:CustomEnumEditor")
def __init__(self, **traits): super(ProgressColumn, self).__init__(**traits) from traitsui.toolkit import toolkit_object ProgressRenderer = toolkit_object( 'extra.progress_renderer:ProgressRenderer') self.renderer = ProgressRenderer()
def _get_custom_editor_class(self): """ Returns the editor class to use for "custom" style views. Overridden to return the editor class for the specified mode. """ editor_file_name = os.path.basename( sys.modules[self.__class__.__module__].__file__) try: if self.mode == "radio": return toolkit_object( editor_file_name.split(".")[0] + ":RadioEditor", raise_exceptions=True, ) else: return toolkit_object( editor_file_name.split(".")[0] + ":ListEditor", raise_exceptions=True, ) except: return super()._get_custom_editor_class()
def __init__(self, **traits): """ Initializes the object. """ super(EditColumn, self).__init__(**traits) from traitsui.toolkit import toolkit_object EditRenderer = toolkit_object('extra.edit_renderer:EditRenderer') self.renderer = EditRenderer() self.label = ""
def _get_simple_editor_class(self): """Returns the editor class to use for "simple" style views. The default implementation tries to import the SimpleEditor class in the editor file in the backend package, and if such a class is not to found it returns the SimpleEditor class defined in editor_factory module in the backend package. """ SimpleEditor = toolkit_object("title_editor:SimpleEditor") return SimpleEditor
def _get_simple_editor_class(self): """Returns the editor class to use for a simple style. The type of editor depends on the type and extent of the range being edited: * One end of range is unspecified: RangeTextEditor * **mode** is specified and not 'auto': editor corresponding to **mode** * Floating point range with extent > 100: LargeRangeSliderEditor * Integer range or floating point range with extent <= 100: SimpleSliderEditor * All other cases: SimpleSpinEditor """ low, high, is_float = self._low_value, self._high_value, self.is_float if (low is None) or (high is None): return toolkit_object("range_editor:RangeTextEditor") if (not is_float) and (abs(high - low) > 1000000000): return toolkit_object("range_editor:RangeTextEditor") if self.mode != "auto": return toolkit_object("range_editor:SimpleEditorMap")[self.mode] if is_float and (abs(high - low) > 100): return toolkit_object("range_editor:LargeRangeSliderEditor") if is_float or (abs(high - low) <= 100): return toolkit_object("range_editor:SimpleSliderEditor") return toolkit_object("range_editor:SimpleSpinEditor")
def ColorEditor(*args, **traits): r"""Returns an instance of the toolkit-specific editor factory declared in traitsui.<toolkit>.color_editor. If such an editor factory cannot be located, an instance of the abstract ToolkitEditorFactory declared in traitsui.editors.color_editor is returned. Parameters ---------- \*args, \*\*traits arguments and keywords to be passed on to the editor factory's constructor. """ try: return toolkit_object("color_editor:ToolkitEditorFactory", True)(*args, **traits) except: return ToolkitEditorFactory(*args, **traits)
def _get_custom_editor_class(self): if self.use_notebook: return toolkit_object("list_editor:NotebookEditor") return toolkit_object("list_editor:CustomEditor")
def _get_klass(self): """ The class used to construct editor objects. """ return toolkit_object("popup_editor:_PopupEditor")
def history_editor(*args, **traits): return toolkit_object("history_editor:_HistoryEditor")(*args, **traits)
# All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in LICENSE.txt and may be redistributed only under # the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! """ An instance editor that allows total control over widget creation. """ # Enthought library imports. from traits.api import Any from traitsui.api import EditorFactory from traitsui.toolkit import toolkit_object Editor = toolkit_object('editor:Editor') class _WidgetEditor(Editor): """ An instance editor that allows total control over widget creation. """ #### '_WidgetEditor' interface ############################################ # The toolkit-specific parent of the editor. parent = Any ########################################################################### # '_WidgetEditor' interface. ########################################################################### def init(self, parent):
def _get_klass(self): """Returns the editor class to be created.""" return toolkit_object("list_str_editor:_ListStrEditor")
def key_binding_editor(*args, **traits): return toolkit_object("key_binding_editor:KeyBindingEditor")(*args, **traits)
def _get_font(self): if isinstance(self._fonts, toolkit_object('font_trait:TraitsFont')): return self._fonts else: return self._fonts.get(self.column_id, 'Courier 10')
def _get_klass(self): """ The class used to construct editor objects. """ return toolkit_object('data_frame_editor:_DataFrameEditor')
def _get_klass(self): """Returns the toolkit-specific editor class to be instantiated.""" return toolkit_object("search_editor:SearchEditor")
def _get_klass(self): """ Returns the editor class to be instantiated. """ return toolkit_object('video_editor:VideoEditor')
def _get_text_editor_class(self): """Returns the editor class to use for a text style.""" return toolkit_object("range_editor:RangeTextEditor")
""" # Enthought library imports from traits.etsconfig.api import ETSConfig from enable.api import black_color_trait, LineStyle, ColorTrait,\ white_color_trait, MarkerTrait, Window from enable.trait_defs.ui.api import RGBAColorEditor from kiva.trait_defs.kiva_font_trait import KivaFont from traits.api import Enum, Str, Range, Tuple, \ Bool, Trait, Int, Any, Property from traitsui.api import Item from traitsui.editor_factory import EditorFactory # Toolkit dependent imports from traitsui.toolkit import toolkit_object Editor = toolkit_object('editor:Editor') # Local relative imports from axis import PlotAxis from plot_containers import OverlayPlotContainer from plot_factory import create_line_plot, create_scatter_plot, \ add_default_grids, add_default_axes from plot_label import PlotLabel # Somewhat unorthodox... from chaco.tools.api import PanTool, ZoomTool #------------------------------------------------------------------------------- # Trait definitions: #-------------------------------------------------------------------------------
def _get_klass(self): """Returns the toolkit-specific editor class to be instantiated.""" return toolkit_object("tabular_editor:TabularEditor")
def _get_klass(self): """ Returns the editor class to be created. """ return toolkit_object("custom_editor:CustomEditor")
@requires_toolkit([ToolkitName.qt, ToolkitName.wx]) def test_invalid_state(self): # Regression test for enthought/traitsui#983 obj = MaybeInvalidTrait(name="Name long enough to be valid") with create_ui(obj) as ui: editor, = ui.get_editors("name") self.assertFalse(editor.invalid) obj.name = "too short" self.assertTrue(editor.invalid) # Regression test on an AttributeError commonly seen (enthought/traitsui#1145) # Code in ui_panel makes use toolkit specific attributes on the toolkit # specific Editor ToolkitSpecificEditor = toolkit_object("editor:Editor") class DummyObject(HasTraits): number = Int() if is_qt(): from pyface.qt import QtGui, QtCore class CustomWidget(QtGui.QWidget): def __init__(self, editor, parent=None): super(CustomWidget, self).__init__() self._some_editor = editor
def _get_klass(self): """ Returns the toolkit-specific editor class to be used in the UI. """ return toolkit_object("shell_editor:_ShellEditor")
def null_editor(*args, **traits): return toolkit_object("null_editor:NullEditor")(*args, **traits)
def html_editor(*args, **traits): return toolkit_object("html_editor:SimpleEditor")(*args, **traits)
def _get_klass(self): """Returns the toolkit-specific editor class to be instantiated.""" return toolkit_object("scrubber_editor:_ScrubberEditor")
# Import the toolkit specific version. from __future__ import absolute_import from traitsui.toolkit import toolkit_object # WIP: Currently only supports qt4 backend. API might change without # prior notification PyMimeData = toolkit_object('clipboard:PyMimeData')
# (C) Copyright 2004-2021 Enthought, Inc., Austin, TX # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in LICENSE.txt and may be redistributed only under # the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # Import the toolkit specific version. from traitsui.toolkit import toolkit_object # WIP: Currently only supports qt4 backend. API might change without # prior notification PyMimeData = toolkit_object("clipboard:PyMimeData")
def _get_klass(self): """ Returns the editor class to be instantiated. """ return toolkit_object("image_editor:_ImageEditor")