示例#1
0
 def occur(self, what, regex=False):
     content = self.toPlainText().split('\n')
     if regex:
         regexp = QRegExp(what, Qt.CaseInsensitive)
         content = [line for line in content if regexp.indexIn(line) >= 0]
     else:
         what = what.lower()
         content = [line for line in content if what in line.lower()]
     content = '\n'.join(content)
     window = QMainWindow(self)
     window.resize(600, 800)
     window.setWindowTitle('Lines matching %r' % what)
     widget = QTextEdit(window)
     widget.setFont(self.font())
     window.setCentralWidget(widget)
     widget.setText(content)
     window.show()
示例#2
0
文件: elog.py 项目: ess-dmsc/nicos
 def on_page_unsupportedContent(self, reply):
     if reply.url().scheme() != 'file':
         return
     filename = reply.url().path()
     if filename.endswith('.dat'):
         content = open(filename, encoding='utf-8', errors='replace').read()
         window = QMainWindow(self)
         window.resize(600, 800)
         window.setWindowTitle(filename)
         widget = QTextEdit(window)
         widget.setFontFamily('monospace')
         window.setCentralWidget(widget)
         widget.setText(content)
         window.show()
     else:
         # try to open the link with host computer default application
         try:
             QDesktopServices.openUrl(reply.url())
         except Exception:
             pass
示例#3
0
 def _retrieve_detinfo(self):
     if self._detinfo is None:
         info = self.panel.client.eval(
             'det._detinfo_parsed, '
             'det._anglemap', None)
         if not info:
             return self.showError('Cannot retrieve detector info.')
         self._lambda = self.panel.client.eval('chWL()', None)
         if not self._lambda:
             return self.showError('Cannot retrieve wavelength.')
         self._detinfo, self._anglemap = info
         self._inverse_anglemap = 0
         self._infowindow = QMainWindow(self)
         self._infolabel = QLabel(self._infowindow)
         self._infolabel.setTextFormat(Qt.RichText)
         self._infowindow.setCentralWidget(self._infolabel)
         self._infowindow.setContentsMargins(10, 10, 10, 10)
         self._inv_anglemap = [[
             entry for entry in self._detinfo[1:]
             if entry[12] == self._anglemap[detnr] + 1
         ][0] for detnr in range(len(self._xs))]