{"id":28016,"library":"orange-widget-base","title":"Orange Widget Base","description":"Base classes for creating Orange Canvas widgets. Provides OWBaseWidget and its derived classes for building interactive data mining components. Current version 4.27.0, requires Python >=3.10. Released as part of the Orange data mining suite.","status":"active","version":"4.27.0","language":"python","source_language":"en","source_url":"https://github.com/biolab/orange-widget-base","tags":["orange","widget","canvas","data-mining","orangedm"],"install":[{"cmd":"pip install orange-widget-base","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"OWBaseWidget is in the orangewidget package, not Orange.widgets.","wrong":"from Orange.widgets import OWBaseWidget","symbol":"OWBaseWidget","correct":"from orangewidget.widget import OWBaseWidget"},{"note":"The gui module is in orangewidget, not Orange.widgets.","wrong":"from Orange.widgets import gui","symbol":"gui.comboBox","correct":"from orangewidget import gui"},{"note":"Signal classes moved to orangewidget.utils.signals in recent versions.","wrong":"from Orange.widgets.widget import InputSignal","symbol":"InputSignal","correct":"from orangewidget.utils.signals import InputSignal"}],"quickstart":{"code":"from orangewidget.widget import OWBaseWidget, Input, Output\nfrom orangewidget import gui\nfrom orangewidget.settings import Setting\n\nclass MyWidget(OWBaseWidget):\n    name = \"My Widget\"\n    description = \"A custom widget\"\n    icon = \"icons/my.svg\"\n    priority = 10\n\n    class Inputs:\n        data = Input(\"Data\", object, \"set_data\")\n\n    class Outputs:\n        result = Output(\"Result\", object)\n\n    settings = {\"threshold\": Setting(0.5)}\n    want_main_area = False\n\n    def __init__(self):\n        super().__init__()\n        self.threshold = 0.5\n        gui.doubleSpin(self.controlArea, self, \"threshold\", 0, 1, 0.1, label=\"Threshold:\")\n\n    def set_data(self, data):\n        pass\n\nif __name__ == \"__main__\":\n    from orangewidget.utils.widgetpreview import WidgetPreview\n    WidgetPreview(MyWidget).run()","lang":"python","description":"Minimal OWBaseWidget subclass with inputs, outputs, settings, and control area."},"warnings":[{"fix":"Define Inputs and Outputs as inner classes with Input/Output instances.","message":"In version 4.x, the signal handling API changed from connect/disconnect style to decorator-based Input/Output classes. Old code using `self.inputs = [...]` or `self.outputs = [...]` will break.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use `from orangewidget import gui` instead.","message":"The `gui` module was removed from `Orange.widgets` and moved to the separate `orangewidget` package. Importing from `Orange.widgets.gui` will raise ImportError.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Import from `orangewidget.settings import Setting`.","message":"The `Orange.widgets.settings` module moved to `orangewidget.settings`. The `Setting` class import path changed.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Update widgets to use OWBaseWidget and Input/Output decorators.","message":"The `orange-canvas-core` package now enforces the new widget API. Old-style widgets may not load or cause errors.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Define handler methods with descriptive names and link them via `Input(\"Name\", type, \"method_name\")`.","message":"The use of `getattr(self, 'handler_{}'.format(signal_name))` signal handlers is deprecated in favor of explicit methods linked via `Input` decorator.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Always set `name` to a unique, descriptive string.","message":"The `name` attribute of OWBaseWidget must be a non-empty string, otherwise the widget may not appear in the canvas.","severity":"gotcha","affected_versions":"all"},{"fix":"Pass the class object, e.g., `Input(\"Data\", Orange.data.Table, \"set_data\")`.","message":"Signals types must be actual Python objects (classes), not strings. Using strings for type will raise a TypeError at registration.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Replace `from Orange.widgets import gui` with `from orangewidget import gui`.","cause":"The gui module was moved to the orangewidget package in version 4.x.","error":"ModuleNotFoundError: No module named 'Orange.widgets.gui'"},{"fix":"Define `class Inputs:` and `class Outputs:` inside your widget class with `Input` and `Output` instances.","cause":"Input and Output signals are now defined as inner classes, not as class-level attributes.","error":"AttributeError: 'MyWidget' object has no attribute 'Inputs'"},{"fix":"Pass the actual class, e.g., `Input(\"Data\", Orange.data.Table, \"set_data\")` instead of a string.","cause":"Passing a string instead of a class for the signal type parameter.","error":"TypeError: signal must be a type, got <class 'str'>"},{"fix":"Change import to `from orangewidget.settings import Setting`.","cause":"The settings module moved to orangewidget.settings.","error":"ImportError: cannot import name 'Setting' from 'Orange.widgets.settings'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}