本文整理汇总了Python中pyjamas.ui.ListBox.ListBox.addChangeLister方法的典型用法代码示例。如果您正苦于以下问题:Python ListBox.addChangeLister方法的具体用法?Python ListBox.addChangeLister怎么用?Python ListBox.addChangeLister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.ListBox.ListBox
的用法示例。
在下文中一共展示了ListBox.addChangeLister方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CustomEditor
# 需要导入模块: from pyjamas.ui.ListBox import ListBox [as 别名]
# 或者: from pyjamas.ui.ListBox.ListBox import addChangeLister [as 别名]
class CustomEditor(Editor):
""" Custom style of editor for instances. If selection among instances is
allowed, the editor displays a combo box listing instances that can be
selected. If the current instance is editable, the editor displays a panel
containing trait editors for all the instance's traits.
"""
# Background color when an item can be dropped on the editor:
ok_color = DropColor
# The orientation of the instance editor relative to the instance selector:
orientation = "vertical"
# Class constant:
extra = 0
# ---------------------------------------------------------------------------
# Trait definitions:
# ---------------------------------------------------------------------------
# List of InstanceChoiceItem objects used by the editor
items = Property
# The view to use for displaying the instance
view = AView
# ---------------------------------------------------------------------------
# Finishes initializing the editor by creating the underlying toolkit
# widget:
# ---------------------------------------------------------------------------
def init(self, parent):
""" Finishes initializing the editor by creating the underlying toolkit
widget.
"""
factory = self.factory
if factory.name != "":
self._object, self._name, self._value = self.parse_extended_name(factory.name)
# Create a panel to hold the object trait's view:
if factory.editable:
self.control = self._panel = parent = SimplePanel()
# Build the instance selector if needed:
selectable = factory.selectable
droppable = factory.droppable
items = self.items
for item in items:
droppable |= item.is_droppable()
selectable |= item.is_selectable()
if selectable:
self._object_cache = {}
item = self.item_for(self.value)
if item is not None:
self._object_cache[id(item)] = self.value
self._choice = ListBox()
self._choice.setVisibleItemCount(0)
self._choice.addChangeLister(getattr(self, "update_object"))
self.set_tooltip(self._choice)
if factory.name != "":
self._object.on_trait_change(self.rebuild_items, self._name, dispatch="ui")
self._object.on_trait_change(self.rebuild_items, self._name + "_items", dispatch="ui")
factory.on_trait_change(self.rebuild_items, "values", dispatch="ui")
factory.on_trait_change(self.rebuild_items, "values_items", dispatch="ui")
self.rebuild_items()
elif droppable:
self._choice = TextBox()
self._choice.setEnabled(False)
self.set_tooltip(self._choice)
# if droppable:
# self._choice.SetDropTarget( PythonDropTarget( self ) )
orientation = factory.orientation
if orientation is "default":
orientation = self.orientation
if (selectable or droppable) and factory.editable:
if orientation is "horizontal":
panel = HorizontalPanel()
else:
panel = VerticalPanel()
# layout = QtGui.QBoxLayout(orientation, parent)
# layout.setMargin(0)
# layout.addWidget(self._choice)
#
# if orientation == QtGui.QBoxLayout.TopToBottom:
# hline = QtGui.QFrame()
# hline.setFrameShape(QtGui.QFrame.HLine)
# hline.setFrameShadow(QtGui.QFrame.Sunken)
#
# layout.addWidget(hline)
#.........这里部分代码省略.........