Source

orange / docs / extend-widgets / rst / OWAttributeSampler.py

Diff from to

docs/extend-widgets/rst/OWAttributeSampler.py

 <icon>icons/AttributeSampler.png</icon>
 <priority>1020</priority>
 """
+import Orange
 
 from OWWidget import *
 import OWGUI
 
 class OWAttributeSampler(OWWidget):
     settingsList = []
-    contextHandlers = {"": DomainContextHandler("", [
-            ContextField("classAttribute", DomainContextHandler.Required),
-            ContextField("attributeList", DomainContextHandler.List + DomainContextHandler.SelectedRequired,
-                         selected="selectedAttributes")])}
+
+    # ~start context handler~
+    contextHandlers = {
+        "": DomainContextHandler(
+            "",
+            [ContextField("classAttribute", DomainContextHandler.Required),
+             ContextField("attributeList",
+                          DomainContextHandler.List +
+                          DomainContextHandler.SelectedRequired,
+                          selected="selectedAttributes")])}
+    # ~end context handler~
 
     def __init__(self, parent=None, signalManager=None):
         OWWidget.__init__(self, parent, signalManager, 'AttributeSampler')
 
-        self.inputs = [("Examples", ExampleTable, self.dataset)]
-        self.outputs = [("Examples", ExampleTable)]
+        self.inputs = [("Examples", Orange.data.Table, self.dataset)]
+        self.outputs = [("Examples", Orange.data.Table)]
 
         self.icons = self.createAttributeIconDict()
 
         self.classAttribute = None
         self.loadSettings()
 
-        OWGUI.listBox(self.controlArea, self, "selectedAttributes", "attributeList", box="Selected attributes", selectionMode = QListWidget.ExtendedSelection)
+        OWGUI.listBox(self.controlArea, self, "selectedAttributes",
+                      "attributeList",
+                      box="Selected attributes",
+                      selectionMode=QListWidget.ExtendedSelection)
+
         OWGUI.separator(self.controlArea)
-        self.classAttrCombo = OWGUI.comboBox(self.controlArea, self, "classAttribute", box="Class attribute")
+        self.classAttrCombo = OWGUI.comboBox(
+            self.controlArea, self, "classAttribute",
+            box="Class attribute")
+
         OWGUI.separator(self.controlArea)
-        OWGUI.button(self.controlArea, self, "Commit", callback = self.outputData)
+        OWGUI.button(self.controlArea, self, "Commit",
+                     callback=self.outputData)
 
         self.resize(150,400)
 
 
         self.classAttrCombo.clear()
         if data:
-            self.attributeList = [(attr.name, attr.varType) for attr in data.domain]
+            self.attributeList = [(attr.name, attr.varType)
+                                  for attr in data.domain]
             self.selectedAttributes = []
             for attrName, attrType in self.attributeList:
                 self.classAttrCombo.addItem(self.icons[attrType], attrName)
         if not self.data:
             self.send("Examples", None)
         else:
-            newDomain = orange.Domain([self.data.domain[i] for i in self.selectedAttributes], self.data.domain[self.classAttribute])
-            newData = orange.ExampleTable(newDomain, self.data)
+            newDomain = Orange.data.Domain(
+                [self.data.domain[i] for i in self.selectedAttributes],
+                self.data.domain[self.classAttribute])
+
+            newData = Orange.data.Table(newDomain, self.data)
             self.send("Examples", newData)
 
 
-##############################################################################
-# Test the widget, run from prompt
-
 if __name__=="__main__":
     appl = QApplication(sys.argv)
     ow = OWAttributeSampler()
     ow.show()
 
-    data = orange.ExampleTable('iris.tab')
+    data = Orange.data.Table('iris.tab')
     ow.dataset(data)
 
     appl.exec_()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.