本文整理汇总了Python中Orange.widgets.settings.SettingsHandler.bind方法的典型用法代码示例。如果您正苦于以下问题:Python SettingsHandler.bind方法的具体用法?Python SettingsHandler.bind怎么用?Python SettingsHandler.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.widgets.settings.SettingsHandler
的用法示例。
在下文中一共展示了SettingsHandler.bind方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_schema_only_settings
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import bind [as 别名]
def test_schema_only_settings(self):
handler = SettingsHandler()
with self.override_default_settings(SimpleWidget):
handler.bind(SimpleWidget)
# fast_save should not update defaults
widget = SimpleWidget()
handler.fast_save(widget, 'schema_only_setting', 5)
self.assertEqual(
handler.known_settings['schema_only_setting'].default, None)
handler.fast_save(widget, 'component.schema_only_setting', 5)
self.assertEqual(
handler.known_settings['component.schema_only_setting'].default, "only")
# update_defaults should not update defaults
widget.schema_only_setting = 5
handler.update_defaults(widget)
self.assertEqual(
handler.known_settings['schema_only_setting'].default, None)
widget.component.schema_only_setting = 5
self.assertEqual(
handler.known_settings['component.schema_only_setting'].default, "only")
# pack_data should pack setting
widget.schema_only_setting = 5
widget.component.schema_only_setting = 5
data = handler.pack_data(widget)
self.assertEqual(data['schema_only_setting'], 5)
self.assertEqual(data['component']['schema_only_setting'], 5)
示例2: test_pack_settings_stores_version
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import bind [as 别名]
def test_pack_settings_stores_version(self):
handler = SettingsHandler()
handler.bind(SimpleWidget)
widget = SimpleWidget()
settings = handler.pack_data(widget)
self.assertIn(VERSION_KEY, settings)
示例3: test_fast_save
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import bind [as 别名]
def test_fast_save(self):
handler = SettingsHandler()
handler.read_defaults = lambda: None
handler.bind(SimpleWidget)
widget = SimpleWidget()
handler.fast_save(widget, 'component.int_setting', 5)
self.assertEqual(Component.int_setting.default, 5)
handler.fast_save(widget, 'non_setting', 4)
示例4: test_about_pack_settings_signal
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import bind [as 别名]
def test_about_pack_settings_signal(self):
handler = SettingsHandler()
handler.bind(SimpleWidget)
widget = SimpleWidget()
handler.initialize(widget)
fn = Mock()
widget.settingsAboutToBePacked.connect(fn)
handler.pack_data(widget)
self.assertEqual(1, fn.call_count)
handler.update_defaults(widget)
self.assertEqual(2, fn.call_count)
示例5: test_initialize_copies_mutables
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import bind [as 别名]
def test_initialize_copies_mutables(self):
handler = SettingsHandler()
handler.bind(SimpleWidget)
handler.defaults = dict(list_setting=[])
widget = SimpleWidget()
handler.initialize(widget)
widget2 = SimpleWidget()
handler.initialize(widget2)
self.assertNotEqual(id(widget.list_setting), id(widget2.list_setting))
示例6: test_fast_save
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import bind [as 别名]
def test_fast_save(self):
handler = SettingsHandler()
with self.override_default_settings(SimpleWidget):
handler.bind(SimpleWidget)
widget = SimpleWidget()
handler.fast_save(widget, 'component.int_setting', 5)
self.assertEqual(
handler.known_settings['component.int_setting'].default, 5)
self.assertEqual(Component.int_setting.default, 42)
handler.fast_save(widget, 'non_setting', 4)
示例7: test_schema_only_settings
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import bind [as 别名]
def test_schema_only_settings(self):
handler = SettingsHandler()
handler.read_defaults = lambda: None
handler.bind(SimpleWidget)
# fast_save should not update defaults
widget = SimpleWidget()
handler.fast_save(widget, 'schema_only_setting', 5)
self.assertEqual(
handler.known_settings['schema_only_setting'].default, None)
# update_defaults should not update defaults
widget.schema_only_setting = 5
handler.update_defaults(widget)
self.assertEqual(
handler.known_settings['schema_only_setting'].default, None)
# pack_data should pack setting
widget.schema_only_setting = 5
data = handler.pack_data(widget)
self.assertEqual(data['schema_only_setting'], 5)
示例8: test_initialize_migrates_settings
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import bind [as 别名]
def test_initialize_migrates_settings(self):
handler = SettingsHandler()
with self.override_default_settings(SimpleWidget):
handler.bind(SimpleWidget)
widget = SimpleWidget()
migrate_settings = Mock()
with patch.object(SimpleWidget, "migrate_settings", migrate_settings):
# Old settings without version
settings = {"value": 5}
handler.initialize(widget, settings)
migrate_settings.assert_called_with(settings, 0)
migrate_settings.reset_mock()
# Settings with version
settings_with_version = dict(settings)
settings_with_version[VERSION_KEY] = 1
handler.initialize(widget, settings_with_version)
migrate_settings.assert_called_with(settings, 1)
示例9: test_fast_save_siblings_spill
# 需要导入模块: from Orange.widgets.settings import SettingsHandler [as 别名]
# 或者: from Orange.widgets.settings.SettingsHandler import bind [as 别名]
def test_fast_save_siblings_spill(self):
handler_mk1 = SettingsHandler()
with self.override_default_settings(SimpleWidgetMk1):
handler_mk1.bind(SimpleWidgetMk1)
widget_mk1 = SimpleWidgetMk1()
handler_mk1.fast_save(widget_mk1, "setting", -1)
handler_mk1.fast_save(widget_mk1, "component.int_setting", 1)
self.assertEqual(
handler_mk1.known_settings['setting'].default, -1)
self.assertEqual(
handler_mk1.known_settings['component.int_setting'].default, 1)
handler_mk1.initialize(widget_mk1, data=None)
handler_mk1.provider.providers["component"].initialize(
widget_mk1.component, data=None)
self.assertEqual(widget_mk1.setting, -1)
self.assertEqual(widget_mk1.component.int_setting, 1)
handler_mk2 = SettingsHandler()
with self.override_default_settings(SimpleWidgetMk2):
handler_mk2.bind(SimpleWidgetMk2)
widget_mk2 = SimpleWidgetMk2()
handler_mk2.initialize(widget_mk2, data=None)
handler_mk2.provider.providers["component"].initialize(
widget_mk2.component, data=None)
self.assertEqual(widget_mk2.setting, 42,
"spils defaults into sibling classes")
self.assertEqual(Component.int_setting.default, 42)
self.assertEqual(widget_mk2.component.int_setting, 42,
"spils defaults into sibling classes")