def mouseMoveEvent(self, event): position = event.pos() cursor = self.cursorForPosition(position) block = cursor.block() checkers = self._neditable.sorted_checkers for items in checkers: checker, color, _ = items if block.blockNumber() in checker.checks: message = checker.checks[block.blockNumber()][0] QToolTip.showText(self.mapToGlobal(position), message, self) if event.modifiers() == Qt.ControlModifier: cursor.select(QTextCursor.WordUnderCursor) selection_start = cursor.selectionStart() selection_end = cursor.selectionEnd() cursor.setPosition(selection_start - 1) cursor.setPosition(selection_end + 1, QTextCursor.KeepAnchor) if cursor.selectedText()[-1:] in ('(', '.') or \ cursor.selectedText()[:1] in ('.', '@'): self.extraSelections = [] selection = QTextEdit.ExtraSelection() lineColor = QColor( resources.CUSTOM_SCHEME.get( 'linkNavigate', resources.COLOR_SCHEME['linkNavigate'])) selection.format.setForeground(lineColor) selection.format.setFontUnderline(True) selection.cursor = cursor self.extraSelections.append(selection) self.setExtraSelections(self.extraSelections) else: self.extraSelections = [] self.setExtraSelections(self.extraSelections) QPlainTextEdit.mouseMoveEvent(self, event)
def help_event(self, event): if self.scatterplot_item is None: return False act_pos = self.scatterplot_item.mapFromScene(event.scenePos()) points = self.scatterplot_item.pointsAt(act_pos) text = "" if len(points): for i, p in enumerate(points): index = p.data() text += "Attributes:\n" if self.tooltip_shows_all: text += "".join( ' {} = {}\n'.format(attr.name, self.raw_data[index][attr]) for attr in self.data_domain.attributes) else: text += ' {} = {}\n {} = {}\n'.format( self.shown_x, self.raw_data[index][self.shown_x], self.shown_y, self.raw_data[index][self.shown_y]) if self.data_domain.class_var: text += 'Class:\n {} = {}\n'.format( self.data_domain.class_var.name, self.raw_data[index][self.raw_data.domain.class_var]) if i < len(points) - 1: text += '------------------\n' text = ('<span style="white-space:pre">{}</span>' .format(escape(text))) QToolTip.showText(event.screenPos(), text, widget=self.plot_widget) return True else: return False
def verifier_feuille(self, eq1, eq2): print eq1, eq2 for nom, eq in (('d1', eq1), ('d2', eq2)): if nom in self.feuille_actuelle.objets.noms: d = self.feuille_actuelle.objets[nom] d.label(mode=NOM) champ = self.feuille_actuelle.objets['champcache_' + nom] M, N = d M = (int(M.x), int(M.y)) N = (int(N.x), int(N.y)) if self.eq_reduite(M, N) == eq: d.style(couleur='g') champ.texte = 'ok' msg = 'La droite %s est correcte.' % nom if nom == 'd1': msg += ' Construisez maintenant d2.' else: print self.eq_reduite(*d), eq d.style(couleur='r') # On peut mettre n'importe quoi différent de ok dans # champ, l'idée étant que si la droite est fausse mais # n'a pas changé, on ne perde pas de point, et par # contre on perde des points en cas de changement si # c'est toujours faux. champ.texte = str(d.equation) msg = "Attention, la droite %s est fausse." % nom QToolTip.showText(QCursor.pos(), msg) self.canvas.message(msg, temporaire=False)
def mouseMoveEvent(self, event): super(Editor, self).mouseMoveEvent(event) position = event.pos() line = str(self.lineAt(position) + 1) message = self.checker.data.get(line, None) if message is not None: QToolTip.showText(self.mapToGlobal(position), message)
def motor(self): """ Modifie l'angle des moteurs a partir de ceux qui ont été changé. Affiche la valeur de l'angle actuel dans le ToolTip """ #récupère le moteur qui a bougé if self.thread_code.isRunning(): return nb=self.hasChanged() if not self.boolOmbre: self.boolOmbre= not self.boolOmbre return sliderEq = ALProxy.getKeys() if self.sliderAxis[nb]!=3: #maj le bon trouvé self.virtualNao.getMembre(sliderEq[nb][:-1]).setAngleFromPercent(self.sliderAxis[nb],self.sliders[nb].value()) QToolTip.showText(self.cursor.pos(),str(self.sliders[nb].value())) else : self.virtualNao.getMembre("hancheD").setAngleFromPercentList([self.horizontalSliderHanche15.value(),0,self.horizontalSliderHanche15.value()]) self.virtualNao.getMembre("hancheG").setAngleFromPercentList([self.horizontalSliderHanche15.value(),0,self.horizontalSliderHanche15.value()]) QToolTip.showText(self.cursor.pos(),str(self.horizontalSliderHanche15.value())) self.virtualNao.getMembre("doigt3D").setAngleFromPercent(0,100-self.horizontalSliderDoigtsD0.value()) self.virtualNao.getMembre("doigt2D").setAngleFromPercent(0,100-self.horizontalSliderDoigtsD0.value()) self.virtualNao.getMembre("doigt1D").setAngleFromPercent(0,100)#=fixe self.virtualNao.getMembre("doigt3G").setAngleFromPercent(0,100-self.horizontalSliderDoigtsG0.value()) self.virtualNao.getMembre("doigt2G").setAngleFromPercent(0,100-self.horizontalSliderDoigtsG0.value()) self.virtualNao.getMembre("doigt1G").setAngleFromPercent(0,100)#=fixe self.updatePhysics() self.Viewer3DWidget.update()
def show_calltip(self, title, text, color='#2D62FF', at_line=None): """ Show calltip This is here because QScintilla does not implement well calltips """ if text is None or len(text) == 0: return weight = 'bold' if self.calltip_font.bold() else 'normal' size = self.calltip_font.pointSize() family = self.calltip_font.family() format1 = '<div style=\'font-size: %spt; color: %s\'>' % (size, color) format2 = '<hr><div style=\'font-family: "%s"; font-size: %spt; font-weight: %s\'>' % (family, size, weight) if isinstance(text, list): text = "\n ".join(text) text = text.replace('\n', '<br>') if len(text) > self.calltip_size: text = text[:self.calltip_size] + " ..." tiptext = format1 + ('<b>%s</b></div>' % title) \ + format2 + text + "</div>" # Showing tooltip at cursor position: cx, cy = self.get_coordinates('cursor') if at_line is not None: cx = 5 _, cy = self.__get_coordinates_from_lineindex(at_line-1, 0) QToolTip.showText(self.mapToGlobal(QPoint(cx, cy)), tiptext) # Saving cursor position: self.calltip_position = self.get_position('cursor')
def show_calltip(self, title, text, color='#2D62FF', at_line=None): """ Show calltip This is here because QScintilla does not implement well calltips """ if text is None or len(text)==0: return weight = 'bold' if self.calltip_font.bold() else 'normal' size = self.calltip_font.pointSize() family = self.calltip_font.family() format1 = '<div style=\'font-size: %spt; color: %s\'>' % (size, color) format2 = '<hr><div style=\'font-family: "%s"; font-size: %spt; font-weight: %s\'>' % (family, size, weight) if isinstance(text, list): text = "\n ".join(text) else: text = text.replace('\n', '<br>') if len(text) > self.calltip_size: text = text[:self.calltip_size] + " ..." tiptext = format1 + ('<b>%s</b></div>' % title) \ + format2 + text + "</div>" # Showing tooltip at cursor position: cx, cy = self.get_coordinates('cursor') if at_line is not None: #TODO: this code has not yet been ported to QPlainTextEdit because it's # only used in editor widgets which are based on QsciScintilla cx = 5 cursor = self.textCursor() block = self.document().findBlockByNumber(at_line-1) cursor.setPosition(block.position()) cy = self.cursorRect(cursor).top() QToolTip.showText(self.mapToGlobal(QPoint(cx, cy)), tiptext) # Saving cursor position: self.calltip_position = self.get_position('cursor')
def event(self, ev): if ev.type() == QEvent.ToolTip: if self._showToolTips: c = self.charcodeAt(ev.pos()) if c: text = self.getToolTipText(c) if text: rect = self.charcodeRect(c) QToolTip.showText(ev.globalPos(), text, self, rect) ev.accept() return True elif ev.type() == QEvent.QueryWhatsThis: if self._showWhatsThis: ev.accept() return True elif ev.type() == QEvent.WhatsThis: ev.accept() if self._showWhatsThis: c = self.charcodeAt(ev.pos()) text = self.getWhatsThisText(c) if c else None if text: QWhatsThis.showText(ev.globalPos(), text, self) else: QWhatsThis.leaveWhatsThisMode() return True return super(CharMap, self).event(ev)
def custom_mouse_movement(event): try: # If no thread is selected, just ignore the move thread_id = self.get_active_thread() if not thread_id: return pos = event.pos() c = editor_widget.cursorForPosition(pos) filepath = os.path.abspath(self.editor.get_editor_path()) if filepath not in self.sym_finder: finder = debugger_plugin.core.symbols.SymbolFinder(open(filepath).read()) finder.parse() self.sym_finder[filepath] = finder else: finder = self.sym_finder[filepath] sym = finder.get(c.blockNumber()+1, c.columnNumber()) if sym is not None: ret = self.debugger_adapter.evaluate(thread_id, sym.expression, depth=0) content = "{exp} = ({type}) {value}".format( exp=sym.expression, type=ret['type'], value=ret['value']) QToolTip.showText(editor_widget.mapToGlobal(pos), content) finally: self.__old_mouse_event(event)
def mouseMoveEvent(self, event): position = event.pos() cursor = self.cursorForPosition(position) block = cursor.block() if settings.ERRORS_HIGHLIGHT_LINE and \ (block.blockNumber()) in self.errors.errorsSummary: message = '\n'.join(self.errors.errorsSummary[block.blockNumber()]) QToolTip.showText(self.mapToGlobal(position), message, self) elif settings.CHECK_HIGHLIGHT_LINE and \ (block.blockNumber()) in self.pep8.pep8checks: message = '\n'.join(self.pep8.pep8checks[block.blockNumber()]) QToolTip.showText(self.mapToGlobal(position), message, self) if event.modifiers() == Qt.ControlModifier: cursor.select(QTextCursor.WordUnderCursor) cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor) if cursor.selectedText().endsWith('(') or \ cursor.selectedText().endsWith('.'): cursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor) self.extraSelections = [] selection = QTextEdit.ExtraSelection() lineColor = QColor( resources.CUSTOM_SCHEME.get( 'linkNavigate', resources.COLOR_SCHEME['linkNavigate'])) selection.format.setForeground(lineColor) selection.format.setFontUnderline(True) selection.cursor = cursor self.extraSelections.append(selection) self.setExtraSelections(self.extraSelections) else: self.extraSelections = [] self.setExtraSelections(self.extraSelections) QPlainTextEdit.mouseMoveEvent(self, event)
def show_calltip(self, title, text, color='#2D62FF', at_line=None): """ Show calltip This is here because QScintilla does not implement well calltips """ if text is None or len(text)==0: return weight = 'bold' if self.calltip_font.bold() else 'normal' size = self.calltip_font.pointSize() family = self.calltip_font.family() format1 = '<div style=\'font-size: %spt; color: %s\'>' % (size, color) format2 = '<hr><div style=\'font-family: "%s"; font-size: %spt; font-weight: %s\'>' % (family, size, weight) if isinstance(text, list): text = "\n ".join(text) else: text = text.replace('\n', '<br>') if len(text) > self.calltip_size: text = text[:self.calltip_size] + " ..." tiptext = format1 + ('<b>%s</b></div>' % title) \ + format2 + text + "</div>" # Showing tooltip at cursor position: cx, cy = self.get_coordinates('cursor') if at_line is not None: #TODO: this code has not yet been ported to QTextEdit because it's # only used in editor widgets which are based on QsciScintilla raise NotImplementedError # cx = 5 # _, cy = self.__get_coordinates_from_lineindex(at_line, 0) QToolTip.showText(self.mapToGlobal(QPoint(cx, cy)), tiptext) # Saving cursor position: self.calltip_position = self.get_position('cursor')
def mouseMoveEvent(self, event): position = event.pos() cursor = self.cursorForPosition(position) block = cursor.block() if settings.ERRORS_HIGHLIGHT_LINE and \ (block.blockNumber()) in self.errors.errorsSummary: message = '\n'.join( self.errors.errorsSummary[block.blockNumber()]) QToolTip.showText(self.mapToGlobal(position), message, self) elif settings.CHECK_HIGHLIGHT_LINE and \ (block.blockNumber()) in self.pep8.pep8checks: message = '\n'.join( self.pep8.pep8checks[block.blockNumber()]) QToolTip.showText(self.mapToGlobal(position), message, self) if event.modifiers() == Qt.ControlModifier: cursor.select(QTextCursor.WordUnderCursor) cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor) if cursor.selectedText().endsWith('(') or \ cursor.selectedText().endsWith('.'): cursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor) self.extraSelections = [] selection = QTextEdit.ExtraSelection() lineColor = QColor(resources.CUSTOM_SCHEME.get('linkNavigate', resources.COLOR_SCHEME['linkNavigate'])) selection.format.setForeground(lineColor) selection.format.setFontUnderline(True) selection.cursor = cursor self.extraSelections.append(selection) self.setExtraSelections(self.extraSelections) else: self.extraSelections = [] self.setExtraSelections(self.extraSelections) QPlainTextEdit.mouseMoveEvent(self, event)
def mouseMoveEvent(self, event): position = event.pos() line = self.lineAt(position) checkers = self._neditable.sorted_checkers for items in checkers: checker, color, _ = items message = checker.message(line) if message: QToolTip.showText(self.mapToGlobal(position), message, self) if event.modifiers() == Qt.ControlModifier: self._navigation_highlight_active = True word = self.wordAtPoint(position) self.SendScintilla(QsciScintilla.SCI_SETINDICATORCURRENT, self.__indicator_navigation) self.SendScintilla(QsciScintilla.SCI_INDICATORCLEARRANGE, 0, len(self.text())) text = self.text() word_length = len(word) index = text.find(word) while index != -1: self.SendScintilla(QsciScintilla.SCI_INDICATORFILLRANGE, index, word_length) index = text.find(word, index + 1) elif self._navigation_highlight_active: self._navigation_highlight_active = False self.SendScintilla(QsciScintilla.SCI_SETINDICATORCURRENT, self.__indicator_navigation) self.SendScintilla(QsciScintilla.SCI_INDICATORCLEARRANGE, 0, len(self.text())) super(Editor, self).mouseMoveEvent(event)
def showMethodToolTip(self): """ Pops up a tooltip message with the help for the object under the \ cursor. :return <bool> success """ self.cancelCompletion() obj = self.objectAtCursor() if (not obj): return False docs = inspect.getdoc(obj) if (not docs): return False # determine the cursor position rect = self.cursorRect() cursor = self.textCursor() point = QPoint(rect.left(), rect.top() + 18) QToolTip.showText(self.mapToGlobal(point), docs, self) return True
def show_calltip(self, title, text, color='#2D62FF', at_line=None, at_position=None): """Show calltip""" if text is None or len(text) == 0: return # Saving cursor position: if at_position is None: at_position = self.get_position('cursor') self.calltip_position = at_position # Preparing text: weight = 'bold' if self.calltip_font.bold() else 'normal' size = self.calltip_font.pointSize() family = self.calltip_font.family() format1 = '<div style=\'font-size: %spt; color: %s\'>' % (size, color) format2 = '<hr><div style=\'font-family: "%s"; font-size: %spt; font-weight: %s\'>' % (family, size, weight) if isinstance(text, list): text = "\n ".join(text) text = text.replace('\n', '<br>') if len(text) > self.calltip_size: text = text[:self.calltip_size] + " ..." tiptext = format1 + ('<b>%s</b></div>' % title) \ + format2 + text + "</div>" # Showing tooltip at cursor position: cx, cy = self.get_coordinates('cursor') if at_line is not None: cx = 5 cursor = QTextCursor(self.document().findBlockByNumber(at_line-1)) cy = self.cursorRect(cursor).top() point = self.mapToGlobal(QPoint(cx, cy)) point.setX(point.x()+self.get_linenumberarea_width()) QToolTip.showText(point, tiptext)
def mouseMoveEvent(self, event): position = event.pos() cursor = self.cursorForPosition(position) block = cursor.block() checkers = sorted(self._neditable.registered_checkers, key=lambda x: x[2], reverse=True) for items in checkers: checker, color, _ = items if block.blockNumber() in checker.checks: message = '\n'.join(checker.checks[block.blockNumber()]) QToolTip.showText(self.mapToGlobal(position), message, self) if event.modifiers() == Qt.ControlModifier: cursor.select(QTextCursor.WordUnderCursor) selection_start = cursor.selectionStart() selection_end = cursor.selectionEnd() cursor.setPosition(selection_start - 1) cursor.setPosition(selection_end + 1, QTextCursor.KeepAnchor) if cursor.selectedText()[-1:] in ('(', '.') or \ cursor.selectedText()[:1] in ('.', '@'): self.extraSelections = [] selection = QTextEdit.ExtraSelection() lineColor = QColor(resources.CUSTOM_SCHEME.get('linkNavigate', resources.COLOR_SCHEME['linkNavigate'])) selection.format.setForeground(lineColor) selection.format.setFontUnderline(True) selection.cursor = cursor self.extraSelections.append(selection) self.setExtraSelections(self.extraSelections) else: self.extraSelections = [] self.setExtraSelections(self.extraSelections) QPlainTextEdit.mouseMoveEvent(self, event)
def mouseMoveEvent(self, mouseEvent): """ Override so that the tool tip can be shown immediately. :param mouseEvent: Mouse move event :type mouseEvent: QMouseEvent """ QToolTip.showText(mouseEvent.globalPos(), self._user_tip, self)
def custom_mouse_movement(event): try: # If no thread is selected, just ignore the move thread_id = self.get_active_thread() if not thread_id: return pos = event.pos() c = editor_widget.cursorForPosition(pos) filepath = os.path.abspath(self.editor.get_editor_path()) if filepath not in self.sym_finder: finder = debugger_plugin.core.symbols.SymbolFinder( open(filepath).read()) finder.parse() self.sym_finder[filepath] = finder else: finder = self.sym_finder[filepath] sym = finder.get(c.blockNumber() + 1, c.columnNumber()) if sym is not None: ret = self.debugger_adapter.evaluate(thread_id, sym.expression, depth=0) content = "{exp} = ({type}) {value}".format( exp=sym.expression, type=ret['type'], value=ret['value']) QToolTip.showText(editor_widget.mapToGlobal(pos), content) finally: self.__old_mouse_event(event)
def help_event(self, event): if self.scatterplot_item is None: return False act_pos = self.scatterplot_item.mapFromScene(event.scenePos()) points = self.scatterplot_item.pointsAt(act_pos) text = "" if len(points): for i, p in enumerate(points): index = p.data() text += "Attributes:\n" if self.tooltip_shows_all: text += "".join(' {} = {}\n'.format( attr.name, self.raw_data[index][attr]) for attr in self.data_domain.attributes) else: text += ' {} = {}\n {} = {}\n'.format( self.shown_x, self.raw_data[index][self.shown_x], self.shown_y, self.raw_data[index][self.shown_y]) if self.data_domain.class_var: text += 'Class:\n {} = {}\n'.format( self.data_domain.class_var.name, self.raw_data[index][self.raw_data.domain.class_var]) if i < len(points) - 1: text += '------------------\n' text = ('<span style="white-space:pre">{}</span>'.format( escape(text))) QToolTip.showText(event.screenPos(), text, widget=self.plot_widget) return True else: return False
def showMethodToolTip( self ): """ Pops up a tooltip message with the help for the object under the \ cursor. :return <bool> success """ self.cancelCompletion() obj = self.objectAtCursor() if ( not obj ): return False docs = inspect.getdoc(obj) if ( not docs ): return False # determine the cursor position rect = self.cursorRect() cursor = self.textCursor() point = QPoint(rect.left(), rect.top() + 18) QToolTip.showText( self.mapToGlobal(point), docs, self ) return True
def load_ui(self, centralWidget): #Set Application Font for ToolTips QToolTip.setFont(QFont(settings.FONT_FAMILY, 10)) #Create Main Container to manage Tabs self.mainContainer = main_container.MainContainer(self) self.connect(self.mainContainer, SIGNAL("currentTabChanged(QString)"), self.change_window_title) self.connect(self.mainContainer, SIGNAL("locateFunction(QString, QString, bool)"), self.actions.locate_function) self.connect(self.mainContainer, SIGNAL("navigateCode(bool, int)"), self.actions.navigate_code_history) self.connect(self.mainContainer, SIGNAL("addBackItemNavigation()"), self.actions.add_back_item_navigation) self.connect(self.mainContainer, SIGNAL("updateFileMetadata()"), self.actions.update_explorer) self.connect(self.mainContainer, SIGNAL("updateLocator(QString)"), self.actions.update_explorer) self.connect(self.mainContainer, SIGNAL("openPreferences()"), self._show_preferences) self.connect(self.mainContainer, SIGNAL("dontOpenStartPage()"), self._dont_show_start_page_again) self.connect(self.mainContainer, SIGNAL("currentTabChanged(QString)"), self.status.handle_tab_changed) # Update symbols self.connect(self.mainContainer, SIGNAL("updateLocator(QString)"), self.status.explore_file_code) #Create Explorer Panel self.explorer = explorer_container.ExplorerContainer(self) self.connect(self.central, SIGNAL("splitterCentralRotated()"), self.explorer.rotate_tab_position) self.connect(self.explorer, SIGNAL("updateLocator()"), self.status.explore_code) self.connect(self.explorer, SIGNAL("goToDefinition(int)"), self.actions.editor_go_to_line) self.connect(self.explorer, SIGNAL("projectClosed(QString)"), self.actions.close_files_from_project) #Create Misc Bottom Container self.misc = misc_container.MiscContainer(self) self.connect(self.mainContainer, SIGNAL("findOcurrences(QString)"), self.misc.show_find_occurrences) centralWidget.insert_central_container(self.mainContainer) centralWidget.insert_lateral_container(self.explorer) centralWidget.insert_bottom_container(self.misc) self.connect(self.mainContainer, SIGNAL("cursorPositionChange(int, int)"), self.central.lateralPanel.update_line_col) # TODO: Change current symbol on move #self.connect(self.mainContainer, #SIGNAL("cursorPositionChange(int, int)"), #self.explorer.update_current_symbol) self.connect(self.mainContainer, SIGNAL("enabledFollowMode(bool)"), self.central.enable_follow_mode_scrollbar) if settings.SHOW_START_PAGE: self.mainContainer.show_start_page()
def dwellStart(self, pos, x, y): if self.edit.frameGeometry().contains(x, y): name = self.getWordOrSelectionFromPosition(pos) val = self.debugController.evaluateExpression(name.strip()) if val != None: name = cgi.escape(name) val = cgi.escape(val) QToolTip.showText(self.edit.mapToGlobal(QtCore.QPoint(x, y)), "<b>" + name + "</b> = " + val, self.edit, QtCore.QRect())
def event(self, e): if e.type() == QEvent.ToolTip: # show action tooltip instead of widget tooltip act = self.actionAt(e.pos()) if act and act.toolTip() != "None": QToolTip.showText(e.globalPos(), act.toolTip(), self) return True return QMenu.event(self, e)
def show_swatch(self, view): """Shows the swatch if a valid color is selected""" if view.selection(): color = QColor(view.selectionText()) if color.isValid(): cursor_pos = view.cursorPositionCoordinates() QToolTip.showText(cursor_pos, self.swatch_template) self.change_palette(color)
def show_swatch(self, view): '''Shows the swatch if a valid color is selected''' if view.selection(): color = QColor(view.selectionText()) if color.isValid(): cursor_pos = view.cursorPositionCoordinates() QToolTip.showText(cursor_pos, self.swatch_template) self.change_palette(color)
def event(self, e): if e.type() == QEvent.ToolTip: # show action tooltip instead of widget tooltip act = self.actionAt(e.pos()); if act and act.toolTip() != "None": QToolTip.showText(e.globalPos(), act.toolTip(), self) return True return QMenu.event(self, e)
def resolutionSliderChanged(self, v): self.updateDEMSize() # size = 100 * self.horizontalSlider_DEMSize.value() # QToolTip.showText(self.horizontalSlider_DEMSize.mapToGlobal(QPoint(0, 0)), "about {0} x {0}".format(size), self.horizontalSlider_DEMSize) size = 100 * self.horizontalSlider_Resolution.value() QToolTip.showText( self.horizontalSlider_Resolution.mapToGlobal(QPoint(0, 0)), "about {0} x {0}".format(size), self.horizontalSlider_Resolution)
def mouseMoveEvent(self, event): '''Get the current mouse position and redraw the selection''' self.current_x = event.globalX() self.current_y = event.globalY() self.repaint() text = "Start: %sx%s \nEnd: %sx%s" % (self.start_x, self.start_y, self.current_x, self.current_y) QToolTip.showText(event.pos(), text)
def mouseMoveEvent(self, event): blockNumber = self._qpart.cursorForPosition(event.pos()).blockNumber() if blockNumber in self._qpart._lintMarks: msgType, msgText = self._qpart._lintMarks[blockNumber] QToolTip.showText(event.globalPos(), msgText) else: QToolTip.hideText() return QWidget.mouseMoveEvent(self, event)
def showInformationToolTip(self, idx): """ Show an informative string about one sample """ sample = self.model.sample(idx.data().toString(), fullNameEntry=False) if sample is None: return QToolTip.showText(QCursor.pos(), sample.getInfos())
def change_palette(self, color): '''Sets the global tooltip background to the given color and initializes reset''' p = QPalette(self.default_palette) p.setColor(QPalette.All, QPalette.ToolTipBase, color) QToolTip.setPalette(p) self.timer = QTimer() self.timer.timeout.connect(self.try_reset_palette) self.timer.start(300) #short enough not to flicker a wrongly colored tooltip
def event(self, ev): if ev.type() == QEvent.ToolTip: text = self.defaultAction().text() key = self.key() if key: text = _("{name} ({key})").format(name=text, key=key) QToolTip.showText(ev.globalPos(), text) return True return super(Button, self).event(ev)
def init_contents(self): """ Setting up qt controls. """ self.changeDB.hide() self.availableDB.hide() self.availableDB.addItems(dbs.keys()) self.kanjiGroup.setAlignment(Qt.AlignCenter) self.kanjiGroup.setStyleSheet("QGroupBox { border: 1px solid gray; border-radius: 3px; }") self.day.setAlignment(Qt.AlignCenter) self.week.setAlignment(Qt.AlignCenter) self.month.setAlignment(Qt.AlignCenter) self.year.setAlignment(Qt.AlignCenter) self.dayLabel.setAlignment(Qt.AlignCenter) self.weekLabel.setAlignment(Qt.AlignCenter) self.monthLabel.setAlignment(Qt.AlignCenter) self.yearLabel.setAlignment(Qt.AlignCenter) self.day.setFont(QFont(PRETTY_FONT, KANJI_SIZE)) self.week.setFont(QFont(PRETTY_FONT, KANJI_SIZE)) self.month.setFont(QFont(PRETTY_FONT, KANJI_SIZE)) self.year.setFont(QFont(PRETTY_FONT, KANJI_SIZE)) self.methodCombo.addItems(RandomMess.algs.keys()) self.methodCombo.setCurrentIndex(1) self.statusMessage.setAlignment(Qt.AlignCenter) self.statusMessage.hide() self.statusMessage.setMaximumHeight(MESSAGE_HEIGHT) self.statusMessage.setStyleSheet(WARNING_STYLE) self.progressBar.setMaximum(0) self.progressBar.setMaximumHeight(PROGRESS_HEIGHT) self.progressBar.hide() QToolTip.setFont(QFont(PRETTY_FONT, TOOLTIP_FONT_SIZE)) self.getAll.setToolTip('Randomly select all 4 kanji') self.methodCombo.setToolTip('Choose algorithm for randomness') self.authGen.setToolTip('Authorize on remote RNG services') self.showStats.setToolTip('Show/hide dialog with comprehensive statistics') self.quitApp.setToolTip('Close application') self.showDB.setToolTip('Show/hide available databases') self.availableDB.setToolTip('Available kanji frequency charts db') self.changeDB.setToolTip('Pick new kanji from currently selected db') # About dialog self.aboutBox.layout().itemAt(1).widget().setAlignment(Qt.AlignLeft) self.aboutBox.setTextFormat(Qt.RichText) self.aboutBox.setText('Version:\t<b>' + __version__ + '</b><br/>Python:\t<b>' + platform.python_version() + '</b>' + '<br/>Platform:\t<b>' + platform.system() + ' ' + platform.release() + '</b>' + '<br/>Author:\t<b>' + __author__ + '</b>' + app_about) self.aboutBox.setWindowTitle('About ' + app_name) self.aboutBox.setIconPixmap(QPixmap(paths['icon']))
def mouseMoveEvent(self, event): QToolTip.showText( event.globalPos(), 'Block logic expects pumps and valves to always\n' 'have two junctions at their endpoints.\n' 'The pump or valve, together with the two junctions,\n' 'are then considered as a single block, and they are\n' 'moved jointly when using the "Move element tool".', self, self.rect())
def mouseMoveEvent(self, event): # This reimplementation adds support for tool tips QsciScintilla.mouseMoveEvent(self, event) QToolTip.hideText() self._global_mouse_position = event.globalPos() self._mouse_position = event.pos() self._tool_tip_timer.stop() self._tool_tip_timer.start(self.tool_tip_delay * 1000)
def mouseMoveEvent(self, event): super(Editor, self).mouseMoveEvent(event) if self.checker is None: return position = event.pos() line = str(self.lineAt(position) + 1) message = self.checker.data.get(line, None) if message is not None: QToolTip.showText(self.mapToGlobal(position), message)
def show_swatch(self, view): '''Shows the swatch if a valid color is selected''' if view.selection(): color = QColor(view.selectionText()) if color.isValid(): cursor_pos = view.mapToGlobal(view.cursorPositionCoordinates()) QToolTip.showText(cursor_pos, ColorSwatcher._SWATCH_TEMPLATE) self.change_palette(color) else: QToolTip.hideText()
def show(self): " Shows the tooltip at the proper position " QToolTip.hideText() QApplication.processEvents() if not inside: return self.move(self.__getTooltipPos()) self.raise_() QFrame.show(self) return
def event(self, e): action = self.activeAction() if e.type() == QEvent.ToolTip and \ action and \ action.toolTip() != action.text(): QToolTip.showText(e.globalPos(), self.activeAction().toolTip()) else: QToolTip.hideText() return super(Menu, self).event(e)
def _show_tool_tip(self): # Show a tool tip based on the mouse position mouse_line = self._mouse_margin_line() if mouse_line == -1: return for syntax_error in self._syntax_errors: if syntax_error.lineno - 1 == mouse_line: QToolTip.showText(self._global_mouse_position, QString(syntax_error.msg))
def linkHelpEvent(self, globalPos, page, link): """Called when a QHelpEvent occurs on a link. The default implementation shows a tooltip if showUrls() is True, and emits the linkHelpRequested() signal. """ if self._showUrlTips and isinstance(link, popplerqt4.Poppler.LinkBrowse): QToolTip.showText(globalPos, link.url(), self, page.linkRect(link.linkArea())) self.linkHelpRequested.emit(globalPos, page, link)
def eventFilter( self, obj, event ): """ Filters particular events for a given QObject through this class. \ Will use this to intercept events to the completer tree widget while \ filtering. :param obj | <QObject> event | <QEvent> :return <bool> consumed """ if ( not obj == self._completerTree ): return False if ( event.type() != event.KeyPress ): return False if ( event.key() == Qt.Key_Escape ): QToolTip.hideText() self.cancelCompletion() return False elif ( event.key() in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Tab) ): self.acceptCompletion() return False elif ( event.key() in (Qt.Key_Up, Qt.Key_Down) ): return False else: self.keyPressEvent(event) # update the completer cursor = self.textCursor() text = projex.text.toUtf8(cursor.block().text()) text = text[:cursor.columnNumber()].split(' ')[-1] text = text.split('.')[-1] self._completerTree.blockSignals(True) self._completerTree.setUpdatesEnabled(False) self._completerTree.setCurrentItem(None) for i in range(self._completerTree.topLevelItemCount()): item = self._completerTree.topLevelItem(i) if projex.text.toUtf8(item.text(0)).startswith(text): self._completerTree.setCurrentItem(item) break self._completerTree.blockSignals(False) self._completerTree.setUpdatesEnabled(True) return True
def hide_tooltip_if_necessary(self, key): """Hide calltip when necessary""" try: calltip_char = self.get_character(self.calltip_position) before = self.is_cursor_before(self.calltip_position, char_offset=1) other = key in (Qt.Key_ParenRight, Qt.Key_Period, Qt.Key_Tab) if calltip_char not in ('?','(') or before or other: QToolTip.hideText() except (IndexError, TypeError): QToolTip.hideText()
def change_palette(self, color): """Sets the global tooltip background to the given color and initializes reset""" self.old_palette = QToolTip.palette() p = QPalette(self.old_palette) p.setColor(QPalette.All, QPalette.ToolTipBase, color) QToolTip.setPalette(p) self.timer = QTimer() self.timer.timeout.connect(self.try_reset_palette) self.timer.start( 300) #short enough not to flicker a wrongly colored tooltip
def eventFilter(self, obj, event): """ Filters particular events for a given QObject through this class. \ Will use this to intercept events to the completer tree widget while \ filtering. :param obj | <QObject> event | <QEvent> :return <bool> consumed """ if (not obj == self._completerTree): return False if (event.type() != event.KeyPress): return False if (event.key() == Qt.Key_Escape): QToolTip.hideText() self.cancelCompletion() return False elif (event.key() in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Tab)): self.acceptCompletion() return False elif (event.key() in (Qt.Key_Up, Qt.Key_Down)): return False else: self.keyPressEvent(event) # update the completer cursor = self.textCursor() text = projex.text.toUtf8(cursor.block().text()) text = text[:cursor.columnNumber()].split(' ')[-1] text = text.split('.')[-1] self._completerTree.blockSignals(True) self._completerTree.setUpdatesEnabled(False) self._completerTree.setCurrentItem(None) for i in range(self._completerTree.topLevelItemCount()): item = self._completerTree.topLevelItem(i) if projex.text.toUtf8(item.text(0)).startswith(text): self._completerTree.setCurrentItem(item) break self._completerTree.blockSignals(False) self._completerTree.setUpdatesEnabled(True) return True
def showToolTip(self): """ """ self.timerMapTips.stop() if self.canvas.underMouse(): raster = self.parent.rasterComboBox.currentLayer() if raster: text = self.getPixelValue(raster) p = self.canvas.mapToGlobal( self.canvas.mouseLastXY() ) QToolTip.showText( p, text, self.canvas )
def __showRevisionTooltip(self, position, x, y): # Calculate the line pos = self.SendScintilla(self.SCI_POSITIONFROMPOINT, x, y) line, posInLine = self.lineIndexFromPosition(pos) tooltip = self.__getRevisionMarginTooltip(line) if not tooltip: return QToolTip.showText(self.mapToGlobal(QPoint(x, y)), tooltip) self.__revisionTooltipShown = True return
def linkHovered(self, link, title, textContent): """ Overload function. Show tooltip when hovered. # ToFix: tooltip disappear too soon. """ #self.setToolTip(link) if link: self.flag = True self.link = link QToolTip.showText(QCursor.pos(), self.link) else: self.flag = False
def showToolTip(self, qgsPoint): """ """ self.timerMapTips.stop() self.timerMapTips.start( 6000 ) # time in milliseconds if self.canvas.underMouse(): raster = self.rasterComboBox.currentLayer() if raster: text = self.getPixelValue(qgsPoint, raster) p = self.canvas.mapToGlobal( self.canvas.mouseLastXY() ) QToolTip.showText( p, text, self.canvas )
def hoverLeaveEvent(self, event): """ Processes when this hotspot is entered. :param event | <QHoverEvent> :return <bool> | processed """ self._hovered = False if self.toolTip(): QToolTip.hideText() return self.style() == XNodeHotspot.Style.Icon
def __showTimestampTooltip(self, position, x, y): " Shows a tooltip on the timestamp margin " # Calculate the line pos = self.SendScintilla(self.SCI_POSITIONFROMPOINT, x, y) line, _ = self.lineIndexFromPosition(pos) tooltip = self.__getTimestampMarginTooltip(line) if not tooltip: return QToolTip.showText(self.mapToGlobal(QPoint(x, y)), tooltip) self.__timestampTooltipShown = True return