You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Via @chenqi0805 and @ERAnderson - the ability to have a popup showing potential completions in an EnumEditor as the user types is useful when there are potentially a large number of completions:
This can be achieved in Qt with a handler which sets the completer mode on the control; but it would be nice to have this exposed as an option in the Editor.
The text was updated successfully, but these errors were encountered:
""" EnumEditor with auto drop down for completion - quick hack """
from pyface.qt import QtGui
from traits.api import HasTraits, Enum, List
from traitsui.api import Item, Group, View, EnumEditor, Handler
class QTEnumDropHandler(Handler):
def init(self, info):
for value_editor in info.ui._editors:
if value_editor.name == 'enum_value':
break
else:
ValueError("'enum_value' editor not found in search element")
control = value_editor.control
control.completer().setCompletionMode(
QtGui.QCompleter.CompletionMode.PopupCompletion)
return True
class EnumEditorDemo(HasTraits):
""" Defines the main EnumEditor demo class. """
# Define possible values for enum
name_list = List(['A-495', 'A-498', 'R-1226', 'TS-17', 'TS-18',
'Foo', 'frombicator_a', 'whitzlegidget', 'splatzleblock',
'frombicator_b', 'foozalator'])
# Define an Enum trait to view
enum_value = Enum(values='name_list')
def default_traits_view(self):
enum_group = Group(
Item('enum_value',
editor=EnumEditor(
name='name_list',
evaluate=True,
),
label='Drop down with completion'),
)
return View(
enum_group,
title='EnumEditor',
buttons=['OK'],
resizable=True,
handler=QTEnumDropHandler(),
)
# Create the demo:
demo = EnumEditorDemo()
# Run the demo (if invoked from the command line):
if __name__ == '__main__':
demo.configure_traits()
Via @chenqi0805 and @ERAnderson - the ability to have a popup showing potential completions in an EnumEditor as the user types is useful when there are potentially a large number of completions:
This can be achieved in Qt with a handler which sets the completer mode on the control; but it would be nice to have this exposed as an option in the
Editor
.The text was updated successfully, but these errors were encountered: