def searchCallback(self, info, c):
     """The default search callback, this is run when the return or enter key is pressed after passing through the doneCompletion argument"""
     if c == 't':
         redRSaveLoad.loadTemplate(info.file)
     elif c == 'w':
         redRObjects.addWidget(redRObjects.widgetRegistry()['widgets'][info.fileName]) # add the correct widget to the schema
     self.clear()  # clear the line edit for the next widget
     return
Beispiel #2
0
 def searchCallback(info, c, x = point.x(), y = point.y(), self = self, dialog = dialog):
     import redRObjects
     if c == 'w':
         newWidget = redRObjects.addWidget(redRObjects.widgetRegistry()['widgets'][info.fileName], x = x, y = y) # add the correct widget to the schema
         #nw = redRObjects.getWidgetByIDActiveTabOnly(newWidget)
         #self.doc.addLine(start or nw, end or nw)
     dialog.accept()
     return
 def itemClicked(self, item, column):
     """Adds the widget to the schema.  If shift is heald and only one widget is selected on the canvas then the new widget is connected to the selected widget."""
     if isinstance(item, WidgetTreeFolder):
         return
     
     if hasattr(self, 'busy'): return
     
     self.busy = 1
     newwidget = redRObjects.addWidget(item.widgetInfo)
     if (self.mouseRightClick or self.shiftPressed):
         if len(redRObjects.activeTab().getSelectedWidgets()) == 1:
             redRObjects.schemaDlg.addLine(redRObjects.activeTab().getSelectedWidgets()[0], redRObjects.getWidgetByIDActiveTabOnly(newwidget))
     delattr(self, 'busy')
def loadWidgets180(widgets, loadingProgressBar, loadedSettingsDict, tmp):
    print 'loading widget using 1.80 settings'
    lpb = 0
    loadedOk = 1
    failureText = ''
    addY = minimumY()
    for widget in widgets.getElementsByTagName("widget"):
        try:
            name = widget.getAttribute("widgetName")
            if name in redRObjects.widgetRegistry()['widgets']:
                widgetInfo =  redRObjects.widgetRegistry()['widgets'][name]
            else:
                widgetInfo =  redRObjects.widgetRegistry()['widgets']['base_dummy']
            widgetID = widget.getAttribute('widgetID')
            settings = cPickle.loads(loadedSettingsDict[widgetID]['settings'])
            inputs = cPickle.loads(loadedSettingsDict[widgetID]['inputs'])
            outputs = cPickle.loads(loadedSettingsDict[widgetID]['outputs'])
            xPos = int(widget.getAttribute('xPos'))
            yPos = int(widget.getAttribute('yPos'))
            caption = unicode(widget.getAttribute('caption'))
            ## for backward compatibility we need to make both the widgets and the instances.
            #addWidgetInstanceByFileName(name, settings, inputs, outputs)
            widgetInfo =  redRObjects.widgetRegistry()['widgets'][name]
            if tmp:
                widgetID += '_'+str(sessionID)
            #schemaDoc.addWidget(widgetInfo, x= xPos, y= yPos, caption = caption, widgetSettings = settings, forceInSignals = inputs, forceOutSignals = outputs, id = widgetID)
            newwidget = redRObjects.addWidget(widgetInfo, x = xPos, y = yPos, caption = caption, widgetSettings = settings, forceInSignals = inputs, forceOutSignals = outputs, wid = widgetID)
            #instanceID = redRObjects.addInstance(widgetInfo, settings = settings, insig = inputs, outsig = outputs, wid = widgetID)
            #newwidget = redRObjects.newIcon(redRObjects.activeCanvas(), redRObjects.activeTab(), widgetInfo, redRStyle.defaultWidgetIcon, canvasDlg, instanceID =  instanceID, tabName = redRObjects.activeTabName())
            
            if newwidget not in redRObjects._widgetInstances.keys():
                raise Exception('widget instance not in instance keys')
            
            lpb += 1
            loadingProgressBar.setValue(lpb)
        except Exception as inst:
            redRLog.log(redRLog.REDRCORE, redRLog.ERROR, redRLog.formatException())
            print unicode(inst), _('Widget load failure 180')
    return (loadedOk, failureText)