Exemple #1
0
    def viewPalesData(self):
        # NBNB TBD
        valueObj = self.outputMatrix

        if isinstance(valueObj, NmrCalc.ExternalData):
            dataStore = valueObj.dataStore
            if dataStore is not None:
                wb = WebBrowser(self, name='PalesData')
                wb.open(dataStore.fullPath)

        elif isinstance(valueObj, NmrCalc.MeasurementListData):
            mm = valueObj.measurementList
            if mm is not None:
                popup = self.parent.editMeasurementLists()
                popup.tabbedFrame.select(1)
                popup.setMeasurementList(mm)

        elif isinstance(valueObj, NmrCalc.StructureEnsembleData):
            models = valueObj.models
            if len(models) == 1:
                popup = self.parent.editStructures()
                popup.tabbedFrame.select(3)
                popup.changeModel(models[0])
                popup.changeTab(3)

        elif isinstance(valueObj, NmrCalc.ConstraintStoreData):
            constraintLists = valueObj.constraintLists
            if len(constraintLists) == 1:
                popup = self.parent.browseConstraints()
                popup.tabbedFrame.select(2)
                popup.changeRestraintList(constraintLists[0])
Exemple #2
0
    def open(self, url):

        if self.project:
            name = getProjectWebBrowser(self.project)
            if name:
                self.name = name

        WebBrowser.open(self, url)
Exemple #3
0
    def __init__(self, parent, name=None, popup=None, project=None):

        self.project = project
        if project and (not name):
            if hasattr(project, 'application'):
                name = getProjectWebBrowser(project)

        WebBrowser.__init__(self, parent, name=name, popup=popup)
Exemple #4
0
def createDismissHelpButtonList(parent, texts = None, commands = None,
                          direction=Tkinter.HORIZONTAL,
                          dismiss_text = '', help_text = '',
                          help_msg = '', help_url = '',
                          buttonBorderwidth=True, expands=True, 
                          dismiss_cmd = None,
                          webBrowser = None,
                          *args, **kw):
  if (texts is None):
    texts = []

  if (commands is None):
    commands = []

  if (not dismiss_text):
    dismiss_text = ''
 
  if (not help_text):
    help_text = ''

  texts = list(texts) + [dismiss_text, help_text]

  popup = getPopup(parent)

  if not webBrowser:
    webBrowser = WebBrowser(popup.top, popup=popup)

  if (not dismiss_cmd):
    dismiss_cmd = popup.close

  if (help_url):
    help_cmd   = lambda url=help_url: webBrowser.open(url)
  else:
    help_cmd = lambda top=popup.top, message=help_msg: memops.gui.HelpPopup.showHelpText(top, message, popup=popup)

  if (type(commands) is types.DictType):
    commands = commands.copy()
    commands[dismiss_text] = dismiss_cmd
    commands[help_text] = help_cmd
  else:
    commands = list(commands) + [dismiss_cmd, help_cmd]

  button_list = ButtonList(parent, texts=texts, commands=commands, buttonBorderwidth=buttonBorderwidth,
                           expands=expands, direction=direction, *args, **kw)
  
  
  if not dismiss_text:
    button_list.cancelIcon = Tkinter.PhotoImage(file=os.path.join(gfxDir,'cancel.gif'))
    button_list.buttons[-2].config(image=button_list.cancelIcon, activebackground=button_list.cget('bg'))
  
  if not help_text:
    button_list.helpIcon   = Tkinter.PhotoImage(file=os.path.join(gfxDir,'help.gif'))
    button_list.buttons[-1].config(image=button_list.helpIcon, activebackground=button_list.cget('bg'))
    

  return button_list
Exemple #5
0
  def viewHtmlResults(self):

    resultsUrl = self.resultsUrl
    if not resultsUrl:
      msg = 'No current iCing results URL'
      showWarning('Failure', msg, parent=self)
      return

    webBrowser = WebBrowser(self.application, popup=self.application)
    webBrowser.open(self.resultsUrl)
