def __init__(self, parent=None, signalManager=None, name="Info"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0) self.inputs = [("Data Table", ExampleTable, self.data)] self.rowcount = 0 self.columncount = 0 self.discattrcount = 0 self.contattrcount = 0 self.stringattrcount = 0 self.metaattrcount = 0 self.classattr = "no" box = OWGUI.widgetBox(self.controlArea, "Data Set Size") OWGUI.label( box, self, '<table><tr><td width="150">Samples (rows):</td><td align="right" width="60">%(rowcount)7i</td></tr>\ <tr><td>Attributes (columns):</td><td align="right">%(columncount)7i</td></tr></table>' ) box = OWGUI.widgetBox(self.controlArea, "Attributes") OWGUI.label( box, self, '<table><tr><td width="150">Discrete attributes:</td><td align="right" width="60">%(discattrcount)7i</td></tr>\ <tr><td>Continuous attributes:</td><td align="right">%(contattrcount)7i</td></tr>\ <tr><td>String attributes:</td><td align="right">%(stringattrcount)7i</td></tr>\ <tr><td> </td></tr>\ <tr><td>Meta attributes:</td><td align="right">%(metaattrcount)7i</td></tr>\ <tr><td>Class attribute:</td><td align="right">%(classattr)7s</td></tr></table>' ) # OWGUI.separator(box) # OWGUI.label(box, self, '<table><tr><td width="100">Meta attributes:</td><td align="right" width="50">%(metaattrcount)7i</td></tr>\ # <tr><td>Class attribute:</td><td align="right">%(classattr)7s</td></tr></table>') # OWGUI.rubber(self.controlArea)
def initDestinationPage(self): self.optionalMetaDataPage = page = QWizardPage() page.setTitle("Destination") page.setLayout(QVBoxLayout()) self.addPage(page) self.prepare_only = False chk_prepare_only = OWGUI.checkBox( page, self, "prepare_only", "Do not pack, only prepare addon.xml and arrange documentation", callback=self.callbackPrepareOnlyChange) p = OWGUI.widgetBox(page, "Filesystem", orientation="horizontal") self.oaofilename = "" self.e_oaofilename = OWGUI.lineEdit(p, self, "oaofilename") button = OWGUI.button(p, self, '...', callback=self.browseDestinationFile, disabled=0) button.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon)) button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) def initOao(page): if not self.oaofilename: self.e_oaofilename.setText(self.directory + ".oao") page.initializePage = initOao p = OWGUI.widgetBox(page, "Repository", orientation="vertical") OWGUI.label( p, self, "Uploading into repositories is not yet implemented, sorry.")
def __init__(self, parent=None): OWWidget.__init__(self, parent, title='Listbox') self.colors = ["Red", "Green", "Blue"] self.chosenColor = [2] self.numbers = ["One", "Two", "Three", "Four"] self.chosenNumbers = [0, 2, 3] OWGUI.listBox(self.controlArea, self, "chosenColor", "colors", box="Color", callback=self.checkAll) OWGUI.listBox(self.controlArea, self, "chosenNumbers", "numbers", box="Number", selectionMode=QListWidget.MultiSelection, callback=self.checkAll) OWGUI.separator(self.controlArea) box = OWGUI.widgetBox(self.controlArea, "Debug info") OWGUI.label(box, self, "Color: %(chosenColor)s") OWGUI.label(box, self, "Numbers: %(chosenNumbers)s", labelWidth=100) self.setFixedSize(110, 280)
def __init__(self, parent=None, signalManager=None, name="Info"): OWWidget.__init__(self, parent, signalManager, name, wantMainArea=0) self.inputs = [("Data", ExampleTable, self.data)] self.rowcount = 0 self.columncount = 0 self.discattrcount = 0 self.contattrcount = 0 self.stringattrcount = 0 self.metaattrcount = 0 self.classattr = "No" box = OWGUI.widgetBox(self.controlArea, "Data Set Size", addSpace=True) OWGUI.label(box, self, '<table><tr><td width="150">Samples (rows):</td><td align="right" width="60">%(rowcount)7i</td></tr>\ <tr><td>Features (columns):</td><td align="right">%(columncount)7i</td></tr></table>') box = OWGUI.widgetBox(self.controlArea, "Features") OWGUI.label(box, self, '<table><tr><td width="150">Discrete:</td><td align="right" width="60">%(discattrcount)7i</td></tr>\ <tr><td>Continuous:</td><td align="right">%(contattrcount)7i</td></tr>\ <tr><td>String:</td><td align="right">%(stringattrcount)7i</td></tr>\ <tr><td> </td></tr>\ <tr><td>Meta features:</td><td align="right">%(metaattrcount)7i</td></tr>\ <tr><td>Class variable present:</td><td align="right">%(classattr)7s</td></tr></table>') # OWGUI.separator(box) # OWGUI.label(box, self, '<table><tr><td width="100">Meta attributes:</td><td align="right" width="50">%(metaattrcount)7i</td></tr>\ # <tr><td>Class attribute:</td><td align="right">%(classattr)7s</td></tr></table>') # OWGUI.rubber(self.controlArea) self.resize(200, 200) self.loadSettings()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Python Script') self.inputs = [("inExampleTable", ExampleTable, self.setExampleTable), ("inDistanceMatrix", orange.SymMatrix, self.setDistanceMatrix), ("inNetwork", orngNetwork.Network, self.setNetwork)] self.outputs = [("outExampleTable", ExampleTable), ("outDistanceMatrix", orange.SymMatrix), ("outNetwork", orngNetwork.Network)] self.inNetwork = None self.inExampleTable = None self.inDistanceMatrix = None self.codeFile = '' self.loadSettings() self.infoBox = OWGUI.widgetBox(self.controlArea, 'Info') OWGUI.label( self.infoBox, self, "Execute python script.\n\nInput variables:\n - inExampleTable\n - inDistanceMatrix\n - inNetwork\n\nOutput variables:\n - outExampleTable\n - outDistanceMatrix\n - outNetwork" ) self.controlBox = OWGUI.widgetBox(self.controlArea, 'File') OWGUI.button(self.controlBox, self, "Open...", callback=self.openScript) OWGUI.button(self.controlBox, self, "Save...", callback=self.saveScript) self.runBox = OWGUI.widgetBox(self.controlArea, 'Run') OWGUI.button(self.runBox, self, "Execute", callback=self.execute) self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitCanvas) self.textBox = OWGUI.widgetBox(self, 'Python script') self.splitCanvas.addWidget(self.textBox) self.text = QPlainTextEdit(self) self.textBox.layout().addWidget(self.text) self.text.setFont(QFont("Monospace")) self.textBox.setAlignment(Qt.AlignVCenter) self.text.setTabStopWidth(4) self.consoleBox = OWGUI.widgetBox(self, 'Console') self.splitCanvas.addWidget(self.consoleBox) self.console = QPlainTextEdit(self) self.consoleBox.layout().addWidget(self.console) self.console.setFont(QFont("Monospace")) self.consoleBox.setAlignment(Qt.AlignBottom) self.console.setTabStopWidth(4) self.openScript(self.codeFile) self.controlArea.layout().addStretch(1) self.resize(800, 600)
def __init__(self, parent=None): OWWidget.__init__(self, parent, title='Labels') self.val = 5 self.line = "a parrot" OWGUI.spin(self.controlArea, self, "val", 1, 10, label="Value") OWGUI.lineEdit(self.controlArea, self, "line", label="Line: ", orientation="horizontal") OWGUI.label(self.controlArea, self, "Value is %(val)i and line edit contains %(line)s") self.resize(100,100)
def __init__(self,parent=None, signalManager = None): OWSubSQLSelect.__init__(self, parent, signalManager, "SQL select") self.sqlReader = orngSQL.SQLReader() self.inputs = [] self.outputs = [("Data", ExampleTable), ("Feature Definitions", orange.Domain)] #set default settings self.domain = None self.recentConnections=["(none)"] self.queryFile = None self.query = '' self.lastQuery = None self.loadSettings() if self.lastQuery is not None: self.query = self.lastQuery self.connectString = self.recentConnections[0] self.connectBox = OWGUI.widgetBox(self.controlArea, "Database") self.connectLineEdit = OWGUI.lineEdit(self.connectBox, self, 'connectString', callback = self.connectDB) self.connectCombo = OWGUI.comboBox(self.connectBox, self, 'connectString', items = self.recentConnections, callback = self.selectConnection) button = OWGUI.button(self.connectBox, self, 'connect', callback = self.connectDB, disabled = 0) #query self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitCanvas) self.textBox = OWGUI.widgetBox(self, 'SQL select') self.splitCanvas.addWidget(self.textBox) self.queryTextEdit = QPlainTextEdit(self.query, self) self.textBox.layout().addWidget(self.queryTextEdit) self.selectBox = OWGUI.widgetBox(self.controlArea, "Select statement") # self.selectSubmitBox = QHGroupBox("", self.selectBox) # self.queryTextEdit.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) # self.queryTextEdit.setMinimumWidth(300) # self.connect(self.queryTextEdit, SIGNAL('returnPressed()'), self.executeQuery) OWGUI.button(self.selectBox, self, "Open...", callback=self.openScript) OWGUI.button(self.selectBox, self, "Save...", callback=self.saveScript) self.selectBox.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) button = OWGUI.button(self.selectBox, self, 'execute!', callback = self.executeQuery, disabled=0) self.domainBox = OWGUI.widgetBox(self.controlArea, "Domain") self.domainLabel = OWGUI.label(self.domainBox, self, '') # info self.infoBox = OWGUI.widgetBox(self.controlArea, "Info") self.info = [] self.info.append(OWGUI.label(self.infoBox, self, 'No data loaded.')) self.info.append(OWGUI.label(self.infoBox, self, '')) self.resize(300,300)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self,parent,signalManager,"Preprocess") self.inputs = [("Example Table", ExampleTable, self.dataset)] self.outputs = [("Distance Matrix", orange.SymMatrix)] self.data = None self.distanceType = 0 self.nDocuments = "N/A"; self.nWords = "N/A" self.loadSettings() box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True) OWGUI.label(box, self, "Documents: %(nDocuments)s") OWGUI.label(box, self, "Words: %(nWords)s") OWGUI.radioButtonsInBox(self.controlArea, self, "distanceType", box = "Matrix type", btnLabels = ["Similarity [cos(fi)]", "Distance [1/cos(fi)]"], addSpace = True) OWGUI.button(self.controlArea, self, "Apply", self.apply) OWGUI.rubber(self.controlArea) self.adjustSize()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'PurgeDomain') self.settingsList=["removeValues", "removeAttributes", "removeClassAttribute", "removeClasses", "autoSend", "sortValues", "sortClasses"] self.inputs = [("Examples", ExampleTable, self.setData)] self.outputs = [("Examples", ExampleTable)] self.data = None self.preRemoveValues = self.removeValues = 1 self.removeAttributes = 1 self.removeClassAttribute = 1 self.preRemoveClasses = self.removeClasses = 1 self.autoSend = 1 self.dataChanged = False self.sortValues = self.sortClasses = True self.loadSettings() self.removedAttrs = self.reducedAttrs = self.resortedAttrs = self.classAttr = "-" boxAt = OWGUI.widgetBox(self.controlArea, "Attributes") OWGUI.checkBox(boxAt, self, 'sortValues', 'Sort attribute values', callback = self.optionsChanged) rua = OWGUI.checkBox(boxAt, self, "removeAttributes", "Remove attributes with less than two values", callback = self.removeAttributesChanged) boxH = OWGUI.widgetBox(boxAt, orientation="horizontal") OWGUI.separator(boxH, width=30, height=0) ruv = OWGUI.checkBox(boxH, self, "removeValues", "Remove unused attribute values", callback = self.optionsChanged) rua.disables = [ruv] OWGUI.separator(self.controlArea) boxAt = OWGUI.widgetBox(self.controlArea, "Classes") OWGUI.checkBox(boxAt, self, 'sortClasses', 'Sort classes', callback = self.optionsChanged) rua = OWGUI.checkBox(boxAt, self, "removeClassAttribute", "Remove class attribute if there are less than two classes", callback = self.removeClassesChanged) boxH = OWGUI.widgetBox(boxAt, orientation="horizontal") OWGUI.separator(boxH, width=30, height=0) ruv = OWGUI.checkBox(boxH, self, "removeClasses", "Remove unused class values", callback = self.optionsChanged) rua.disables = [ruv] OWGUI.separator(self.controlArea) box2 = OWGUI.widgetBox(self.controlArea) btSend = OWGUI.button(box2, self, "Send data", callback = self.process) cbAutoSend = OWGUI.checkBox(box2, self, "autoSend", "Send automatically") OWGUI.setStopper(self, btSend, cbAutoSend, "dataChanged", self.process) OWGUI.separator(self.controlArea, height=24) box3 = OWGUI.widgetBox(self.controlArea, 'Statistics') OWGUI.label(box3, self, "Removed attributes: %(removedAttrs)s") OWGUI.label(box3, self, "Reduced attributes: %(reducedAttrs)s") OWGUI.label(box3, self, "Resorted attributes: %(resortedAttrs)s") OWGUI.label(box3, self, "Class attribute: %(classAttr)s")
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'PurgeDomain', wantMainArea=False) self.settingsList=["removeValues", "removeAttributes", "removeClassAttribute", "removeClasses", "autoSend", "sortValues", "sortClasses"] self.inputs = [("Data", ExampleTable, self.setData)] self.outputs = [("Data", ExampleTable)] self.data = None self.preRemoveValues = self.removeValues = 1 self.removeAttributes = 1 self.removeClassAttribute = 1 self.preRemoveClasses = self.removeClasses = 1 self.autoSend = 1 self.dataChanged = False self.sortValues = self.sortClasses = True self.loadSettings() self.removedAttrs = self.reducedAttrs = self.resortedAttrs = self.classAttr = "-" boxAt = OWGUI.widgetBox(self.controlArea, "Attributes", addSpace=True) OWGUI.checkBox(boxAt, self, 'sortValues', 'Sort attribute values', callback = self.optionsChanged) rua = OWGUI.checkBox(boxAt, self, "removeAttributes", "Remove attributes with less than two values", callback = self.removeAttributesChanged) ruv = OWGUI.checkBox(OWGUI.indentedBox(boxAt, sep=OWGUI.checkButtonOffsetHint(rua)), self, "removeValues", "Remove unused attribute values", callback = self.optionsChanged) rua.disables = [ruv] rua.makeConsistent() boxAt = OWGUI.widgetBox(self.controlArea, "Classes", addSpace=True) OWGUI.checkBox(boxAt, self, 'sortClasses', 'Sort classes', callback = self.optionsChanged) rua = OWGUI.checkBox(boxAt, self, "removeClassAttribute", "Remove class attribute if there are less than two classes", callback = self.removeClassesChanged) ruv = OWGUI.checkBox(OWGUI.indentedBox(boxAt, sep=OWGUI.checkButtonOffsetHint(rua)), self, "removeClasses", "Remove unused class values", callback = self.optionsChanged) rua.disables = [ruv] rua.makeConsistent() box3 = OWGUI.widgetBox(self.controlArea, 'Statistics', addSpace=True) OWGUI.label(box3, self, "Removed attributes: %(removedAttrs)s") OWGUI.label(box3, self, "Reduced attributes: %(reducedAttrs)s") OWGUI.label(box3, self, "Resorted attributes: %(resortedAttrs)s") OWGUI.label(box3, self, "Class attribute: %(classAttr)s") box2 = OWGUI.widgetBox(self.controlArea, "Send") btSend = OWGUI.button(box2, self, "Send data", callback = self.process, default=True) cbAutoSend = OWGUI.checkBox(box2, self, "autoSend", "Send automatically") OWGUI.setStopper(self, btSend, cbAutoSend, "dataChanged", self.process) OWGUI.rubber(self.controlArea)
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Predictions") self.callbackDeposit = [] self.inputs = [("Examples", ExampleTable, self.setData), ("Predictors", orange.Classifier, self.setPredictor, Multiple)] self.outputs = [("Predictions", ExampleTable)] self.predictors = {} # saveble settings self.ShowAttributeMethod = 0 self.classes = [] self.selectedClasses = [] self.loadSettings() self.datalabel = "N/A" self.predictorlabel = "N/A" self.tasklabel = "N/A" self.outvar = None # current output variable (set by the first predictor/data set send in) self.classifications = [] self.rindx = None self.data = None self.verbose = 0 self.nVarImportance = 0 # GUI - Options # Options - classification ibox = OWGUI.widgetBox(self.controlArea, "Info") OWGUI.label(ibox, self, "Data: %(datalabel)s") OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s") OWGUI.label(ibox, self, "Task: %(tasklabel)s") OWGUI.separator(ibox) OWGUI.label(ibox, self, "Predictions can be viewed with the 'Data Table'\nand saved with the 'Save' widget!") OWGUI.separator(self.controlArea) self.copt = OWGUI.widgetBox(self.controlArea,"Probabilities (classification)") self.copt.setDisabled(1) self.lbcls = OWGUI.listBox(self.copt, self, "selectedClasses", "classes", selectionMode=QListWidget.MultiSelection) self.lbcls.setFixedHeight(50) OWGUI.separator(self.controlArea) self.VarImportanceBox = OWGUI.doubleSpin(self.controlArea, self, "nVarImportance", 0,9999999,1, label="Variable importance", orientation="horizontal", tooltip="The number of variables to report for each prediction.") OWGUI.checkBox(self.controlArea, self, 'verbose', 'Verbose', tooltip='Show detailed info while predicting. This will slow down the predictions process!') OWGUI.separator(self.controlArea) self.outbox = OWGUI.widgetBox(self.controlArea,"Output") self.apply = OWGUI.button(self.outbox, self, "Apply", callback=self.sendpredictions) OWGUI.rubber(self.controlArea) self.adjustSize()
def initDestinationPage(self): self.optionalMetaDataPage = page = QWizardPage() page.setTitle("Destination") page.setLayout(QVBoxLayout()) self.addPage( page ) self.prepare_only = False chk_prepare_only = OWGUI.checkBox(page, self, "prepare_only", "Do not pack, only prepare addon.xml and arrange documentation", callback = self.callbackPrepareOnlyChange) p = OWGUI.widgetBox(page, "Filesystem", orientation="horizontal") self.oaofilename = "" self.e_oaofilename = OWGUI.lineEdit(p, self, "oaofilename") button = OWGUI.button(p, self, '...', callback = self.browseDestinationFile, disabled=0) button.setIcon(self.style().standardIcon(QStyle.SP_DirOpenIcon)) button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) def initOao(page): if not self.oaofilename: self.e_oaofilename.setText(self.directory+".oao") page.initializePage = initOao p = OWGUI.widgetBox(page, "Repository", orientation="vertical") OWGUI.label(p, self, "Uploading into repositories is not yet implemented, sorry.")
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Itemsets explorer") self.inputs = [("Itemsets", Itemsets, self.setItemsets)] self.outputs = [("Itemsets", Itemsets), ("Data", ExampleTable)] self.showWholeItemsets = 1 self.treeDepth = 2 self.autoSend = True self.dataChanged = False self.purgeAttributes = True self.purgeClasses = True self.nItemsets = self.nSelectedItemsets = self.nSelectedExamples = "" self.loadSettings() self.treeItemsets = QTreeWidget(self.mainArea) self.mainArea.layout().addWidget(self.treeItemsets) self.treeItemsets.setSelectionMode (QTreeWidget.ExtendedSelection) self.treeItemsets.setHeaderLabels(["Itemsets", "Examples"]) self.treeItemsets.setAllColumnsShowFocus ( 1) self.treeItemsets.setAlternatingRowColors(1) self.treeItemsets.setColumnCount(2) self.connect(self.treeItemsets,SIGNAL("itemSelectionChanged()"),self. selectionChanged) box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True) OWGUI.label(box, self, "Number of itemsets: %(nItemsets)s") OWGUI.label(box, self, "Selected itemsets: %(nSelectedItemsets)s") OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s") box = OWGUI.widgetBox(self.controlArea, "Tree", addSpace = True) OWGUI.spin(box, self, "treeDepth", label = "Tree depth", min = 1, max = 10, step = 1, callback = self.populateTree, callbackOnReturn = True) OWGUI.checkBox(box, self, "showWholeItemsets", "Display whole itemsets", callback = self.setWholeItemsets) OWGUI.button(box, self, "Expand All", callback = lambda: self.treeItemsets.expandAll()) OWGUI.button(box, self, "Collapse", callback = lambda: self.treeItemsets.collapseAll()) OWGUI.rubber(self.controlArea) boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection') OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged) self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged) if not self.purgeAttributes: self.purgeClassesCB.setEnabled(False) self.oldPurgeClasses = False cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None) btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True) OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData) self.itemsets= None
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self,parent,signalManager,"BagofWords") self.inputs = [("Example Table", ExampleTable, self.dataset)] self.outputs = [("Bag-of-Words", ExampleTable)] self.TFIDF = 0 self.norm = 0 self.nDocuments = "N/A"; self.nStrAttributes = "N/A"; self.nWords = "N/A" self.textAttribute = None self.data = None self.loadSettings() box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True) OWGUI.label(box, self, "Documents: %(nDocuments)s") OWGUI.label(box, self, "String attributes: %(nStrAttributes)s") OWGUI.label(box, self, "Words: %(nWords)s") OWGUI.radioButtonsInBox(self.controlArea, self, "TFIDF", ["None", "log(1/f)"], "TFIDF", addSpace = True) OWGUI.radioButtonsInBox(self.controlArea, self, "norm", ["None", "L1 (Sum of elements)", "L2 (Euclidean)"], "Normalization", addSpace = True) self.attributesCombo = OWGUI.comboBox(self.controlArea, self, "textAttribute", box="Text attribute", callback=self.apply) OWGUI.rubber(self.controlArea) self.adjustSize()
def __init__(self, parent=None, signalManager=None): OWSubSQLSelect.__init__(self, parent, signalManager, "SQL select") self.sqlReader = orngSQL.SQLReader() self.inputs = [] self.outputs = [("Data", ExampleTable), ("Feature Definitions", orange.Domain)] #set default settings self.domain = None self.recentConnections = ["(none)"] self.queryFile = None self.query = '' self.lastQuery = None self.loadSettings() if self.lastQuery is not None: self.query = self.lastQuery self.connectString = self.recentConnections[0] self.connectBox = OWGUI.widgetBox(self.controlArea, "Database") self.connectLineEdit = OWGUI.lineEdit(self.connectBox, self, 'connectString', callback=self.connectDB) self.connectCombo = OWGUI.comboBox(self.connectBox, self, 'connectString', items=self.recentConnections, callback=self.selectConnection) button = OWGUI.button(self.connectBox, self, 'connect', callback=self.connectDB, disabled=0) #query self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitCanvas) self.textBox = OWGUI.widgetBox(self, 'SQL select') self.splitCanvas.addWidget(self.textBox) self.queryTextEdit = QPlainTextEdit(self.query, self) self.textBox.layout().addWidget(self.queryTextEdit) self.selectBox = OWGUI.widgetBox(self.controlArea, "Select statement") # self.selectSubmitBox = QHGroupBox("", self.selectBox) # self.queryTextEdit.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) # self.queryTextEdit.setMinimumWidth(300) # self.connect(self.queryTextEdit, SIGNAL('returnPressed()'), self.executeQuery) OWGUI.button(self.selectBox, self, "Open...", callback=self.openScript) OWGUI.button(self.selectBox, self, "Save...", callback=self.saveScript) self.selectBox.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) button = OWGUI.button(self.selectBox, self, 'execute!', callback=self.executeQuery, disabled=0) self.domainBox = OWGUI.widgetBox(self.controlArea, "Domain") self.domainLabel = OWGUI.label(self.domainBox, self, '') # info self.infoBox = OWGUI.widgetBox(self.controlArea, "Info") self.info = [] self.info.append(OWGUI.label(self.infoBox, self, 'No data loaded.')) self.info.append(OWGUI.label(self.infoBox, self, '')) self.resize(300, 300)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Python Script') self.inputs = [("in_data", Orange.data.Table, self.setExampleTable, Default), ("in_distance", Orange.misc.SymMatrix, self.setDistanceMatrix, Default), ("in_learner", Orange.core.Learner, self.setLearner, Default), ("in_classifier", Orange.core.Classifier, self.setClassifier, Default), ("in_object", object, self.setObject)] self.outputs = [("out_data", Orange.data.Table), ("out_distance", Orange.misc.SymMatrix), ("out_learner", Orange.core.Learner), ("out_classifier", Orange.core.Classifier, Dynamic), ("out_object", object, Dynamic)] self.in_data = None self.in_distance = None self.in_learner = None self.in_classifier = None self.in_object = None self.auto_execute = False self.libraryListSource = [Script("Hello world", "print 'Hello world'\n")] self.currentScriptIndex = 0 self.splitterState = None self.loadSettings() for s in self.libraryListSource: s.flags = 0 self._cachedDocuments = {} self.infoBox = OWGUI.widgetBox(self.controlArea, 'Info') OWGUI.label( self.infoBox, self, "<p>Execute python script.</p><p>Input variables:<ul><li> " + "<li>".join(t[0] for t in self.inputs) + "</ul></p><p>Output variables:<ul><li>" + "<li>".join(t[0] for t in self.outputs) + "</ul></p>" ) self.libraryList = PyListModel( [], self, flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable ) self.libraryList.wrap(self.libraryListSource) self.controlBox = OWGUI.widgetBox(self.controlArea, 'Library') self.controlBox.layout().setSpacing(1) self.libraryView = QListView( editTriggers=QListView.DoubleClicked | QListView.EditKeyPressed, sizePolicy=QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred) ) self.libraryView.setItemDelegate(ScriptItemDelegate(self)) self.libraryView.setModel(self.libraryList) self.libraryView.selectionModel().selectionChanged.connect( self.onSelectedScriptChanged ) self.controlBox.layout().addWidget(self.libraryView) w = ModelActionsWidget() self.addNewScriptAction = action = QAction("+", self) action.setToolTip("Add a new script to the library") action.triggered.connect(self.onAddScript) w.addAction(action) action = QAction(unicodedata.lookup("MINUS SIGN"), self) action.setToolTip("Remove script from library") action.triggered.connect(self.onRemoveScript) w.addAction(action) action = QAction("Update", self) action.setToolTip("Save changes in the editor to library") action.setShortcut(QKeySequence(QKeySequence.Save)) action.triggered.connect(self.commitChangesToLibrary) w.addAction(action) action = QAction("More", self, toolTip="More actions") new_from_file = QAction("Import a script from a file", self) save_to_file = QAction("Save selected script to a file", self) save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs)) new_from_file.triggered.connect(self.onAddScriptFromFile) save_to_file.triggered.connect(self.saveScript) menu = QMenu(w) menu.addAction(new_from_file) menu.addAction(save_to_file) action.setMenu(menu) button = w.addAction(action) button.setPopupMode(QToolButton.InstantPopup) w.layout().setSpacing(1) self.controlBox.layout().addWidget(w) self.runBox = OWGUI.widgetBox(self.controlArea, 'Run') OWGUI.button(self.runBox, self, "Execute", callback=self.execute) OWGUI.checkBox(self.runBox, self, "auto_execute", "Auto execute", tooltip=("Run the script automatically whenever " "the inputs to the widget change.")) self.splitter = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitter) self.defaultFont = defaultFont = \ "Monaco" if sys.platform == "darwin" else "Courier" self.textBox = OWGUI.widgetBox(self, 'Python script') self.splitter.addWidget(self.textBox) self.text = PythonScriptEditor(self) self.textBox.layout().addWidget(self.text) self.textBox.setAlignment(Qt.AlignVCenter) self.text.setTabStopWidth(4) self.text.modificationChanged[bool].connect(self.onModificationChanged) self.consoleBox = OWGUI.widgetBox(self, 'Console') self.splitter.addWidget(self.consoleBox) self.console = PythonConsole(self.__dict__, self) self.consoleBox.layout().addWidget(self.console) self.console.document().setDefaultFont(QFont(defaultFont)) self.consoleBox.setAlignment(Qt.AlignBottom) self.console.setTabStopWidth(4) select_row(self.libraryView, self.currentScriptIndex) self.splitter.setSizes([2, 1]) if self.splitterState is not None: self.splitter.restoreState(QByteArray(self.splitterState)) self.splitter.splitterMoved[int, int].connect(self.onSpliterMoved) self.controlArea.layout().addStretch(1) self.resize(800, 600)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates", TRUE) #add a graph widget self.graph = OWParallelGraph(self, self.mainArea) self.mainArea.layout().addWidget(self.graph) self.showAllAttributes = 0 self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes)] self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable), ("Features", AttributeList)] #set default settings self.data = None self.subsetData = None self.autoSendSelection = 1 self.attrDiscOrder = "Unordered" self.attrContOrder = "Unordered" self.projections = None self.correlationDict = {} self.middleLabels = "Correlations" self.attributeSelectionList = None self.toolbarSelection = 0 self.colorSettings = None self.selectedSchemaIndex = 0 self.graph.jitterSize = 10 self.graph.showDistributions = 1 self.graph.showStatistics = 0 self.graph.showAttrValues = 1 self.graph.useSplines = 0 self.graph.enabledLegend = 1 #load settings self.loadSettings() #GUI self.tabs = OWGUI.tabWidget(self.controlArea) self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main") self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") self.createShowHiddenLists(self.GeneralTab, callback=self.updateGraph) self.connect(self.shownAttribsLB, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.flipAttribute) self.optimizationDlg = ParallelOptimization( self, signalManager=self.signalManager) self.optimizationDlgButton = OWGUI.button( self.GeneralTab, self, "Optimization Dialog", callback=self.optimizationDlg.reshow, debuggingEnabled=0) self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar( self, self.GeneralTab, self.graph, self.autoSendSelection, buttons=(1, 2, 0, 7, 8)) self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections) #connect controls to appropriate functions self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) # #################################### # SETTINGS functionality box = OWGUI.widgetBox(self.SettingsTab, "Transparency") OWGUI.hSlider(box, self, 'graph.alphaValue', label="Examples: ", minValue=0, maxValue=255, step=10, callback=self.updateGraph, tooltip="Alpha value used for drawing example lines") OWGUI.hSlider( box, self, 'graph.alphaValue2', label="Rest: ", minValue=0, maxValue=255, step=10, callback=self.updateGraph, tooltip="Alpha value used to draw statistics, example subsets, ..." ) box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options") OWGUI.comboBox(box, self, "graph.jitterSize", label='Jittering size (% of size): ', orientation='horizontal', callback=self.setJitteringSize, items=self.jitterSizeNums, sendSelectedValue=1, valueType=float) # visual settings box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings") OWGUI.checkBox(box, self, 'graph.showAttrValues', 'Show attribute values', callback=self.updateGraph) OWGUI.checkBox(box, self, 'graph.useAntialiasing', 'Use antialiasing', callback=self.updateGraph) OWGUI.checkBox(box, self, 'graph.useSplines', 'Show splines', callback=self.updateGraph, tooltip="Show lines using splines") OWGUI.checkBox(box, self, 'graph.enabledLegend', 'Show legend', callback=self.updateGraph) box = OWGUI.widgetBox(self.SettingsTab, "Axis Distance") resizeColsBox = OWGUI.widgetBox(box, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Increase/decrease distance: ") b = OWGUI.toolButton(resizeColsBox, self, "+", callback=self.increaseAxesDistance, tooltip="Increase the distance between the axes", width=30, height=20) b = OWGUI.toolButton(resizeColsBox, self, "-", callback=self.decreaseAxesDistance, tooltip="Decrease the distance between the axes", width=30, height=20) OWGUI.rubber(resizeColsBox) OWGUI.checkBox( box, self, "graph.autoUpdateAxes", "Auto scale X axis", tooltip="Auto scale X axis to show all visualized attributes", callback=self.updateGraph) box = OWGUI.widgetBox(self.SettingsTab, "Statistical Information") OWGUI.comboBox( box, self, "graph.showStatistics", label="Statistics: ", orientation="horizontal", labelWidth=90, items=["No statistics", "Means, deviations", "Median, quartiles"], callback=self.updateGraph, sendSelectedValue=0, valueType=int) OWGUI.comboBox( box, self, "middleLabels", label="Middle labels: ", orientation="horizontal", labelWidth=90, items=["No labels", "Correlations", "VizRank"], callback=self.updateGraph, tooltip= "The information do you wish to view on top in the middle of coordinate axes", sendSelectedValue=1, valueType=str) OWGUI.checkBox( box, self, 'graph.showDistributions', 'Show distributions', callback=self.updateGraph, tooltip= "Show bars with distribution of class values (only for discrete attributes)" ) box = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation="horizontal") OWGUI.button( box, self, "Set colors", self.setColors, tooltip= "Set the canvas background color and color palette for coloring continuous variables", debuggingEnabled=0) box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...") OWGUI.checkBox( box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback=self.selectionChanged, tooltip= "Send selected data whenever a selection area is added or removed") OWGUI.checkBox( box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip= "Send selected data when a user moves or resizes an existing selection area" ) self.graph.autoSendSelectionCallback = self.selectionChanged self.SettingsTab.layout().addStretch(100) self.icons = self.createAttributeIconDict() dlg = self.createColorDialog() self.graph.contPalette = dlg.getContinuousPalette("contPalette") self.graph.discPalette = dlg.getDiscretePalette("discPalette") self.graph.setCanvasBackground(dlg.getColor("Canvas")) apply([ self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection ][self.toolbarSelection], []) self.cbShowAllAttributes() self.resize(900, 700)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Data Table") self.inputs = [("Examples", ExampleTable, self.dataset, Multiple + Default)] self.outputs = [("Selected Examples", ExampleTable)] self.data = {} # key: id, value: ExampleTable self.showMetas = {} # key: id, value: (True/False, columnList) self.showMeta = 1 self.showAttributeLabels = 1 self.showDistributions = 1 self.distColorRgb = (220, 220, 220, 255) self.distColor = QColor(*self.distColorRgb) self.locale = QLocale() self.autoCommit = False self.loadSettings() # info box infoBox = OWGUI.widgetBox(self.controlArea, "Info") self.infoEx = OWGUI.widgetLabel(infoBox, 'No data on input.') self.infoMiss = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoAttr = OWGUI.widgetLabel(infoBox, ' ') self.infoMeta = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoClass = OWGUI.widgetLabel(infoBox, ' ') infoBox.setMinimumWidth(200) OWGUI.separator(self.controlArea) # settings box boxSettings = OWGUI.widgetBox(self.controlArea, "Settings") self.cbShowMeta = OWGUI.checkBox(boxSettings, self, "showMeta", 'Show meta attributes', callback=self.cbShowMetaClicked) self.cbShowMeta.setEnabled(False) self.cbShowAttLbls = OWGUI.checkBox( boxSettings, self, "showAttributeLabels", 'Show attribute labels (if any)', callback=self.cbShowAttLabelsClicked) self.cbShowAttLbls.setEnabled(True) self.cbShowDistributions = OWGUI.checkBox( boxSettings, self, "showDistributions", 'Visualize continuous values', callback=self.cbShowDistributions) colBox = OWGUI.indentedBox(boxSettings, sep=OWGUI.checkButtonOffsetHint( self.cbShowDistributions), orientation="horizontal") OWGUI.widgetLabel(colBox, "Color: ") self.colButton = OWGUI.toolButton(colBox, self, self.changeColor, width=20, height=20, debuggingEnabled=0) OWGUI.rubber(colBox) resizeColsBox = OWGUI.widgetBox(boxSettings, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Resize columns: ") OWGUI.toolButton(resizeColsBox, self, self.increaseColWidth, tooltip="Increase the width of the columns", width=20, height=20).setText("+") OWGUI.toolButton(resizeColsBox, self, self.decreaseColWidth, tooltip="Decrease the width of the columns", width=20, height=20).setText("-") OWGUI.rubber(resizeColsBox) self.btnResetSort = OWGUI.button( boxSettings, self, "Restore Order of Examples", callback=self.btnResetSortClicked, tooltip="Show examples in the same order as they appear in the file" ) OWGUI.separator(self.controlArea) selectionBox = OWGUI.widgetBox(self.controlArea, "Selection") self.sendButton = OWGUI.button(selectionBox, self, "Send selections", self.commit) cb = OWGUI.checkBox(selectionBox, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.setStopper(self, self.sendButton, cb, "selectionChangedFlag", self.commit) OWGUI.rubber(self.controlArea) # GUI with tabs self.tabs = OWGUI.tabWidget(self.mainArea) self.id2table = {} # key: widget id, value: table self.table2id = {} # key: table, value: widget id self.connect(self.tabs, SIGNAL("currentChanged(QWidget*)"), self.tabClicked) self.selectionChangedFlag = False self.updateColor()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Python Script') self.inputs = [ ("in_data", Orange.data.Table, self.setExampleTable, Default), ("in_distance", Orange.misc.SymMatrix, self.setDistanceMatrix, Default), ("in_learner", Orange.core.Learner, self.setLearner, Default), ("in_classifier", Orange.core.Classifier, self.setClassifier, Default), ("in_object", object, self.setObject) ] self.outputs = [("out_data", Orange.data.Table), ("out_distance", Orange.misc.SymMatrix), ("out_learner", Orange.core.Learner), ("out_classifier", Orange.core.Classifier, Dynamic), ("out_object", object, Dynamic)] self.in_data = None self.in_distance = None self.in_learner = None self.in_classifier = None self.in_object = None self.auto_execute = False self.libraryListSource = [ Script("Hello world", "print 'Hello world'\n") ] self.currentScriptIndex = 0 self.splitterState = None self.loadSettings() for s in self.libraryListSource: s.flags = 0 self._cachedDocuments = {} self.infoBox = OWGUI.widgetBox(self.controlArea, 'Info') OWGUI.label( self.infoBox, self, "<p>Execute python script.</p><p>Input variables:<ul><li> " + "<li>".join(t[0] for t in self.inputs) + "</ul></p><p>Output variables:<ul><li>" + "<li>".join(t[0] for t in self.outputs) + "</ul></p>") self.libraryList = PyListModel([], self, flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable) self.libraryList.wrap(self.libraryListSource) self.controlBox = OWGUI.widgetBox(self.controlArea, 'Library') self.controlBox.layout().setSpacing(1) self.libraryView = QListView( editTriggers=QListView.DoubleClicked | QListView.EditKeyPressed, sizePolicy=QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)) self.libraryView.setItemDelegate(ScriptItemDelegate(self)) self.libraryView.setModel(self.libraryList) self.libraryView.selectionModel().selectionChanged.connect( self.onSelectedScriptChanged) self.controlBox.layout().addWidget(self.libraryView) w = ModelActionsWidget() self.addNewScriptAction = action = QAction("+", self) action.setToolTip("Add a new script to the library") action.triggered.connect(self.onAddScript) w.addAction(action) action = QAction(unicodedata.lookup("MINUS SIGN"), self) action.setToolTip("Remove script from library") action.triggered.connect(self.onRemoveScript) w.addAction(action) action = QAction("Update", self) action.setToolTip("Save changes in the editor to library") action.setShortcut(QKeySequence(QKeySequence.Save)) action.triggered.connect(self.commitChangesToLibrary) w.addAction(action) action = QAction("More", self, toolTip="More actions") new_from_file = QAction("Import a script from a file", self) save_to_file = QAction("Save selected script to a file", self) save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs)) new_from_file.triggered.connect(self.onAddScriptFromFile) save_to_file.triggered.connect(self.saveScript) menu = QMenu(w) menu.addAction(new_from_file) menu.addAction(save_to_file) action.setMenu(menu) button = w.addAction(action) button.setPopupMode(QToolButton.InstantPopup) w.layout().setSpacing(1) self.controlBox.layout().addWidget(w) self.runBox = OWGUI.widgetBox(self.controlArea, 'Run') OWGUI.button(self.runBox, self, "Execute", callback=self.execute) OWGUI.checkBox(self.runBox, self, "auto_execute", "Auto execute", tooltip=("Run the script automatically whenever " "the inputs to the widget change.")) self.splitter = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitter) self.defaultFont = defaultFont = \ "Monaco" if sys.platform == "darwin" else "Courier" self.textBox = OWGUI.widgetBox(self, 'Python script') self.splitter.addWidget(self.textBox) self.text = PythonScriptEditor(self) self.textBox.layout().addWidget(self.text) self.textBox.setAlignment(Qt.AlignVCenter) self.text.setTabStopWidth(4) self.text.modificationChanged[bool].connect(self.onModificationChanged) self.consoleBox = OWGUI.widgetBox(self, 'Console') self.splitter.addWidget(self.consoleBox) self.console = PythonConsole(self.__dict__, self) self.consoleBox.layout().addWidget(self.console) self.console.document().setDefaultFont(QFont(defaultFont)) self.consoleBox.setAlignment(Qt.AlignBottom) self.console.setTabStopWidth(4) select_row(self.libraryView, self.currentScriptIndex) self.splitter.setSizes([2, 1]) if self.splitterState is not None: self.splitter.restoreState(QByteArray(self.splitterState)) self.splitter.splitterMoved[int, int].connect(self.onSpliterMoved) self.controlArea.layout().addStretch(1) self.resize(800, 600)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Python Script') self.inputs = [ ("in_data", ExampleTable, self.setExampleTable), ("in_distance", orange.SymMatrix, self.setDistanceMatrix), ("in_network", Orange.network.Graph, self.setNetwork), ("in_learner", orange.Learner, self.setLearner), ("in_classifier", orange.Classifier, self.setClassifier) ] self.outputs = [("out_data", ExampleTable), ("out_distance", orange.SymMatrix), ("out_network", Orange.network.Graph), ("out_learner", orange.Learner), ("out_classifier", orange.Classifier, Dynamic)] self.in_data = None self.in_network = None self.in_distance = None self.in_learner = None self.in_classifier = None self.codeFile = '' self.libraryListSource = [ Script("Hello world", "print 'Hello world'\n") ] self.currentScriptIndex = 0 self.splitterState = None self.loadSettings() for s in self.libraryListSource: s.flags = 0 self._cachedDocuments = {} self.infoBox = OWGUI.widgetBox(self.controlArea, 'Info') label = OWGUI.label(self.infoBox, self, "<p>Execute python script.</p><p>Input variables:<ul><li> " + \ "<li>".join(t[0] for t in self.inputs) + "</ul></p><p>Output variables:<ul><li>" + \ "<li>".join(t[0] for t in self.outputs) + "</ul></p>") self.libraryList = PyListModel([], self, flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable) # self.libraryList.append(Script("Hello world", "print 'Hello world'\n")) self.libraryList.wrap(self.libraryListSource) self.controlBox = OWGUI.widgetBox(self.controlArea, 'Library') self.controlBox.layout().setSpacing(1) self.libraryView = QListView() self.libraryView.pyqtConfigure(editTriggers=QListView.DoubleClicked | QListView.SelectedClicked) self.libraryView.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred) self.libraryView.setItemDelegate(ScriptItemDelegate(self)) self.libraryView.setModel(self.libraryList) self.connect( self.libraryView.selectionModel(), SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.onSelectedScriptChanged) self.controlBox.layout().addWidget(self.libraryView) w = ModelActionsWidget() self.addNewScriptAction = action = QAction("+", self) action.pyqtConfigure(toolTip="Add a new script to the library") self.connect(action, SIGNAL("triggered()"), self.onAddScript) new_empty = QAction("Add a new empty script", action) new_from_file = QAction("Add a new script from a file", action) self.connect(new_empty, SIGNAL("triggered()"), self.onAddScript) self.connect(new_from_file, SIGNAL("triggered()"), self.onAddScriptFromFile) menu = QMenu(w) menu.addAction(new_empty) menu.addAction(new_from_file) # action.setMenu(menu) button = w.addAction(action) self.removeAction = action = QAction("-", self) action.pyqtConfigure(toolTip="Remove script from library") self.connect(action, SIGNAL("triggered()"), self.onRemoveScript) w.addAction(action) action = QAction("Update", self) action.pyqtConfigure(toolTip="Save changes in the editor to library") action.setShortcut(QKeySequence(QKeySequence.Save)) self.connect(action, SIGNAL("triggered()"), self.commitChangesToLibrary) b = w.addAction(action) # b.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) action = QAction("More", self) action.pyqtConfigure( toolTip="More actions" ) #, icon=self.style().standardIcon(QStyle.SP_ToolBarHorizontalExtensionButton)) self.openScriptFromFileAction = new_from_file = QAction( "Import a script from a file", self) self.saveScriptToFile = save_to_file = QAction( "Save selected script to a file", self) save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs)) self.connect(new_from_file, SIGNAL("triggered()"), self.onAddScriptFromFile) self.connect(save_to_file, SIGNAL("triggered()"), self.saveScript) menu = QMenu(w) menu.addAction(new_from_file) menu.addAction(save_to_file) action.setMenu(menu) b = w.addAction(action) b.setPopupMode(QToolButton.InstantPopup) ## TODO: set the space for the indicator w.layout().setSpacing(1) self.controlBox.layout().addWidget(w) # OWGUI.button(self.controlBox, self, "Open...", callback=self.openScript) # OWGUI.button(self.controlBox, self, "Save...", callback=self.saveScript) self.runBox = OWGUI.widgetBox(self.controlArea, 'Run') OWGUI.button(self.runBox, self, "Execute", callback=self.execute) self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitCanvas) self.defaultFont = defaultFont = "Monaco" if sys.platform == "darwin" else "Courier" self.textBox = OWGUI.widgetBox(self, 'Python script') self.splitCanvas.addWidget(self.textBox) self.text = PythonScriptEditor(self) self.textBox.layout().addWidget(self.text) self.textBox.setAlignment(Qt.AlignVCenter) self.text.setTabStopWidth(4) self.connect(self.text, SIGNAL("modificationChanged(bool)"), self.onModificationChanged) self.saveAction = action = QAction("&Save", self.text) action.pyqtConfigure(toolTip="Save script to file") action.setShortcut(QKeySequence(QKeySequence.Save)) action.setShortcutContext(Qt.WidgetWithChildrenShortcut) self.connect(action, SIGNAL("triggered()"), self.saveScript) self.consoleBox = OWGUI.widgetBox(self, 'Console') self.splitCanvas.addWidget(self.consoleBox) self.console = PythonConsole(self.__dict__, self) self.consoleBox.layout().addWidget(self.console) self.console.document().setDefaultFont(QFont(defaultFont)) self.consoleBox.setAlignment(Qt.AlignBottom) self.console.setTabStopWidth(4) self.openScript(self.codeFile) try: self.libraryView.selectionModel().select( self.libraryList.index(self.currentScriptIndex), QItemSelectionModel.ClearAndSelect) except Exception: pass self.splitCanvas.setSizes([2, 1]) if self.splitterState is not None: self.splitCanvas.restoreState(QByteArray(self.splitterState)) self.connect( self.splitCanvas, SIGNAL("splitterMoved(int, int)"), lambda pos, ind: setattr(self, "splitterState", str(self.splitCanvas.saveState()))) self.controlArea.layout().addStretch(1) self.resize(800, 600)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Nx Analysis", noReport=True, wantMainArea=False) self.inputs = [("Network", Orange.network.Graph, self.set_graph), ("Items", Orange.data.Table, self.set_items)] self.outputs = [("Network", Orange.network.Graph), ("Items", Orange.data.Table)] self.methods = [ ("number_of_nodes", True, "Number of nodes", GRAPHLEVEL, lambda G: G.number_of_nodes()), ("number_of_edges", True, "Number of edges", GRAPHLEVEL, lambda G: G.number_of_edges()), ("average_degree", True, "Average degree", GRAPHLEVEL, lambda G: numpy.average(G.degree().values())), ("diameter", False, "Diameter", GRAPHLEVEL, nx.diameter), ("radius", False, "Radius", GRAPHLEVEL, nx.radius), ("average_shortest_path_length", False, "Average shortest path length", GRAPHLEVEL, nx.average_shortest_path_length), ("density", True, "Density", GRAPHLEVEL, nx.density), ("degree_assortativity_coefficient", False, "Degree assortativity coefficient", GRAPHLEVEL, nx.degree_assortativity_coefficient), # additional attr needed #("attribute_assortativity_coefficient", False, "Attribute assortativity coefficient", GRAPHLEVEL, nx.attribute_assortativity_coefficient), #("numeric_assortativity_coefficient", False, "Numeric assortativity coefficient", GRAPHLEVEL, nx.numeric_assortativity_coefficient), ("degree_pearson_correlation_coefficient", False, "Degree pearson correlation coefficient", GRAPHLEVEL, nx.degree_pearson_correlation_coefficient), ("estrada_index", False, "Estrada index", GRAPHLEVEL, nx.estrada_index), ("graph_clique_number", False, "Graph clique number", GRAPHLEVEL, nx.graph_clique_number), ("graph_number_of_cliques", False, "Graph number of cliques", GRAPHLEVEL, nx.graph_number_of_cliques), ("transitivity", False, "Graph transitivity", GRAPHLEVEL, nx.transitivity), ("average_clustering", False, "Average clustering coefficient", GRAPHLEVEL, nx.average_clustering), ("number_connected_components", False, "Number of connected components", GRAPHLEVEL, nx.number_connected_components), ("number_strongly_connected_components", False, "Number of strongly connected components", GRAPHLEVEL, nx.number_strongly_connected_components), ("number_weakly_connected_components", False, "Number of weakly connected components", GRAPHLEVEL, nx.number_weakly_connected_components), ("number_attracting_components", False, "Number of attracting components", GRAPHLEVEL, nx.number_attracting_components), # TODO: input parameters #("max_flow", False, "Maximum flow", GRAPHLEVEL, nx.max_flow), #("min_cut", False, "Minimum cut", GRAPHLEVEL, nx.min_cut), #("ford_fulkerson", False, "Maximum single-commodity flow (Ford-Fulkerson)", GRAPHLEVEL, nx.ford_fulkerson), #("min_cost_flow_cost", False, "min_cost_flow_cost", GRAPHLEVEL, nx.min_cost_flow_cost), # returns dict of dict #("shortest_path_length", False, "Shortest path length", GRAPHLEVEL, nx.shortest_path_length), ("degree", False, "Degree", NODELEVEL, nx.degree), ("in_degree", False, "In-degree", NODELEVEL, lambda G: G.in_degree()), ("out_degree", False, "Out-degree", NODELEVEL, lambda G: G.out_degree()), ("average_neighbor_degree", False, "Average neighbor degree", NODELEVEL, nx.average_neighbor_degree), ("clustering", False, "Clustering coefficient", NODELEVEL, nx.clustering), ("triangles", False, "Number of triangles", NODELEVEL, nx.triangles), ("square_clustering", False, "Squares clustering coefficient", NODELEVEL, nx.square_clustering), ("number_of_cliques", False, "Number of cliques", NODELEVEL, nx.number_of_cliques), ("degree_centrality", False, "Degree centrality", NODELEVEL, nx.degree_centrality), ("in_degree_centrality", False, "In-egree centrality", NODELEVEL, nx.in_degree_centrality), ("out_degree_centrality", False, "Out-degree centrality", NODELEVEL, nx.out_degree_centrality), ("closeness_centrality", False, "Closeness centrality", NODELEVEL, nx.closeness_centrality), ("betweenness_centrality", False, "Betweenness centrality", NODELEVEL, nx.betweenness_centrality), ("current_flow_closeness_centrality", False, "Information centrality", NODELEVEL, nx.current_flow_closeness_centrality), ("current_flow_betweenness_centrality", False, "Random-walk betweenness centrality", NODELEVEL, nx.current_flow_betweenness_centrality), ("approximate_current_flow_betweenness_centrality", False, "Approx. random-walk betweenness centrality", NODELEVEL, nx.approximate_current_flow_betweenness_centrality), ("eigenvector_centrality", False, "Eigenvector centrality", NODELEVEL, nx.eigenvector_centrality), ("eigenvector_centrality_numpy", False, "Eigenvector centrality (NumPy)", NODELEVEL, nx.eigenvector_centrality_numpy), ("load_centrality", False, "Load centrality", NODELEVEL, nx.load_centrality), ("core_number", False, "Core number", NODELEVEL, nx.core_number), ("eccentricity", False, "Eccentricity", NODELEVEL, nx.eccentricity), ("closeness_vitality", False, "Closeness vitality", NODELEVEL, nx.closeness_vitality), ] self.auto_commit = False self.tab_index = 0 self.mutex = QMutex() self.graph = None self.items = None # items set by Items signal self.items_graph = None # items set by graph.items by Network signal self.items_analysis = None # items to output and merge with analysis result self.job_queue = [] self.job_working = [] self.analfeatures = [] self.analdata = {} for method in self.methods: setattr(self, method[0], method[1]) setattr(self, "lbl_" + method[0], "") self.loadSettings() self.tabs = OWGUI.tabWidget(self.controlArea) self.tabs.setMinimumWidth(450) self.graphIndices = OWGUI.createTabPage(self.tabs, "Graph-level indices") self.nodeIndices = OWGUI.createTabPage(self.tabs, "Node-level indices") self.tabs.setCurrentIndex(self.tab_index) self.connect(self.tabs, SIGNAL("currentChanged(int)"), lambda index: setattr(self, 'tab_index', index)) for name, default, label, type, algorithm in self.methods: if type == NODELEVEL: box = OWGUI.widgetBox(self.nodeIndices, orientation="horizontal") elif type == GRAPHLEVEL: box = OWGUI.widgetBox(self.graphIndices, orientation="horizontal") OWGUI.checkBox(box, self, name, label=label, callback=lambda n=name: self.method_clicked(n)) box.layout().addStretch(1) lbl = OWGUI.label(box, self, "%(lbl_" + name + ")s") setattr(self, "tool_" + name, lbl) self.graphIndices.layout().addStretch(1) self.nodeIndices.layout().addStretch(1) OWGUI.checkBox(self.controlArea, self, "auto_commit", label="Commit automatically") hb = OWGUI.widgetBox(self.controlArea, None, orientation='horizontal') self.btnCommit = OWGUI.button(hb, self, "Commit", callback=self.analyze, toggleButton=1) self.btnStopC = OWGUI.button( hb, self, "Stop current", callback=lambda current=True: self.stop_job(current)) self.btnStopA = OWGUI.button( hb, self, "Stop all", callback=lambda current=False: self.stop_job(current)) self.btnStopC.setEnabled(False) self.btnStopA.setEnabled(False) self.reportButton = OWGUI.button(hb, self, "&Report", self.reportAndFinish, debuggingEnabled=0) self.reportButton.setAutoDefault(0)
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Parallel Coordinates (Qt)", TRUE) #add a graph widget self.graph = OWParallelGraph(self, self.mainArea) self.mainArea.layout().addWidget(self.graph) self.showAllAttributes = 0 self.inputs = [("Data", ExampleTable, self.setData, Default), ("Data Subset", ExampleTable, self.setSubsetData), ("Features", AttributeList, self.setShownAttributes)] self.outputs = [("Selected Data", ExampleTable), ("Other Data", ExampleTable), ("Features", AttributeList)] #set default settings self.data = None self.subsetData = None self.autoSendSelection = 1 self.attrDiscOrder = "Unordered" self.attrContOrder = "Unordered" self.projections = None self.correlationDict = {} self.middleLabels = "Correlations" self.attributeSelectionList = None self.toolbarSelection = 0 self.colorSettings = None self.selectedSchemaIndex = 0 self.graph.jitterSize = 10 self.graph.showDistributions = 1 self.graph.showStatistics = 0 self.graph.showAttrValues = 1 self.graph.useSplines = 0 self.graph.show_legend = 1 #load settings self.loadSettings() #GUI self.tabs = OWGUI.tabWidget(self.controlArea) self.GeneralTab = OWGUI.createTabPage(self.tabs, "Main") self.SettingsTab = OWGUI.createTabPage(self.tabs, "Settings") self.createShowHiddenLists(self.GeneralTab, callback = self.updateGraph) self.connect(self.shownAttribsLB, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.flipAttribute) self.optimizationDlg = ParallelOptimization(self, signalManager = self.signalManager) self.optimizationDlgButton = OWGUI.button(self.GeneralTab, self, "Optimization Dialog", callback = self.optimizationDlg.reshow, debuggingEnabled = 0) self.zoomSelectToolbar = OWToolbars.ZoomSelectToolbar(self, self.GeneralTab, self.graph, self.autoSendSelection, buttons = (1, 2, 0, 7, 8)) self.connect(self.zoomSelectToolbar.buttonSendSelections, SIGNAL("clicked()"), self.sendSelections) #connect controls to appropriate functions self.connect(self.graphButton, SIGNAL("clicked()"), self.graph.saveToFile) # #################################### # SETTINGS functionality box = OWGUI.widgetBox(self.SettingsTab, "Transparency") OWGUI.hSlider(box, self, 'graph.alphaValue', label = "Examples: ", minValue=0, maxValue=255, step=10, callback = self.updateGraph, tooltip = "Alpha value used for drawing example lines") OWGUI.hSlider(box, self, 'graph.alphaValue2', label = "Rest: ", minValue=0, maxValue=255, step=10, callback = self.updateGraph, tooltip = "Alpha value used to draw statistics, example subsets, ...") box = OWGUI.widgetBox(self.SettingsTab, "Jittering Options") OWGUI.comboBox(box, self, "graph.jitterSize", label = 'Jittering size (% of size): ', orientation='horizontal', callback = self.setJitteringSize, items = self.jitterSizeNums, sendSelectedValue = 1, valueType = float) # visual settings box = OWGUI.widgetBox(self.SettingsTab, "Visual Settings") OWGUI.checkBox(box, self, 'graph.showAttrValues', 'Show attribute values', callback = self.updateGraph) OWGUI.checkBox(box, self, 'graph.useSplines', 'Show splines', callback = self.updateGraph, tooltip = "Show lines using splines") self.graph.gui.show_legend_check_box(box) box = OWGUI.widgetBox(self.SettingsTab, "Axis Distance") resizeColsBox = OWGUI.widgetBox(box, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Increase/decrease distance: ") b = OWGUI.toolButton(resizeColsBox, self, "+", callback=self.increaseAxesDistance, tooltip = "Increase the distance between the axes", width=30, height = 20) b = OWGUI.toolButton(resizeColsBox, self, "-", callback=self.decreaseAxesDistance, tooltip = "Decrease the distance between the axes", width=30, height = 20) OWGUI.rubber(resizeColsBox) OWGUI.checkBox(box, self, "graph.autoUpdateAxes", "Auto scale X axis", tooltip = "Auto scale X axis to show all visualized attributes", callback = self.updateGraph) box = OWGUI.widgetBox(self.SettingsTab, "Statistical Information") OWGUI.comboBox(box, self, "graph.showStatistics", label = "Statistics: ", orientation = "horizontal", labelWidth=90, items = ["No statistics", "Means, deviations", "Median, quartiles"], callback = self.updateGraph, sendSelectedValue = 0, valueType = int) OWGUI.comboBox(box, self, "middleLabels", label = "Middle labels: ", orientation="horizontal", labelWidth=90, items = ["No labels", "Correlations", "VizRank"], callback = self.updateGraph, tooltip = "The information do you wish to view on top in the middle of coordinate axes", sendSelectedValue = 1, valueType = str) OWGUI.checkBox(box, self, 'graph.showDistributions', 'Show distributions', callback = self.updateGraph, tooltip = "Show bars with distribution of class values (only for discrete attributes)") box = OWGUI.widgetBox(self.SettingsTab, "Colors", orientation = "horizontal") OWGUI.button(box, self, "Set colors", self.setColors, tooltip = "Set the canvas background color and color palette for coloring continuous variables", debuggingEnabled = 0) box = OWGUI.widgetBox(self.SettingsTab, "Auto Send Selected Data When...") OWGUI.checkBox(box, self, 'autoSendSelection', 'Adding/Removing selection areas', callback = self.selectionChanged, tooltip = "Send selected data whenever a selection area is added or removed") OWGUI.checkBox(box, self, 'graph.sendSelectionOnUpdate', 'Moving/Resizing selection areas', tooltip = "Send selected data when a user moves or resizes an existing selection area") self.graph.autoSendSelectionCallback = self.selectionChanged self.SettingsTab.layout().addStretch(100) self.icons = self.createAttributeIconDict() dlg = self.createColorDialog() self.graph.contPalette = dlg.getContinuousPalette("contPalette") self.graph.discPalette = dlg.getDiscretePalette("discPalette") self.graph.setCanvasBackground(dlg.getColor("Canvas")) apply([self.zoomSelectToolbar.actionZooming, self.zoomSelectToolbar.actionRectangleSelection, self.zoomSelectToolbar.actionPolygonSelection][self.toolbarSelection], []) self.cbShowAllAttributes() self.resize(900, 700)
def defineGUI(self): self.sBox = OWGUI.widgetBox(self.controlArea, "Execution environment") itms = [e[0] for e in self.execEnvs] OWGUI.radioButtonsInBox(self.sBox, self, "execEnv", btnLabels=itms) boxGrid = OWGUI.widgetBox(self.controlArea, 'Initial Point for the Optimizer') OWGUI.checkBox( boxGrid, self, 'UseGridSearch', 'Use Grid-Search', tooltip= 'Use Grid-Search to find the best initial point to start the optimization.<br>If not checked, the midrange point will be used as optimization initial point.' ) OWGUI.spin( boxGrid, self, 'nInnerPoints', 1, 100, step=1, label=' Number of inner points:', tooltip= 'Number of points to break down each variable to evaluate the initial point.<br>It will evaluate nInnerPoints^nOptimizedVars' ) OWGUI.separator(self.controlArea) self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling Method") itms = [e[0] for e in self.SMethods] self.comboDistItems = [ "Continuous", "Power2", "By Step", "Specific Values" ] OWGUI.radioButtonsInBox(self.sBox, self, "SMethod", btnLabels=itms) hBox = OWGUI.widgetBox(OWGUI.indentedBox(self.sBox)) #QWidget(hBox).setFixedSize(19, 8) OWGUI.spin(hBox, self, 'nFolds', 2, 100, step=1, label='Number of Folds: ') OWGUI.separator(self.controlArea) box2 = OWGUI.widgetBox(self.controlArea, 'Evaluation Method') width = 150 itms = [e[0] for e in self.CMethods] OWGUI.comboBox( box2, self, 'CMethod', items=itms, label='For Classifiers:', labelWidth=width, orientation='horizontal', tooltip='Method used for evaluation in case of classifiers.') itms = [e[0] for e in self.RMethods] OWGUI.comboBox( box2, self, 'RMethod', items=itms, label='For Regressors:', labelWidth=width, orientation='horizontal', tooltip='Method used for evaluation in case of regressors.') OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Reload Defaults ", callback=self.reloadDefaults) OWGUI.separator(self.controlArea) #OWGUI.separator(self.controlArea, height=24) infoBox = OWGUI.widgetBox(self.controlArea, "Optimizer status") self.infoStatus = OWGUI.label(infoBox, self, 'Waiting for inputs...') self.infoPars = OWGUI.label(infoBox, self, '') self.infoRes = OWGUI.label(infoBox, self, '') OWGUI.label(infoBox, self, '') self.infoErr = OWGUI.label(infoBox, self, '') OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self, "&Apply Settings ", callback=self.optimizeParameters) # Main area GUI import sip sip.delete(self.mainArea.layout()) self.mainLayout = QGridLayout(self.mainArea) mainRight = OWGUI.widgetBox(self.mainArea, "Parameters Configuration") mainRight.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.paramsTable = OWGUI.table( self.mainArea, rows=0, columns=0, selectionMode=QTableWidget.MultiSelection, addToLayout=0) #self.paramsTable.setLeftMargin(0) self.paramsTable.verticalHeader().hide() self.paramsTable.setSelectionMode(QTableWidget.NoSelection) self.paramsTable.setColumnCount(len(self.paramsNames)) #for i, m in enumerate(self.paramsNames): # self.paramsTable.setColumnStretchable(i, 0) # header.setLabel(i, m) self.paramsTable.setHorizontalHeaderLabels(self.paramsNames) #self.mainLayout.setColumnStretch(1, 100) #self.mainLayout.setRowStretch(2, 100) self.mainLayout.addWidget(self.paramsTable, 0, 0, 1, 2) self.mainLayout.addWidget( OWGUI.label( mainRight, self, 'Red - Parameter selected to be optimized\r\nGreen - Parameter optimized\r\nBlack - Parameter will not be optimized' ), 1, 0) self.mainLayout.addWidget( OWGUI.label( mainRight, self, 'N_EX - Number of Examples in dataset\r\nN_ATTR - Number of attributes in dataset' ), 1, 1) self.adjustSize() self.create()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Nx Analysis", noReport=True, wantMainArea=False) self.inputs = [("Network", Orange.network.Graph, self.set_graph), ("Items", Orange.data.Table, self.set_items)] self.outputs = [("Network", Orange.network.Graph), ("Items", Orange.data.Table)] self.methods = [ ("number_of_nodes", True, "Number of nodes", GRAPHLEVEL, lambda G: G.number_of_nodes()), ("number_of_edges", True, "Number of edges", GRAPHLEVEL, lambda G: G.number_of_edges()), ("average_degree", True, "Average degree", GRAPHLEVEL, lambda G: numpy.average(G.degree().values())), ("diameter", False, "Diameter", GRAPHLEVEL, nx.diameter), ("radius", False, "Radius", GRAPHLEVEL, nx.radius), ("average_shortest_path_length", False, "Average shortest path length", GRAPHLEVEL, nx.average_shortest_path_length), ("density", True, "Density", GRAPHLEVEL, nx.density), ("degree_assortativity_coefficient", False, "Degree assortativity coefficient", GRAPHLEVEL, nx.degree_assortativity_coefficient), # additional attr needed #("attribute_assortativity_coefficient", False, "Attribute assortativity coefficient", GRAPHLEVEL, nx.attribute_assortativity_coefficient), #("numeric_assortativity_coefficient", False, "Numeric assortativity coefficient", GRAPHLEVEL, nx.numeric_assortativity_coefficient), ("degree_pearson_correlation_coefficient", False, "Degree pearson correlation coefficient", GRAPHLEVEL, nx.degree_pearson_correlation_coefficient), ("estrada_index", False, "Estrada index", GRAPHLEVEL, nx.estrada_index), ("graph_clique_number", False, "Graph clique number", GRAPHLEVEL, nx.graph_clique_number), ("graph_number_of_cliques", False, "Graph number of cliques", GRAPHLEVEL, nx.graph_number_of_cliques), ("transitivity", False, "Graph transitivity", GRAPHLEVEL, nx.transitivity), ("average_clustering", False, "Average clustering coefficient", GRAPHLEVEL, nx.average_clustering), ("number_connected_components", False, "Number of connected components", GRAPHLEVEL, nx.number_connected_components), ("number_strongly_connected_components", False, "Number of strongly connected components", GRAPHLEVEL, nx.number_strongly_connected_components), ("number_weakly_connected_components", False, "Number of weakly connected components", GRAPHLEVEL, nx.number_weakly_connected_components), ("number_attracting_components", False, "Number of attracting components", GRAPHLEVEL, nx.number_attracting_components), # TODO: input parameters #("max_flow", False, "Maximum flow", GRAPHLEVEL, nx.max_flow), #("min_cut", False, "Minimum cut", GRAPHLEVEL, nx.min_cut), #("ford_fulkerson", False, "Maximum single-commodity flow (Ford-Fulkerson)", GRAPHLEVEL, nx.ford_fulkerson), #("min_cost_flow_cost", False, "min_cost_flow_cost", GRAPHLEVEL, nx.min_cost_flow_cost), # returns dict of dict #("shortest_path_length", False, "Shortest path length", GRAPHLEVEL, nx.shortest_path_length), ("degree", False, "Degree", NODELEVEL, nx.degree), ("in_degree", False, "In-degree", NODELEVEL, lambda G: G.in_degree()), ("out_degree", False, "Out-degree", NODELEVEL, lambda G: G.out_degree()), ("average_neighbor_degree", False, "Average neighbor degree", NODELEVEL, nx.average_neighbor_degree), ("clustering", False, "Clustering coefficient", NODELEVEL, nx.clustering), ("triangles", False, "Number of triangles", NODELEVEL, nx.triangles), ("square_clustering", False, "Squares clustering coefficient", NODELEVEL, nx.square_clustering), ("number_of_cliques", False, "Number of cliques", NODELEVEL, nx.number_of_cliques), ("degree_centrality", False, "Degree centrality", NODELEVEL, nx.degree_centrality), ("in_degree_centrality", False, "In-egree centrality", NODELEVEL, nx.in_degree_centrality), ("out_degree_centrality", False, "Out-degree centrality", NODELEVEL, nx.out_degree_centrality), ("closeness_centrality", False, "Closeness centrality", NODELEVEL, nx.closeness_centrality), ("betweenness_centrality", False, "Betweenness centrality", NODELEVEL, nx.betweenness_centrality), ("current_flow_closeness_centrality", False, "Information centrality", NODELEVEL, nx.current_flow_closeness_centrality), ("current_flow_betweenness_centrality", False, "Random-walk betweenness centrality", NODELEVEL, nx.current_flow_betweenness_centrality), ("approximate_current_flow_betweenness_centrality", False, "Approx. random-walk betweenness centrality", NODELEVEL, nx.approximate_current_flow_betweenness_centrality), ("eigenvector_centrality", False, "Eigenvector centrality", NODELEVEL, nx.eigenvector_centrality), ("eigenvector_centrality_numpy", False, "Eigenvector centrality (NumPy)", NODELEVEL, nx.eigenvector_centrality_numpy), ("load_centrality", False, "Load centrality", NODELEVEL, nx.load_centrality), ("core_number", False, "Core number", NODELEVEL, nx.core_number), ("eccentricity", False, "Eccentricity", NODELEVEL, nx.eccentricity), ("closeness_vitality", False, "Closeness vitality", NODELEVEL, nx.closeness_vitality), ] self.auto_commit = False self.tab_index = 0 self.mutex = QMutex() self.graph = None self.items = None # items set by Items signal self.items_graph = None # items set by graph.items by Network signal self.items_analysis = None # items to output and merge with analysis result self.job_queue = [] self.job_working = [] self.analfeatures = [] self.analdata = {} for method in self.methods: setattr(self, method[0], method[1]) setattr(self, "lbl_" + method[0], "") self.loadSettings() self.tabs = OWGUI.tabWidget(self.controlArea) self.tabs.setMinimumWidth(450) self.graphIndices = OWGUI.createTabPage(self.tabs, "Graph-level indices") self.nodeIndices = OWGUI.createTabPage(self.tabs, "Node-level indices") self.tabs.setCurrentIndex(self.tab_index) self.connect(self.tabs, SIGNAL("currentChanged(int)"), lambda index: setattr(self, 'tab_index', index)) for name, default, label, type, algorithm in self.methods: if type == NODELEVEL: box = OWGUI.widgetBox(self.nodeIndices, orientation="horizontal") elif type == GRAPHLEVEL: box = OWGUI.widgetBox(self.graphIndices, orientation="horizontal") OWGUI.checkBox(box, self, name, label=label, callback=lambda n=name: self.method_clicked(n)) box.layout().addStretch(1) lbl = OWGUI.label(box, self, "%(lbl_" + name + ")s") setattr(self, "tool_" + name, lbl) self.graphIndices.layout().addStretch(1) self.nodeIndices.layout().addStretch(1) OWGUI.checkBox(self.controlArea, self, "auto_commit", label="Commit automatically") hb = OWGUI.widgetBox(self.controlArea, None, orientation='horizontal') self.btnCommit = OWGUI.button(hb, self, "Commit", callback=self.analyze, toggleButton=1) self.btnStopC = OWGUI.button(hb, self, "Stop current", callback=lambda current=True: self.stop_job(current)) self.btnStopA = OWGUI.button(hb, self, "Stop all", callback=lambda current=False: self.stop_job(current)) self.btnStopC.setEnabled(False) self.btnStopA.setEnabled(False) self.reportButton = OWGUI.button(hb, self, "&Report", self.reportAndFinish, debuggingEnabled=0) self.reportButton.setAutoDefault(0)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Predictions") self.callbackDeposit = [] self.inputs = [("Examples", ExampleTable, self.setData), ("Predictors", orange.Classifier, self.setPredictor, Multiple)] self.outputs = [("Predictions", ExampleTable)] self.predictors = {} # saveble settings self.ShowAttributeMethod = 0 self.classes = [] self.selectedClasses = [] self.loadSettings() self.datalabel = "N/A" self.predictorlabel = "N/A" self.tasklabel = "N/A" self.outvar = None # current output variable (set by the first predictor/data set send in) self.classifications = [] self.rindx = None self.data = None self.verbose = 0 self.nVarImportance = 0 # GUI - Options # Options - classification ibox = OWGUI.widgetBox(self.controlArea, "Info") OWGUI.label(ibox, self, "Data: %(datalabel)s") OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s") OWGUI.label(ibox, self, "Task: %(tasklabel)s") OWGUI.separator(ibox) OWGUI.label( ibox, self, "Predictions can be viewed with the 'Data Table'\nand saved with the 'Save' widget!" ) OWGUI.separator(self.controlArea) self.copt = OWGUI.widgetBox(self.controlArea, "Probabilities (classification)") self.copt.setDisabled(1) self.lbcls = OWGUI.listBox(self.copt, self, "selectedClasses", "classes", selectionMode=QListWidget.MultiSelection) self.lbcls.setFixedHeight(50) OWGUI.separator(self.controlArea) self.VarImportanceBox = OWGUI.doubleSpin( self.controlArea, self, "nVarImportance", 0, 9999999, 1, label="Variable importance", orientation="horizontal", tooltip="The number of variables to report for each prediction.") OWGUI.checkBox( self.controlArea, self, 'verbose', 'Verbose', tooltip= 'Show detailed info while predicting. This will slow down the predictions process!' ) OWGUI.separator(self.controlArea) self.outbox = OWGUI.widgetBox(self.controlArea, "Output") self.apply = OWGUI.button(self.outbox, self, "Apply", callback=self.sendpredictions) OWGUI.rubber(self.controlArea) self.adjustSize()
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Predictions") self.callbackDeposit = [] self.inputs = [("Data", ExampleTable, self.setData), ("Predictors", orange.Classifier, self.setPredictor, Multiple)] self.outputs = [("Predictions", ExampleTable)] self.predictors = {} # saveble settings self.showProb = 1; self.showClass = 1 self.ShowAttributeMethod = 0 self.sendOnChange = 1 self.classes = [] self.selectedClasses = [] self.loadSettings() self.datalabel = "N/A" self.predictorlabel = "N/A" self.tasklabel = "N/A" self.precision = 2 self.doPrediction = False self.outvar = None # current output variable (set by the first predictor/data set send in) self.data = None self.changedFlag = False self.loadSettings() # GUI - Options # Options - classification ibox = OWGUI.widgetBox(self.controlArea, "Info") OWGUI.label(ibox, self, "Data: %(datalabel)s") OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s") OWGUI.label(ibox, self, "Task: %(tasklabel)s") OWGUI.separator(self.controlArea) self.copt = OWGUI.widgetBox(self.controlArea, "Options (classification)") self.copt.setDisabled(1) cb = OWGUI.checkBox(self.copt, self, 'showProb', "Show predicted probabilities", callback=self.setPredictionDelegate)#self.updateTableOutcomes) # self.lbClasses = OWGUI.listBox(self.copt, self, selectionMode = QListWidget.MultiSelection, callback = self.updateTableOutcomes) ibox = OWGUI.indentedBox(self.copt, sep=OWGUI.checkButtonOffsetHint(cb)) self.lbcls = OWGUI.listBox(ibox, self, "selectedClasses", "classes", callback=[self.setPredictionDelegate, self.checksendpredictions], # callback=[self.updateTableOutcomes, self.checksendpredictions], selectionMode=QListWidget.MultiSelection) self.lbcls.setFixedHeight(50) OWGUI.spin(ibox, self, "precision", 1, 6, label="No. of decimals: ", orientation=0, callback=self.setPredictionDelegate) #self.updateTableOutcomes) cb.disables.append(ibox) ibox.setEnabled(bool(self.showProb)) OWGUI.checkBox(self.copt, self, 'showClass', "Show predicted class", callback=[self.setPredictionDelegate, self.checksendpredictions]) # callback=[self.updateTableOutcomes, self.checksendpredictions]) OWGUI.separator(self.controlArea) self.att = OWGUI.widgetBox(self.controlArea, "Data attributes") OWGUI.radioButtonsInBox(self.att, self, 'ShowAttributeMethod', ['Show all', 'Hide all'], callback=lambda :self.setDataModel(self.data)) #self.updateAttributes) self.att.setDisabled(1) OWGUI.rubber(self.controlArea) OWGUI.separator(self.controlArea) self.outbox = OWGUI.widgetBox(self.controlArea, "Output") b = self.commitBtn = OWGUI.button(self.outbox, self, "Send Predictions", callback=self.sendpredictions, default=True) cb = OWGUI.checkBox(self.outbox, self, 'sendOnChange', 'Send automatically') OWGUI.setStopper(self, b, cb, "changedFlag", callback=self.sendpredictions) OWGUI.checkBox(self.outbox, self, "doPrediction", "Replace/add predicted class", tooltip="Apply the first predictor to input examples and replace/add the predicted value as the new class variable.", callback=self.checksendpredictions) self.outbox.setDisabled(1) ## GUI table self.splitter = splitter = QSplitter(Qt.Horizontal, self.mainArea) self.dataView = QTableView() self.predictionsView = QTableView() self.dataView.verticalHeader().setDefaultSectionSize(22) self.dataView.setHorizontalScrollMode(QTableWidget.ScrollPerPixel) self.dataView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.dataView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.predictionsView.verticalHeader().setDefaultSectionSize(22) self.predictionsView.setHorizontalScrollMode(QTableWidget.ScrollPerPixel) self.predictionsView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.predictionsView.verticalHeader().hide() # def syncVertical(value): # """ sync vertical scroll positions of the two views # """ # v1 = self.predictionsView.verticalScrollBar().value() # if v1 != value: # self.predictionsView.verticalScrollBar().setValue(value) # v2 = self.dataView.verticalScrollBar().value() # if v2 != value: # self.dataView.verticalScrollBar().setValue(v1) self.connect(self.dataView.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.syncVertical) self.connect(self.predictionsView.verticalScrollBar(), SIGNAL("valueChanged(int)"), self.syncVertical) splitter.addWidget(self.dataView) splitter.addWidget(self.predictionsView) splitter.setHandleWidth(3) splitter.setChildrenCollapsible(False) self.mainArea.layout().addWidget(splitter) self.spliter_restore_state = -1, 0 self.dataModel = None self.predictionsModel = None self.resize(800, 600) self.handledAllSignalsFlag = False
def __init__(self, parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Data Table") self.inputs = [("Data", ExampleTable, self.dataset, Multiple + Default)] self.outputs = [("Selected Data", ExampleTable, Default), ("Other Data", ExampleTable)] self.data = {} # key: id, value: ExampleTable self.showMetas = {} # key: id, value: (True/False, columnList) self.showMeta = 1 self.showAttributeLabels = 1 self.showDistributions = 1 self.distColorRgb = (220,220,220, 255) self.distColor = QColor(*self.distColorRgb) self.locale = QLocale() self.autoCommit = False self.colorSettings = None self.selectedSchemaIndex = 0 self.colorByClass = True self.loadSettings() # info box infoBox = OWGUI.widgetBox(self.controlArea, "Info") self.infoEx = OWGUI.widgetLabel(infoBox, 'No data on input.') self.infoMiss = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoAttr = OWGUI.widgetLabel(infoBox, ' ') self.infoMeta = OWGUI.widgetLabel(infoBox, ' ') OWGUI.widgetLabel(infoBox, ' ') self.infoClass = OWGUI.widgetLabel(infoBox, ' ') infoBox.setMinimumWidth(200) OWGUI.separator(self.controlArea) # settings box boxSettings = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True) self.cbShowMeta = OWGUI.checkBox(boxSettings, self, "showMeta", 'Show meta attributes', callback = self.cbShowMetaClicked) self.cbShowMeta.setEnabled(False) self.cbShowAttLbls = OWGUI.checkBox(boxSettings, self, "showAttributeLabels", 'Show attribute labels (if any)', callback = self.cbShowAttLabelsClicked) self.cbShowAttLbls.setEnabled(True) box = OWGUI.widgetBox(self.controlArea, "Colors") OWGUI.checkBox(box, self, "showDistributions", 'Visualize continuous values', callback = self.cbShowDistributions) OWGUI.checkBox(box, self, "colorByClass", 'Color by class value', callback = self.cbShowDistributions) OWGUI.button(box, self, "Set colors", self.setColors, tooltip = "Set the canvas background color and color palette for coloring continuous variables", debuggingEnabled = 0) resizeColsBox = OWGUI.widgetBox(boxSettings, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Resize columns: ") OWGUI.toolButton(resizeColsBox, self, "+", self.increaseColWidth, tooltip = "Increase the width of the columns", width=20, height=20) OWGUI.toolButton(resizeColsBox, self, "-", self.decreaseColWidth, tooltip = "Decrease the width of the columns", width=20, height=20) OWGUI.rubber(resizeColsBox) self.btnResetSort = OWGUI.button(boxSettings, self, "Restore Order of Examples", callback = self.btnResetSortClicked, tooltip = "Show examples in the same order as they appear in the file") OWGUI.separator(self.controlArea) selectionBox = OWGUI.widgetBox(self.controlArea, "Selection") self.sendButton = OWGUI.button(selectionBox, self, "Send selections", self.commit, default=True) cb = OWGUI.checkBox(selectionBox, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.setStopper(self, self.sendButton, cb, "selectionChangedFlag", self.commit) OWGUI.rubber(self.controlArea) dlg = self.createColorDialog() self.discPalette = dlg.getDiscretePalette("discPalette") # GUI with tabs self.tabs = OWGUI.tabWidget(self.mainArea) self.id2table = {} # key: widget id, value: table self.table2id = {} # key: table, value: widget id self.connect(self.tabs, SIGNAL("currentChanged(QWidget*)"), self.tabClicked) self.selectionChangedFlag = False
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Predictions") self.callbackDeposit = [] self.inputs = [("Examples", ExampleTable, self.setData), ("Predictors", orange.Classifier, self.setPredictor, Multiple)] self.outputs = [("Predictions", ExampleTable)] self.predictors = {} # saveble settings self.showProb = 1 self.showClass = 1 self.ShowAttributeMethod = 0 self.sendOnChange = 1 self.classes = [] self.selectedClasses = [] self.loadSettings() self.datalabel = "N/A" self.predictorlabel = "N/A" self.tasklabel = "N/A" self.precision = 2 self.outvar = None # current output variable (set by the first predictor/data set send in) self.data = None # GUI - Options # Options - classification ibox = OWGUI.widgetBox(self.controlArea, "Info") OWGUI.label(ibox, self, "Data: %(datalabel)s") OWGUI.label(ibox, self, "Predictors: %(predictorlabel)s") OWGUI.label(ibox, self, "Task: %(tasklabel)s") OWGUI.separator(self.controlArea) self.copt = OWGUI.widgetBox(self.controlArea, "Options (classification)") self.copt.setDisabled(1) OWGUI.checkBox(self.copt, self, 'showProb', "Show predicted probabilities", callback=self.updateTableOutcomes) # self.lbClasses = OWGUI.listBox(self.copt, self, selectionMode = QListWidget.MultiSelection, callback = self.updateTableOutcomes) self.lbcls = OWGUI.listBox( self.copt, self, "selectedClasses", "classes", callback=[self.updateTableOutcomes, self.checksendpredictions], selectionMode=QListWidget.MultiSelection) self.lbcls.setFixedHeight(50) OWGUI.spin(self.copt, self, "precision", 1, 6, label="No. of decimals: ", orientation=0, callback=self.updateTableOutcomes) OWGUI.checkBox( self.copt, self, 'showClass', "Show predicted class", callback=[self.updateTableOutcomes, self.checksendpredictions]) # Options - regression # self.ropt = QVButtonGroup("Options (regression)", self.controlArea) # OWGUI.checkBox(self.ropt, self, 'showClass', "Show predicted class", # callback=[self.updateTableOutcomes, self.checksendpredictions]) # self.ropt.hide() OWGUI.separator(self.controlArea) self.att = OWGUI.widgetBox(self.controlArea, "Data attributes") OWGUI.radioButtonsInBox(self.att, self, 'ShowAttributeMethod', ['Show all', 'Hide all'], callback=self.updateAttributes) self.att.setDisabled(1) OWGUI.rubber(self.controlArea) OWGUI.separator(self.controlArea) self.outbox = OWGUI.widgetBox(self.controlArea, "Output") self.commitBtn = OWGUI.button(self.outbox, self, "Send Predictions", callback=self.sendpredictions) OWGUI.checkBox(self.outbox, self, 'sendOnChange', 'Send automatically') self.outbox.setDisabled(1) # GUI - Table self.table = OWGUI.table(self.mainArea, selectionMode=QTableWidget.NoSelection) self.table.setItemDelegate(OWGUI.TableBarItem(self)) self.header = self.table.horizontalHeader() self.vheader = self.table.verticalHeader() # manage sorting (not correct, does not handle real values) self.connect(self.header, SIGNAL("sectionPressed(int)"), self.sort) self.sortby = -1 self.resize(800, 600)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'MultiData Python Script') self.inputs = [("in_data", ExampleTable, self.setExampleTable, Default + Multiple), ("in_distance", orange.SymMatrix, self.setDistanceMatrix), ("in_network", Orange.network.Graph, self.setNetwork), ("in_learners", orange.Learner, self.setLearner, Default + Multiple), ("in_classifiers", orange.Classifier, self.setClassifier, Default + Multiple), ("in_misc", object, self.setMisc, Default + Multiple)] self.outputs = [("out_data", ExampleTable), ("out_distance", orange.SymMatrix), ("out_network", Orange.network.Graph), ("out_learner", orange.Learner), ("out_classifier", orange.Classifier, Dynamic), ("out_test_results", Orange.evaluation.testing.ExperimentResults), ("out_misc", object)] self.in_data = [] self.in_data_dict = {} # TODO: switch to weakref? self.in_learners = [] self.in_learner_dict = {} self.in_classifiers = [] self.in_classifier_dict = {} self.in_misc = [] self.in_misc_dict = {} self.in_network = None self.in_distance = None self.codeFile = '' self.libraryListSource = [Script("Hello world", "print 'Hello world'\n")] self.currentScriptIndex = 0 self.splitterState = None self.loadSettings() for s in self.libraryListSource: s.flags = 0 self._cachedDocuments = {} self.infoBox = OWGUI.widgetBox(self.controlArea, 'Info') label = OWGUI.label(self.infoBox, self, "<p>Execute python script.</p><p>Input variables:<ul><li> " + \ "<li>".join(t[0] for t in self.inputs) + "</ul></p><p>Output variables:<ul><li>" + \ "<li>".join(t[0] for t in self.outputs) + "</ul></p>") self.libraryList = PyListModel([], self, flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable) # self.libraryList.append(Script("Hello world", "print 'Hello world'\n")) self.libraryList.wrap(self.libraryListSource) self.controlBox = OWGUI.widgetBox(self.controlArea, 'Library') self.controlBox.layout().setSpacing(1) self.libraryView = QListView() self.libraryView.setEditTriggers(QListView.DoubleClicked | QListView.EditKeyPressed) self.libraryView.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred) self.libraryView.setItemDelegate(ScriptItemDelegate(self)) self.libraryView.setModel(self.libraryList) self.connect(self.libraryView.selectionModel(), SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.onSelectedScriptChanged) self.controlBox.layout().addWidget(self.libraryView) w = ModelActionsWidget() self.addNewScriptAction = action = QAction("+", self) action.pyqtConfigure(toolTip="Add a new script to the library") self.connect(action, SIGNAL("triggered()"), self.onAddScript) new_empty = QAction("Add a new empty script", action) new_from_file = QAction("Add a new script from a file", action) self.connect(new_empty, SIGNAL("triggered()"), self.onAddScript) self.connect(new_from_file, SIGNAL("triggered()"), self.onAddScriptFromFile) menu = QMenu(w) menu.addAction(new_empty) menu.addAction(new_from_file) # action.setMenu(menu) button = w.addAction(action) self.removeAction = action = QAction("-", self) action.pyqtConfigure(toolTip="Remove script from library") self.connect(action, SIGNAL("triggered()"), self.onRemoveScript) w.addAction(action) action = QAction("Update", self) action.pyqtConfigure(toolTip="Save changes in the editor to library") action.setShortcut(QKeySequence(QKeySequence.Save)) self.connect(action, SIGNAL("triggered()"), self.commitChangesToLibrary) b = w.addAction(action) # b.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) action = QAction("More", self) action.pyqtConfigure(toolTip="More actions") #, icon=self.style().standardIcon(QStyle.SP_ToolBarHorizontalExtensionButton)) self.openScriptFromFileAction = new_from_file = QAction("Import a script from a file", self) self.saveScriptToFile = save_to_file = QAction("Save selected script to a file", self) save_to_file.setShortcut(QKeySequence(QKeySequence.SaveAs)) self.connect(new_from_file, SIGNAL("triggered()"), self.onAddScriptFromFile) self.connect(save_to_file, SIGNAL("triggered()"), self.saveScript) menu = QMenu(w) menu.addAction(new_from_file) menu.addAction(save_to_file) action.setMenu(menu) b = w.addAction(action) b.setPopupMode(QToolButton.InstantPopup) ## TODO: set the space for the indicator w.layout().setSpacing(1) self.controlBox.layout().addWidget(w) # OWGUI.button(self.controlBox, self, "Open...", callback=self.openScript) # OWGUI.button(self.controlBox, self, "Save...", callback=self.saveScript) self.runBox = OWGUI.widgetBox(self.controlArea, 'Run') OWGUI.button(self.runBox, self, "Execute", callback=self.execute) self.splitCanvas = QSplitter(Qt.Vertical, self.mainArea) self.mainArea.layout().addWidget(self.splitCanvas) self.defaultFont = defaultFont = "Monaco" if sys.platform == "darwin" else "Courier" self.textBox = OWGUI.widgetBox(self, 'MultiData Python script') self.splitCanvas.addWidget(self.textBox) self.text = PythonScriptEditor(self) self.textBox.layout().addWidget(self.text) self.textBox.setAlignment(Qt.AlignVCenter) self.text.setTabStopWidth(4) self.connect(self.text, SIGNAL("modificationChanged(bool)"), self.onModificationChanged) self.saveAction = action = QAction("&Save", self.text) action.pyqtConfigure(toolTip="Save script to file") action.setShortcut(QKeySequence(QKeySequence.Save)) action.setShortcutContext(Qt.WidgetWithChildrenShortcut) self.connect(action, SIGNAL("triggered()"), self.saveScript) self.consoleBox = OWGUI.widgetBox(self, 'Console') self.splitCanvas.addWidget(self.consoleBox) self.console = PythonConsole(self.__dict__, self) self.consoleBox.layout().addWidget(self.console) self.console.document().setDefaultFont(QFont(defaultFont)) self.consoleBox.setAlignment(Qt.AlignBottom) self.console.setTabStopWidth(4) self.openScript(self.codeFile) try: self.libraryView.selectionModel().select(self.libraryList.index(self.currentScriptIndex), QItemSelectionModel.ClearAndSelect) except Exception: pass self.splitCanvas.setSizes([2, 1]) if self.splitterState is not None: self.splitCanvas.restoreState(QByteArray(self.splitterState)) self.connect(self.splitCanvas, SIGNAL("splitterMoved(int, int)"), lambda pos, ind: setattr(self, "splitterState", str(self.splitCanvas.saveState()))) self.controlArea.layout().addStretch(1) self.resize(800,600)
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Association rules viewer") self.inputs = [("Association Rules", orange.AssociationRules, self.arules)] self.outputs = [("Association Rules", orange.AssociationRules), ("Covered Data", ExampleTable), ("Matching Data", ExampleTable), ("Mismatched Data", ExampleTable)] self.showWholeRules = 1 self.treeDepth = 2 self.autoSend = True self.dataChanged = False self.purgeAttributes = True self.purgeClasses = True self.nRules = self.nSelectedRules = self.nSelectedExamples = self.nMatchingExamples = self.nMismatchingExamples = "" self.showsupport = self.showconfidence = 1 self.showlift = self.showleverage = self.showstrength = self.showcoverage = 0 self.loadSettings() # self.grid = QGridLayout() # rightUpRight = OWGUI.widgetBox(self.mainArea, box="Shown measures", orientation = self.grid) # self.cbMeasures = [OWGUI.checkBox(rightUpRight, self, "show"+attr, long, callback = self.showHideColumn, addToLayout = 0) for long, short, attr in self.measures] # for i, cb in enumerate(self.cbMeasures): # self.grid.addWidget(cb, i % 2, i / 2) box = OWGUI.widgetBox(self.mainArea, orientation=0) OWGUI.widgetLabel(box, "Shown measures: ") self.cbMeasures = [ OWGUI.checkBox(box, self, "show" + attr, long + " ", callback=self.showHideColumn) for long, short, attr in self.measures ] OWGUI.rubber(box) self.treeRules = QTreeWidget(self.mainArea) self.mainArea.layout().addWidget(self.treeRules) self.treeRules.setSelectionMode(QTreeWidget.ExtendedSelection) self.treeRules.setHeaderLabels(["Rules"] + [m[1] for m in self.measures]) self.treeRules.setAllColumnsShowFocus(1) self.treeRules.setAlternatingRowColors(1) self.showHideColumn() self.connect(self.treeRules, SIGNAL("itemSelectionChanged()"), self.selectionChanged) box = OWGUI.widgetBox(self.controlArea, "Info", addSpace=True) OWGUI.label(box, self, "Number of rules: %(nRules)s") OWGUI.label(box, self, "Selected rules: %(nSelectedRules)s") OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s") ibox = OWGUI.indentedBox(box) OWGUI.label(ibox, self, "... matching: %(nMatchingExamples)s") OWGUI.label(ibox, self, "... mismatching: %(nMismatchingExamples)s") box = OWGUI.widgetBox(self.controlArea, "Options", addSpace=True) OWGUI.spin(box, self, "treeDepth", label="Tree depth", min=0, max=10, step=1, callback=self.displayRules, callbackOnReturn=True) OWGUI.separator(box) OWGUI.checkBox(box, self, "showWholeRules", "Display whole rules", callback=self.setWholeRules) OWGUI.rubber(self.controlArea) boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection') OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged) self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged) if not self.purgeAttributes: self.purgeClassesCB.setEnabled(False) self.oldPurgeClasses = False cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None) btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True) OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData) self.rules = None
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, 'Itemset visualizer') self.inputs = [("Graph with Data", orange.Graph, self.setGraph), ("Data Subset", orange.ExampleTable, self.setExampleSubset)] self.outputs = [("Selected Data", ExampleTable), ("Selected Graph", orange.Graph)] self.markerAttributes = [] self.tooltipAttributes = [] self.attributes = [] self.autoSendSelection = False self.graphShowGrid = 1 # show gridlines in the graph self.markNConnections = 2 self.markNumber = 0 self.markProportion = 0 self.markSearchString = "" self.markDistance = 2 self.frSteps = 1 self.hubs = 0 self.color = 0 self.nVertices = self.nMarked = self.nSelected = self.nHidden = self.nShown = self.nEdges = self.verticesPerEdge = self.edgesPerVertex = self.diameter = 0 self.optimizeWhat = 1 self.stopOptimization = 0 self.loadSettings() self.visualize = None self.graph = OWIntemsetCanvas(self, self.mainArea, "Network") #start of content (right) area self.box = QVBoxLayout(self.mainArea) self.box.addWidget(self.graph) self.tabs = QTabWidget(self.controlArea) self.displayTab = QVGroupBox(self) self.mainTab = self.displayTab self.markTab = QVGroupBox(self) self.infoTab = QVGroupBox(self) self.protoTab = QVGroupBox(self) self.tabs.insertTab(self.displayTab, "Display") self.tabs.insertTab(self.markTab, "Mark") self.tabs.insertTab(self.infoTab, "Info") self.tabs.insertTab(self.protoTab, "Prototypes") OWGUI.separator(self.controlArea) self.optimizeBox = OWGUI.radioButtonsInBox(self.mainTab, self, "optimizeWhat", [], "Optimize", addSpace=False) OWGUI.button(self.optimizeBox, self, "Random", callback=self.random) self.frButton = OWGUI.button(self.optimizeBox, self, "Fruchterman Reingold", callback=self.fr, toggleButton=1) OWGUI.spin(self.optimizeBox, self, "frSteps", 1, 10000, 1, label="Iterations: ") OWGUI.button(self.optimizeBox, self, "F-R Radial", callback=self.frRadial) OWGUI.button(self.optimizeBox, self, "Circular Original", callback=self.circularOriginal) OWGUI.button(self.optimizeBox, self, "Circular Crossing Reduction", callback=self.circularCrossingReduction) self.showLabels = 0 OWGUI.checkBox(self.mainTab, self, 'showLabels', 'Show labels', callback=self.showLabelsClick) self.labelsOnMarkedOnly = 0 OWGUI.checkBox(self.mainTab, self, 'labelsOnMarkedOnly', 'Show labels on marked nodes only', callback=self.labelsOnMarked) OWGUI.separator(self.mainTab) OWGUI.button(self.mainTab, self, "Show degree distribution", callback=self.showDegreeDistribution) OWGUI.button(self.mainTab, self, "Save network", callback=self.saveNetwork) ib = OWGUI.widgetBox(self.markTab, "Info", addSpace=True) OWGUI.label( ib, self, "Vertices (shown/hidden): %(nVertices)i (%(nShown)i/%(nHidden)i)") OWGUI.label( ib, self, "Selected and marked vertices: %(nSelected)i - %(nMarked)i") ribg = OWGUI.radioButtonsInBox(self.markTab, self, "hubs", [], "Method", callback=self.setHubs, addSpace=True) OWGUI.appendRadioButton(ribg, self, "hubs", "Mark vertices given in the input signal") OWGUI.appendRadioButton(ribg, self, "hubs", "Find vertices which label contain") self.ctrlMarkSearchString = OWGUI.lineEdit( OWGUI.indentedBox(ribg), self, "markSearchString", callback=self.setSearchStringTimer, callbackOnType=True) self.searchStringTimer = QTimer(self) self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.setHubs) OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of focused vertex") OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of selected vertices") ib = OWGUI.indentedBox(ribg, orientation=0) self.ctrlMarkDistance = OWGUI.spin( ib, self, "markDistance", 0, 100, 1, label="Distance ", callback=(lambda h=2: self.setHubs(h))) self.ctrlMarkFreeze = OWGUI.button(ib, self, "&Freeze", value="graph.freezeNeighbours", toggleButton=True) OWGUI.widgetLabel(ribg, "Mark vertices with ...") OWGUI.appendRadioButton(ribg, self, "hubs", "at least N connections") OWGUI.appendRadioButton(ribg, self, "hubs", "at most N connections") self.ctrlMarkNConnections = OWGUI.spin( OWGUI.indentedBox(ribg), self, "markNConnections", 0, 1000000, 1, label="N ", callback=(lambda h=4: self.setHubs(h))) OWGUI.appendRadioButton(ribg, self, "hubs", "more connections than any neighbour") OWGUI.appendRadioButton(ribg, self, "hubs", "more connections than avg neighbour") OWGUI.appendRadioButton(ribg, self, "hubs", "most connections") ib = OWGUI.indentedBox(ribg) self.ctrlMarkNumber = OWGUI.spin( ib, self, "markNumber", 0, 1000000, 1, label="Number of vertices" + ": ", callback=(lambda h=8: self.setHubs(h))) OWGUI.widgetLabel(ib, "(More vertices are marked in case of ties)") ib = QHGroupBox("Selection", self.markTab) btnM2S = OWGUI.button(ib, self, "", callback=self.markedToSelection) btnM2S.setPixmap(QPixmap(dlg_mark2sel)) QToolTip.add(btnM2S, "Add Marked to Selection") btnS2M = OWGUI.button(ib, self, "", callback=self.markedFromSelection) btnS2M.setPixmap(QPixmap(dlg_sel2mark)) QToolTip.add(btnS2M, "Remove Marked from Selection") btnSIM = OWGUI.button(ib, self, "", callback=self.setSelectionToMarked) btnSIM.setPixmap(QPixmap(dlg_selIsmark)) QToolTip.add(btnSIM, "Set Selection to Marked") self.hideBox = QHGroupBox("Hide vertices", self.markTab) btnSEL = OWGUI.button(self.hideBox, self, "", callback=self.hideSelected) btnSEL.setPixmap(QPixmap(dlg_selected)) QToolTip.add(btnSEL, "Selected") btnUN = OWGUI.button(self.hideBox, self, "", callback=self.hideAllButSelected) btnUN.setPixmap(QPixmap(dlg_unselected)) QToolTip.add(btnUN, "Unselected") OWGUI.button(self.hideBox, self, "Show", callback=self.showAllNodes) T = OWToolbars.NavigateSelectToolbar self.zoomSelectToolbar = OWToolbars.NavigateSelectToolbar( self, self.controlArea, self.graph, self.autoSendSelection, buttons=(T.IconZoom, T.IconZoomExtent, T.IconZoomSelection, ("", "", "", None, None, 0, "navigate"), T.IconPan, ("Move selection", "buttonMoveSelection", "activateMoveSelection", QPixmap(OWToolbars.dlg_select), Qt.arrowCursor, 1, "select"), T.IconRectangle, T.IconPolygon, ("", "", "", None, None, 0, "select"), T.IconSendSelection)) ib = OWGUI.widgetBox(self.infoTab, "General", addSpace=True) OWGUI.label(ib, self, "Number of vertices: %(nVertices)i") OWGUI.label(ib, self, "Number of edges: %(nEdges)i") OWGUI.label(ib, self, "Vertices per edge: %(verticesPerEdge).2f") OWGUI.label(ib, self, "Edges per vertex: %(edgesPerVertex).2f") OWGUI.label(ib, self, "Diameter: %(diameter)i") self.insideView = 0 self.insideViewNeighbours = 2 self.insideSpin = OWGUI.spin(self.protoTab, self, "insideViewNeighbours", 1, 6, 1, label="Inside view (neighbours): ", checked="insideView", checkCallback=self.insideview, callback=self.insideviewneighbours) #OWGUI.button(self.protoTab, self, "Clustering", callback=self.clustering) OWGUI.button(self.protoTab, self, "Collapse", callback=self._collapse) self.icons = self.createAttributeIconDict() self.setHubs() self.resize(850, 700)
def __init__(self,parent=None, signalManager = None): OWWidget.__init__(self, parent, signalManager, "Association rules viewer") self.inputs = [("Association Rules", orange.AssociationRules, self.arules)] self.outputs = [("Association Rules", orange.AssociationRules), ("Covered Data", ExampleTable), ("Matching Data", ExampleTable), ("Mismatched Data", ExampleTable)] self.showWholeRules = 1 self.treeDepth = 2 self.autoSend = True self.dataChanged = False self.purgeAttributes = True self.purgeClasses = True self.nRules = self.nSelectedRules = self.nSelectedExamples = self.nMatchingExamples = self.nMismatchingExamples = "" self.showsupport = self.showconfidence = 1 self.showlift = self.showleverage = self.showstrength = self.showcoverage = 0 self.loadSettings() # self.grid = QGridLayout() # rightUpRight = OWGUI.widgetBox(self.mainArea, box="Shown measures", orientation = self.grid) # self.cbMeasures = [OWGUI.checkBox(rightUpRight, self, "show"+attr, long, callback = self.showHideColumn, addToLayout = 0) for long, short, attr in self.measures] # for i, cb in enumerate(self.cbMeasures): # self.grid.addWidget(cb, i % 2, i / 2) box = OWGUI.widgetBox(self.mainArea, orientation = 0) OWGUI.widgetLabel(box, "Shown measures: ") self.cbMeasures = [OWGUI.checkBox(box, self, "show"+attr, long+" ", callback = self.showHideColumn) for long, short, attr in self.measures] OWGUI.rubber(box) self.treeRules = QTreeWidget(self.mainArea) self.mainArea.layout().addWidget(self.treeRules) self.treeRules.setSelectionMode (QTreeWidget.ExtendedSelection) self.treeRules.setHeaderLabels(["Rules"] + [m[1] for m in self.measures]) self.treeRules.setAllColumnsShowFocus ( 1) self.treeRules.setAlternatingRowColors(1) self.showHideColumn() self.connect(self.treeRules,SIGNAL("itemSelectionChanged()"),self. selectionChanged) box = OWGUI.widgetBox(self.controlArea, "Info", addSpace = True) OWGUI.label(box, self, "Number of rules: %(nRules)s") OWGUI.label(box, self, "Selected rules: %(nSelectedRules)s") OWGUI.label(box, self, "Selected examples: %(nSelectedExamples)s") ibox = OWGUI.indentedBox(box) OWGUI.label(ibox, self, "... matching: %(nMatchingExamples)s") OWGUI.label(ibox, self, "... mismatching: %(nMismatchingExamples)s") box = OWGUI.widgetBox(self.controlArea, "Options", addSpace = True) OWGUI.spin(box, self, "treeDepth", label = "Tree depth", min = 0, max = 10, step = 1, callback = self.displayRules, callbackOnReturn = True) OWGUI.separator(box) OWGUI.checkBox(box, self, "showWholeRules", "Display whole rules", callback = self.setWholeRules) OWGUI.rubber(self.controlArea) boxSettings = OWGUI.widgetBox(self.controlArea, 'Send selection') OWGUI.checkBox(boxSettings, self, "purgeAttributes", "Purge attribute values/attributes", box=None, callback=self.purgeChanged) self.purgeClassesCB = OWGUI.checkBox(OWGUI.indentedBox(boxSettings), self, "purgeClasses", "Purge class attribute", callback=self.purgeChanged) if not self.purgeAttributes: self.purgeClassesCB.setEnabled(False) self.oldPurgeClasses = False cbSendAuto = OWGUI.checkBox(boxSettings, self, "autoSend", "Send immediately", box=None) btnUpdate = OWGUI.button(boxSettings, self, "Send", self.sendData, default=True) OWGUI.setStopper(self, btnUpdate, cbSendAuto, "dataChanged", self.sendData) self.rules = None
def defineGUI(self): self.sBox = OWGUI.widgetBox(self.controlArea, "Execution environment") itms = [e[0] for e in self.execEnvs] OWGUI.radioButtonsInBox(self.sBox, self, "execEnv", btnLabels=itms) boxGrid = OWGUI.widgetBox(self.controlArea,'Initial Point for the Optimizer') OWGUI.checkBox(boxGrid, self, 'UseGridSearch','Use Grid-Search', tooltip='Use Grid-Search to find the best initial point to start the optimization.<br>If not checked, the midrange point will be used as optimization initial point.') OWGUI.spin(boxGrid, self, 'nInnerPoints', 1, 100, step=1, label=' Number of inner points:', tooltip='Number of points to break down each variable to evaluate the initial point.<br>It will evaluate nInnerPoints^nOptimizedVars') OWGUI.separator(self.controlArea) self.sBox = OWGUI.widgetBox(self.controlArea, "Sampling Method") itms = [e[0] for e in self.SMethods] self.comboDistItems = ["Continuous","Power2","By Step","Specific Values"] OWGUI.radioButtonsInBox(self.sBox, self, "SMethod", btnLabels=itms) hBox = OWGUI.widgetBox(OWGUI.indentedBox(self.sBox)) #QWidget(hBox).setFixedSize(19, 8) OWGUI.spin(hBox, self, 'nFolds', 2, 100, step=1, label='Number of Folds: ') OWGUI.separator(self.controlArea) box2 = OWGUI.widgetBox(self.controlArea,'Evaluation Method') width = 150 itms = [e[0] for e in self.CMethods] OWGUI.comboBox(box2, self, 'CMethod', items=itms, label='For Classifiers:', labelWidth=width, orientation='horizontal', tooltip='Method used for evaluation in case of classifiers.') itms = [e[0] for e in self.RMethods] OWGUI.comboBox(box2, self, 'RMethod', items=itms, label='For Regressors:', labelWidth=width, orientation='horizontal', tooltip='Method used for evaluation in case of regressors.') OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self,"&Reload Defaults ", callback=self.reloadDefaults) OWGUI.separator(self.controlArea) #OWGUI.separator(self.controlArea, height=24) infoBox = OWGUI.widgetBox(self.controlArea, "Optimizer status") self.infoStatus = OWGUI.label(infoBox,self,'Waiting for inputs...') self.infoPars = OWGUI.label(infoBox,self,'') self.infoRes = OWGUI.label(infoBox,self,'') OWGUI.label(infoBox,self,'') self.infoErr = OWGUI.label(infoBox,self,'') OWGUI.separator(self.controlArea) OWGUI.button(self.controlArea, self,"&Apply Settings ", callback=self.optimizeParameters) # Main area GUI import sip sip.delete(self.mainArea.layout()) self.mainLayout = QGridLayout(self.mainArea) mainRight = OWGUI.widgetBox(self.mainArea, "Parameters Configuration") mainRight.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.paramsTable = OWGUI.table(self.mainArea, rows = 0, columns = 0, selectionMode = QTableWidget.MultiSelection, addToLayout = 0) #self.paramsTable.setLeftMargin(0) self.paramsTable.verticalHeader().hide() self.paramsTable.setSelectionMode(QTableWidget.NoSelection) self.paramsTable.setColumnCount(len(self.paramsNames)) #for i, m in enumerate(self.paramsNames): # self.paramsTable.setColumnStretchable(i, 0) # header.setLabel(i, m) self.paramsTable.setHorizontalHeaderLabels(self.paramsNames) #self.mainLayout.setColumnStretch(1, 100) #self.mainLayout.setRowStretch(2, 100) self.mainLayout.addWidget(self.paramsTable, 0, 0, 1,2) self.mainLayout.addWidget(OWGUI.label(mainRight,self,'Red - Parameter selected to be optimized\r\nGreen - Parameter optimized\r\nBlack - Parameter will not be optimized'),1,0) self.mainLayout.addWidget(OWGUI.label(mainRight,self,'N_EX - Number of Examples in dataset\r\nN_ATTR - Number of attributes in dataset'),1,1) self.adjustSize() self.create()
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Data Table") self.inputs = [("Data", ExampleTable, self.dataset, Multiple + Default)] self.outputs = [("Selected Data", ExampleTable, Default), ("Other Data", ExampleTable)] self.data = {} # key: id, value: ExampleTable self.showMetas = {} # key: id, value: (True/False, columnList) self.showMeta = 1 self.showAttributeLabels = 1 self.showDistributions = 1 self.distColorRgb = (220, 220, 220, 255) self.distColor = QColor(*self.distColorRgb) self.locale = QLocale() self.autoCommit = False self.colorSettings = None self.selectedSchemaIndex = 0 self.colorByClass = True self.loadSettings() # info box infoBox = OWGUI.widgetBox(self.controlArea, "Info") self.infoEx = OWGUI.widgetLabel(infoBox, "No data on input.") self.infoMiss = OWGUI.widgetLabel(infoBox, " ") OWGUI.widgetLabel(infoBox, " ") self.infoAttr = OWGUI.widgetLabel(infoBox, " ") self.infoMeta = OWGUI.widgetLabel(infoBox, " ") OWGUI.widgetLabel(infoBox, " ") self.infoClass = OWGUI.widgetLabel(infoBox, " ") infoBox.setMinimumWidth(200) OWGUI.separator(self.controlArea) # settings box boxSettings = OWGUI.widgetBox(self.controlArea, "Settings", addSpace=True) self.cbShowMeta = OWGUI.checkBox( boxSettings, self, "showMeta", "Show meta attributes", callback=self.cbShowMetaClicked ) self.cbShowMeta.setEnabled(False) self.cbShowAttLbls = OWGUI.checkBox( boxSettings, self, "showAttributeLabels", "Show attribute labels (if any)", callback=self.cbShowAttLabelsClicked, ) self.cbShowAttLbls.setEnabled(True) box = OWGUI.widgetBox(self.controlArea, "Colors") OWGUI.checkBox(box, self, "showDistributions", "Visualize continuous values", callback=self.cbShowDistributions) OWGUI.checkBox(box, self, "colorByClass", "Color by class value", callback=self.cbShowDistributions) OWGUI.button( box, self, "Set colors", self.setColors, tooltip="Set the canvas background color and color palette for coloring continuous variables", debuggingEnabled=0, ) resizeColsBox = OWGUI.widgetBox(boxSettings, 0, "horizontal", 0) OWGUI.label(resizeColsBox, self, "Resize columns: ") OWGUI.toolButton( resizeColsBox, self, "+", self.increaseColWidth, tooltip="Increase the width of the columns", width=20, height=20, ) OWGUI.toolButton( resizeColsBox, self, "-", self.decreaseColWidth, tooltip="Decrease the width of the columns", width=20, height=20, ) OWGUI.rubber(resizeColsBox) self.btnResetSort = OWGUI.button( boxSettings, self, "Restore Order of Examples", callback=self.btnResetSortClicked, tooltip="Show examples in the same order as they appear in the file", ) OWGUI.separator(self.controlArea) selectionBox = OWGUI.widgetBox(self.controlArea, "Selection") self.sendButton = OWGUI.button(selectionBox, self, "Send selections", self.commit, default=True) cb = OWGUI.checkBox(selectionBox, self, "autoCommit", "Commit on any change", callback=self.commitIf) OWGUI.setStopper(self, self.sendButton, cb, "selectionChangedFlag", self.commit) OWGUI.rubber(self.controlArea) dlg = self.createColorDialog() self.discPalette = dlg.getDiscretePalette("discPalette") # GUI with tabs self.tabs = OWGUI.tabWidget(self.mainArea) self.id2table = {} # key: widget id, value: table self.table2id = {} # key: table, value: widget id self.connect(self.tabs, SIGNAL("currentChanged(QWidget*)"), self.tabClicked) self.selectionChangedFlag = False
def __init__(self, parent=None, signalManager=None): OWWidget.__init__(self, parent, signalManager, "Itemset visualizer") self.inputs = [ ("Graph with Data", orange.Graph, self.setGraph), ("Data Subset", orange.ExampleTable, self.setExampleSubset), ] self.outputs = [("Selected Data", ExampleTable), ("Selected Graph", orange.Graph)] self.markerAttributes = [] self.tooltipAttributes = [] self.attributes = [] self.autoSendSelection = False self.graphShowGrid = 1 # show gridlines in the graph self.markNConnections = 2 self.markNumber = 0 self.markProportion = 0 self.markSearchString = "" self.markDistance = 2 self.frSteps = 1 self.hubs = 0 self.color = 0 self.nVertices = ( self.nMarked ) = ( self.nSelected ) = self.nHidden = self.nShown = self.nEdges = self.verticesPerEdge = self.edgesPerVertex = self.diameter = 0 self.optimizeWhat = 1 self.stopOptimization = 0 self.loadSettings() self.visualize = None self.graph = OWIntemsetCanvas(self, self.mainArea, "Network") # start of content (right) area self.box = QVBoxLayout(self.mainArea) self.box.addWidget(self.graph) self.tabs = QTabWidget(self.controlArea) self.displayTab = QVGroupBox(self) self.mainTab = self.displayTab self.markTab = QVGroupBox(self) self.infoTab = QVGroupBox(self) self.protoTab = QVGroupBox(self) self.tabs.insertTab(self.displayTab, "Display") self.tabs.insertTab(self.markTab, "Mark") self.tabs.insertTab(self.infoTab, "Info") self.tabs.insertTab(self.protoTab, "Prototypes") OWGUI.separator(self.controlArea) self.optimizeBox = OWGUI.radioButtonsInBox(self.mainTab, self, "optimizeWhat", [], "Optimize", addSpace=False) OWGUI.button(self.optimizeBox, self, "Random", callback=self.random) self.frButton = OWGUI.button(self.optimizeBox, self, "Fruchterman Reingold", callback=self.fr, toggleButton=1) OWGUI.spin(self.optimizeBox, self, "frSteps", 1, 10000, 1, label="Iterations: ") OWGUI.button(self.optimizeBox, self, "F-R Radial", callback=self.frRadial) OWGUI.button(self.optimizeBox, self, "Circular Original", callback=self.circularOriginal) OWGUI.button(self.optimizeBox, self, "Circular Crossing Reduction", callback=self.circularCrossingReduction) self.showLabels = 0 OWGUI.checkBox(self.mainTab, self, "showLabels", "Show labels", callback=self.showLabelsClick) self.labelsOnMarkedOnly = 0 OWGUI.checkBox( self.mainTab, self, "labelsOnMarkedOnly", "Show labels on marked nodes only", callback=self.labelsOnMarked ) OWGUI.separator(self.mainTab) OWGUI.button(self.mainTab, self, "Show degree distribution", callback=self.showDegreeDistribution) OWGUI.button(self.mainTab, self, "Save network", callback=self.saveNetwork) ib = OWGUI.widgetBox(self.markTab, "Info", addSpace=True) OWGUI.label(ib, self, "Vertices (shown/hidden): %(nVertices)i (%(nShown)i/%(nHidden)i)") OWGUI.label(ib, self, "Selected and marked vertices: %(nSelected)i - %(nMarked)i") ribg = OWGUI.radioButtonsInBox(self.markTab, self, "hubs", [], "Method", callback=self.setHubs, addSpace=True) OWGUI.appendRadioButton(ribg, self, "hubs", "Mark vertices given in the input signal") OWGUI.appendRadioButton(ribg, self, "hubs", "Find vertices which label contain") self.ctrlMarkSearchString = OWGUI.lineEdit( OWGUI.indentedBox(ribg), self, "markSearchString", callback=self.setSearchStringTimer, callbackOnType=True ) self.searchStringTimer = QTimer(self) self.connect(self.searchStringTimer, SIGNAL("timeout()"), self.setHubs) OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of focused vertex") OWGUI.appendRadioButton(ribg, self, "hubs", "Mark neighbours of selected vertices") ib = OWGUI.indentedBox(ribg, orientation=0) self.ctrlMarkDistance = OWGUI.spin( ib, self, "markDistance", 0, 100, 1, label="Distance ", callback=(lambda h=2: self.setHubs(h)) ) self.ctrlMarkFreeze = OWGUI.button(ib, self, "&Freeze", value="graph.freezeNeighbours", toggleButton=True) OWGUI.widgetLabel(ribg, "Mark vertices with ...") OWGUI.appendRadioButton(ribg, self, "hubs", "at least N connections") OWGUI.appendRadioButton(ribg, self, "hubs", "at most N connections") self.ctrlMarkNConnections = OWGUI.spin( OWGUI.indentedBox(ribg), self, "markNConnections", 0, 1000000, 1, label="N ", callback=(lambda h=4: self.setHubs(h)), ) OWGUI.appendRadioButton(ribg, self, "hubs", "more connections than any neighbour") OWGUI.appendRadioButton(ribg, self, "hubs", "more connections than avg neighbour") OWGUI.appendRadioButton(ribg, self, "hubs", "most connections") ib = OWGUI.indentedBox(ribg) self.ctrlMarkNumber = OWGUI.spin( ib, self, "markNumber", 0, 1000000, 1, label="Number of vertices" + ": ", callback=(lambda h=8: self.setHubs(h)), ) OWGUI.widgetLabel(ib, "(More vertices are marked in case of ties)") ib = QHGroupBox("Selection", self.markTab) btnM2S = OWGUI.button(ib, self, "", callback=self.markedToSelection) btnM2S.setPixmap(QPixmap(dlg_mark2sel)) QToolTip.add(btnM2S, "Add Marked to Selection") btnS2M = OWGUI.button(ib, self, "", callback=self.markedFromSelection) btnS2M.setPixmap(QPixmap(dlg_sel2mark)) QToolTip.add(btnS2M, "Remove Marked from Selection") btnSIM = OWGUI.button(ib, self, "", callback=self.setSelectionToMarked) btnSIM.setPixmap(QPixmap(dlg_selIsmark)) QToolTip.add(btnSIM, "Set Selection to Marked") self.hideBox = QHGroupBox("Hide vertices", self.markTab) btnSEL = OWGUI.button(self.hideBox, self, "", callback=self.hideSelected) btnSEL.setPixmap(QPixmap(dlg_selected)) QToolTip.add(btnSEL, "Selected") btnUN = OWGUI.button(self.hideBox, self, "", callback=self.hideAllButSelected) btnUN.setPixmap(QPixmap(dlg_unselected)) QToolTip.add(btnUN, "Unselected") OWGUI.button(self.hideBox, self, "Show", callback=self.showAllNodes) T = OWToolbars.NavigateSelectToolbar self.zoomSelectToolbar = OWToolbars.NavigateSelectToolbar( self, self.controlArea, self.graph, self.autoSendSelection, buttons=( T.IconZoom, T.IconZoomExtent, T.IconZoomSelection, ("", "", "", None, None, 0, "navigate"), T.IconPan, ( "Move selection", "buttonMoveSelection", "activateMoveSelection", QPixmap(OWToolbars.dlg_select), Qt.arrowCursor, 1, "select", ), T.IconRectangle, T.IconPolygon, ("", "", "", None, None, 0, "select"), T.IconSendSelection, ), ) ib = OWGUI.widgetBox(self.infoTab, "General", addSpace=True) OWGUI.label(ib, self, "Number of vertices: %(nVertices)i") OWGUI.label(ib, self, "Number of edges: %(nEdges)i") OWGUI.label(ib, self, "Vertices per edge: %(verticesPerEdge).2f") OWGUI.label(ib, self, "Edges per vertex: %(edgesPerVertex).2f") OWGUI.label(ib, self, "Diameter: %(diameter)i") self.insideView = 0 self.insideViewNeighbours = 2 self.insideSpin = OWGUI.spin( self.protoTab, self, "insideViewNeighbours", 1, 6, 1, label="Inside view (neighbours): ", checked="insideView", checkCallback=self.insideview, callback=self.insideviewneighbours, ) # OWGUI.button(self.protoTab, self, "Clustering", callback=self.clustering) OWGUI.button(self.protoTab, self, "Collapse", callback=self._collapse) self.icons = self.createAttributeIconDict() self.setHubs() self.resize(850, 700)