我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用PyQt5.QtCore.Qt.TextSelectableByMouse()。
def process_finished(self, exit_code): format = self.ui.edit_stdout.currentCharFormat() format.setFontWeight(QFont.Bold) if exit_code == 0: if self._interrupted: color = Qt.red msg = ('Process interrupted by user') else: color = Qt.green msg = ('Process exited normally') else: color = Qt.red msg = ('Process exited with exit code %d' % exit_code) format.setForeground(color) self.ui.edit_stdout.setCurrentCharFormat(format) self.ui.edit_stdout.appendPlainText(msg) self.restore_gui() self.ui.edit_stdout.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.TextSelectableByKeyboard) self.process = None self.ui.btn_log.setEnabled(self.last_log_file is not None and os.path.isfile(self.last_log_file))
def exception_message(log_lines, exc_info): stacktrace = traceback.format_exception(*exc_info) if exc_info else "" message = """ {log_lines} ---- {stacktrace} """.format(log_lines='\n'.join(log_lines), stacktrace='\n'.join(stacktrace)) mb = QMessageBox() mb.setIcon(QMessageBox.Critical) mb.setWindowTitle("DUANG!!!") mb.setText('A critical error occurred. Select the details to display it.') mb.setInformativeText("Please report it to " "<a href=https://github.com/bioinformatist/Gao-s-SB/issues/new>the owner's GitHub</a>") mb.setTextFormat(Qt.RichText) mb.setDetailedText(message) mb.setTextInteractionFlags(Qt.TextSelectableByMouse) mb.exec()
def process_errored(self): try: exit_code = self.process.exitCode() except Exception: exit_code = 0 format = self.ui.edit_stdout.currentCharFormat() format.setFontWeight(QFont.Bold) format.setForeground(Qt.red) self.ui.edit_stdout.setCurrentCharFormat(format) self.ui.edit_stdout.appendPlainText('Process exited with exit code' % exit_code) self.restore_gui() self.ui.edit_stdout.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.TextSelectableByKeyboard) self.process = None
def __init__(self, myTime, lyric, myOrder, signal, parent=None): super(_LyricLabel, self).__init__(lyric) self.setObjectName('lyric') self.parent = parent self.myTime = myTime[:myTime.rfind('.')] self.myLyric = lyric self.myOrder = myOrder signal.connect(self.lightMe) self.setMinimumHeight(40) # ????????? self.setTextInteractionFlags(Qt.TextSelectableByMouse)
def excepthook(excType, excValue, tracebackobj): """Rewritten "excepthook" function, to display a message box with details about the exception. @param excType exception type @param excValue exception value @param tracebackobj traceback object """ separator = '-' * 40 notice = "An unhandled exception has occurred\n" tbinfofile = io.StringIO() traceback.print_tb(tracebackobj, None, tbinfofile) tbinfofile.seek(0) tbinfo = tbinfofile.read() errmsg = '%s: \n%s' % (str(excType), str(excValue)) sections = [separator, errmsg, separator, tbinfo] msg = '\n'.join(sections) # Create a QMessagebox error_box = QMessageBox() error_box.setText(str(notice)+str(msg)) error_box.setWindowTitle("Hue-plus - unhandled exception") error_box.setIcon(QMessageBox.Critical) error_box.setStandardButtons(QMessageBox.Ok) error_box.setTextInteractionFlags(Qt.TextSelectableByMouse) # Show the window error_box.exec_() sys.exit(1)