def __apply_results(self, call=None, request=None): # QToolTip.hideText() self.__thread_counter -= 1 if call: # create a formatted calltip (current index appear in bold) calltip = "<nobr>{0}.{1}(".format( call.module.name, call.call_name) for i, param in enumerate(call.params): if i != 0: calltip += ", " if i == call.index: calltip += "<b>" calltip += unicode(param.token_list[0]) if i == call.index: calltip += "</b>" calltip += ')</nobr>' # set tool tip position at the start of the bracket charWidth = self.editor.codeEdit.fm.width('A') w_offset = (request.col - call.bracket_start[1]) * charWidth position = QPoint( self.editor.codeEdit.cursorRect().x() - w_offset, self.editor.codeEdit.cursorRect().y()) position = self.editor.codeEdit.mapToGlobal(position) # show tooltip QToolTip.showText(position, calltip, self.editor.codeEdit) else: QToolTip.hideText()
def _displayHighlightedTooltip(self, txt): """ Shows/hides current suggestion tooltip next to the completer popup :param txt: :return: """ if not self.displayTooltips or not txt in self.__tooltips: QToolTip.hideText() return tooltip = self.__tooltips[txt] charWidth = self.editor.codeEdit.fm.width('A') # show tooltip pos = self.__completer.popup().pos() pos.setX(pos.x() + 400) pos.setY(pos.y() - 15) QToolTip.showText(pos, tooltip, self.editor.codeEdit)
def __onKeyReleased(self, event): if event.key() == Qt.Key_ParenLeft or \ event.key() == Qt.Key_Comma or \ event.key() == Qt.Key_Space: if self.__thread_counter >= 1: return self.__thread_counter += 1 tc = self.editor.codeEdit.textCursor() line = tc.blockNumber() + 1 col = tc.columnNumber() fn = self.editor.codeEdit.tagFilename encoding = self.editor.codeEdit.tagEncoding source = self.editor.codeEdit.toPlainText() runnable = RunnableCalltip( CalltipRequest(source_code=source, line=line, col=col, filename=fn, encoding=encoding)) runnable.failedEvent.signal.connect(self.__apply_results) runnable.resultsAvailable.signal.connect(self.__apply_results) self.__threadPool.start(runnable) else: QToolTip.hideText()
def _hideCompletions(self): """ Hides the completion popup """ self.__completer.popup().hide() QToolTip.hideText()
def _set_tooltip ( self, tooltip ): self.control.setToolTip( tooltip ) if tooltip == '': QToolTip.hideText()