Exemple #6
0
    def __init__(self,
                 parent,
                 webBrowser=None,
                 helpUrl=None,
                 helpMsg=None,
                 doClone=True,
                 doHelp=True,
                 doClose=True,
                 cloneText=None,
                 helpText=None,
                 closeText=None,
                 cloneCmd=None,
                 helpCmd=None,
                 closeCmd=None,
                 *args,
                 **kw):

        self.helpUrl = helpUrl
        self.helpMsg = helpMsg
        self.popup = getPopup(parent)

        if not isinstance(self.popup, BasePopup):
            self.popup = None

        if self.popup and not webBrowser:

            webBrowser = WebBrowser(self.popup.parent, popup=self.popup)

        self.webBrowser = webBrowser

        _commands = []
        _texts = []
        _images = []

        _doActions = [
            (doClone, cloneCmd, self.clonePopup, cloneText, 'twoWindows.gif'),
            (doHelp, helpCmd, self.launchHelp, helpText, 'help.gif'),
            (doClose, closeCmd, self.closePopup, closeText, 'cancel.gif')
        ]

        for doAction, userCmd, defaultCmd, text, imageFile in _doActions:
            if doAction:
                _commands.append(userCmd or defaultCmd)

                if text:
                    _texts.append(text)
                    _images.append(None)
                else:
                    icon = Tkinter.PhotoImage(
                        file=os.path.join(GFX_DIR, imageFile))
                    _texts.append('')
                    _images.append(icon)

        # Needed for photoimage reference count/persistence
        self.icons = [img for img in _images if img]

        images = kw.get('images')
        if images:
            kw['images'] = images + _images
        else:
            kw['images'] = [None] * len(kw.get('texts', [])) + _images

        kw['commands'] = kw.get('commands', []) + _commands
        kw['texts'] = kw.get('texts', []) + _texts

        ButtonList.__init__(self, parent, *args, **kw)
Exemple #7
0
    def __init__(self,
                 parent,
                 webBrowser=None,
                 helpUrl=None,
                 helpMsg=None,
                 doClone=True,
                 doHelp=True,
                 doClose=True,
                 cloneText=None,
                 helpText=None,
                 closeText=None,
                 cloneCmd=None,
                 helpCmd=None,
                 closeCmd=None,
                 cloneTip=None,
                 helpTip=None,
                 closeTip=None,
                 *args,
                 **kw):

        self.helpUrl = helpUrl
        self.helpMsg = helpMsg
        self.popup = getPopup(parent)

        cloneTip = cloneTip or Doc.cloneDoc.documentation
        helpTip = helpTip or Doc.helpDoc.documentation

        if not closeTip:  # a bit of a hack, this
            if closeText == 'Cancel':
                closeTip = Doc.cancelDoc.documentation
            else:
                closeTip = Doc.closeDoc.documentation

        cloneKey = cloneText or Doc.cloneDoc.name
        helpKey = helpText or Doc.helpDoc.name
        closeKey = closeText or Doc.closeDoc.name

        if not isinstance(self.popup, BasePopup):
            self.popup = None

        if self.popup and not webBrowser:

            webBrowser = WebBrowser(self.popup.parent, popup=self.popup)

        self.webBrowser = webBrowser

        _commands = []
        _texts = []
        _images = []
        _docKeys = []
        _tipTexts = []

        _doActions = [
            (doClone, cloneCmd, self.clonePopup, cloneText, 'twoWindows.gif',
             cloneTip, cloneKey),
            (doHelp, helpCmd, self.launchHelp, helpText, 'help.gif', helpTip,
             helpKey),
            (doClose, closeCmd, self.closePopup, closeText, 'cancel.gif',
             closeTip, closeKey),
        ]

        for doAction, userCmd, defaultCmd, text, imageFile, tipText, docKey in _doActions:
            if doAction:
                _commands.append(userCmd or defaultCmd)
                _docKeys.append(docKey)
                _tipTexts.append(tipText)

                if text:
                    _texts.append(text)
                    _images.append(None)
                else:
                    icon = Tkinter.PhotoImage(
                        file=os.path.join(GFX_DIR, imageFile))
                    _texts.append('')
                    _images.append(icon)

        # Needed for photoimage reference count/persistence
        self.icons = [img for img in _images if img]

        images = kw.get('images')
        if images:
            kw['images'] = images + _images
        else:
            kw['images'] = [None] * len(kw.get('texts', [])) + _images

        texts = kw.get('texts', [])
        commands = kw.get('commands', [])
        docKeys = kw.get('docKeys') or [None] * max(
            [len(texts), len(commands)])
        tipTexts = kw.get('tipTexts') or [None] * max(
            [len(texts), len(commands)])

        kw['docKeys'] = docKeys + _docKeys
        kw['tipTexts'] = tipTexts + _tipTexts
        kw['commands'] = commands + _commands
        kw['texts'] = texts + _texts

        ButtonList.__init__(self, parent, *args, **kw)