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
 def menuItemOpen(self):
     """Opens a schema, clearing the current canvas unless the schema is a template."""
     name = QFileDialog.getOpenFileName(self.canvas, _("Open File"), 
     redREnviron.settings["saveSchemaDir"], "Schema or Template (*.rrs *.rrts)")
     
     if name.isEmpty(): return
     name = unicode(name)
     
     if os.path.splitext(name)[1] == '.rrts':
         redRSaveLoad.loadTemplate(name)
     else:
         redREnviron.settings['saveSchemaDir'] = os.path.split(unicode(name))[0]
         self.canvas.schema.clear()
         redRSaveLoad.loadDocument(unicode(name), freeze = 0, importing = False)
         self.addToRecentMenu(unicode(name))
Esempio n. 3
0
 def callback(self):
     text = unicode(self.widgetSuggestEdit.text())
     if '.rrts' in text: ## this is a template, we should load this and not add the widget
         for action in self.templateActions:
             if action.templateInfo.name == text:
                 redRSaveLoad.loadTemplate(action.templateInfo.file)
                 return
     else: ## if there isn't a .rrts in the filename then we should proceed as normal
         for action in self.actions: # move through all of the actions in the actions list
             if action.widgetInfo.name == text: # find the widget (action) that has the correct name, note this finds the first instance.  Widget names must be unique   ??? should we allow multiple widgets with the same name ??? probably not.
                 self.widgetInfo = action.widgetInfo
                 #print action.widgetInfo, _('Widget info')
                 self.canvasDlg.schema.addWidget(action.widgetInfo) # add the correct widget to the schema
                 
                 self.widgetSuggestEdit.clear()  # clear the line edit for the next widget
                 return
Esempio n. 4
0
 def callback(self):
     text = unicode(self.widgetSuggestEdit.text())
     if '.rrts' in text: ## this is a template, we should load this and not add the widget
         for action in self.templateActions:
             if action.templateInfo.name == text:
                 redRSaveLoad.loadTemplate(action.templateInfo.file)
                 return
     else: ## if there isn't a .rrts in the filename then we should proceed as normal
         for action in self.actions: # move through all of the actions in the actions list
             if action.widgetInfo.name == text: # find the widget (action) that has the correct name, note this finds the first instance.  Widget names must be unique   ??? should we allow multiple widgets with the same name ??? probably not.
                 self.widgetInfo = action.widgetInfo
                 #print action.widgetInfo, _('Widget info')
                 self.canvasDlg.schema.addWidget(action.widgetInfo) # add the correct widget to the schema
                 
                 self.widgetSuggestEdit.clear()  # clear the line edit for the next widget
                 return