Skip to content

Commit

Permalink
Start from an orange3-example-addon
Browse files Browse the repository at this point in the history
  • Loading branch information
markotoplak committed Mar 7, 2016
0 parents commit 47e87ab
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Build files
build
dist
*.egg-info/*
*.so
*.la
*.o
*.py[doc]
MANIFEST

# Cython generated files
__pycache__

# Editor files
.idea
.idea/*
*~
.project
.pydevproject
.settings/*
.DS_Store
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ref https://docs.python.org/2/distutils/sourcedist.html#commands
recursive-include orangecontrib *.ows icons/*
global-exclude __pycache__
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Orange3 Example Add-on
======================

This is an example add-on for [Orange3](http://orange.biolab.si). Add-on can extend Orange either
in scripting or GUI part, or in both. We here focus on the GUI part and implement a simple (empty) widget,
register it with Orange and add a new workflow with this widget to example tutorials.

Installation
------------

To install the add-on, run

python setup.py install

To register this add-on with Orange, but keep the code in the development directory (do not copy it to
Python's site-packages directory), run

python setup.py develop

Usage
-----

After the installation, the widget from this add-on is registered with Orange. To run Orange from the terminal,
use

python -m Orange.canvas

The new widget appears in the toolbox bar under the section Example.

![screenshot](https://github.com/biolab/orange3-example-addon/blob/master/screenshot.png)
3 changes: 3 additions & 0 deletions orangecontrib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__import__("pkg_resources").declare_namespace(__name__)
# orangecontrib is a namespace modules shared by multiple Orange add-on so it
# needs to declare namespace.
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions orangecontrib/infrared/tutorials/example_tutorial.ows
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version='1.0' encoding='utf-8'?>
<scheme description="" title="Example Workflow" version="2.0">
<nodes>
<node id="0" name="Example Widget" position="(129.0, 126.0)" project_name="Orange3-Example-Add-on" qualified_name="orangecontrib.example.widgets.mywidget.MyWidget" title="Example Widget" version="" />
</nodes>
<links />
<annotations>
<arrow end="(183.0, 144.0)" fill="#C1272D" id="0" start="(283.0, 238.0)" />
<text font-family="Helvetica" font-size="16" id="1" rect="(259.0, 260.0, 150.0, 44.0)">This is a wiget from an addon</text>
</annotations>
<thumbnail />
<node_properties>
<properties format="pickle" node_id="0">gAN9cQBYEwAAAHNhdmVkV2lkZ2V0R2VvbWV0cnlxAWNzaXAKX3VucGlja2xlX3R5cGUKcQJYDAAA
AFB5UXQ0LlF0Q29yZXEDWAoAAABRQnl0ZUFycmF5cQRDLgHZ0MsAAQAAAAAGEQAABHQAAAbYAAAE
7QAABhEAAASKAAAG2AAABO0AAAAAAABxBYVxBodxB1JxCHMu
</properties>
</node_properties>
</scheme>
8 changes: 8 additions & 0 deletions orangecontrib/infrared/widgets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Category metadata.

# Category icon show in the menu
ICON = "icons/category.svg"

# Background color for category background in menu
# and widget icon background in workflow.
BACKGROUND = "light-blue"
9 changes: 9 additions & 0 deletions orangecontrib/infrared/widgets/icons/category.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions orangecontrib/infrared/widgets/icons/mywidget.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions orangecontrib/infrared/widgets/mywidget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from PyQt4 import QtCore, QtGui
from Orange.widgets.widget import OWWidget
from Orange.widgets import gui


class MyWidget(OWWidget):
# Widget needs a name, or it is considered an abstract widget
# and not shown in the menu.
name = "Hello World"
icon = "icons/mywidget.svg"
want_main_area = False

def __init__(self):
super().__init__()

label = QtGui.QLabel("Hello, World!")
self.controlArea.layout().addWidget(
label, QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter)
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python

from setuptools import setup, find_packages

ENTRY_POINTS = {
# Entry point used to specify packages containing tutorials accessible
# from welcome screen. Tutorials are saved Orange Workflows (.ows files).
'orange.widgets.tutorials': (
# Syntax: any_text = path.to.package.containing.tutorials
'exampletutorials = orangecontrib.example.tutorials',
),

# Entry point used to specify packages containing widgets.
'orange.widgets': (
# Syntax: category name = path.to.package.containing.widgets
# Widget category specification can be seen in
# orangecontrib/example/widgets/__init__.py
'Infrared = orangecontrib.infrared.widgets',
),
}

KEYWORDS = (
# [PyPi](https://pypi.python.org) packages with keyword "orange3 add-on"
# can be installed using the Orange Add-on Manager
'orange3 add-on',
)

if __name__ == '__main__':
setup(
name="Orange-Infrared",
description='',
author='',
author_email='',
packages=find_packages(),
install_requires=[
'Orange',
],
entry_points=ENTRY_POINTS,
keywords=KEYWORDS,
namespace_packages=['orangecontrib'],
include_package_data=True,
zip_safe=False,
)

0 comments on commit 47e87ab

Please sign in to comment.