コード例 #1
0
    def check_checklist_mappings_tuple_value_change(self, style):
        check_list_editor_factory = CheckListEditor(
            values=[(1, "one"), (2, "two")],
            format_func=lambda t: t[1].upper(),
        )
        formatted_view = View(
            UItem(
                "value",
                editor=check_list_editor_factory,
                style=style,
            ))
        model = ListModel()

        with reraise_exceptions(), \
                self.setup_ui(model, formatted_view) as editor:

            # FIXME issue enthought/traitsui#841
            with self.assertRaises(AssertionError):
                self.assertEqual(editor.names, ["ONE", "TWO"])
            self.assertEqual(editor.names, ["one", "two"])

            check_list_editor_factory.values = [(2, "two"), (1, "one")]

            # FIXME issue enthought/traitsui#841
            with self.assertRaises(AssertionError):
                self.assertEqual(editor.names, ["TWO", "ONE"])
            self.assertEqual(editor.names, ["two", "one"])
コード例 #2
0
    def check_checklist_mappings_value_change(self, style):
        check_list_editor_factory = CheckListEditor(
            values=["one", "two"],
            format_func=lambda v: v.upper(),
        )
        formatted_view = View(
            UItem(
                "value",
                editor=check_list_editor_factory,
                style=style,
            ))
        model = ListModel()

        with reraise_exceptions(), \
                self.setup_ui(model, formatted_view) as editor:

            self.assertEqual(editor.names, ["ONE", "TWO"])

            check_list_editor_factory.values = ["two", "one"]

            self.assertEqual(editor.names, ["TWO", "ONE"])