Пример #1
0
    def highlightBlock(self, text):
        if not self.enabled:
            return
        fmt = QTextCharFormat()
        fmt.setUnderlineColor(Qt.red)
        fmt.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline)

        for word_object in re.finditer(self.WORDS, text):
            if not self.spellcheck.check(word_object.group()):
                self.setFormat(word_object.start(),
                    word_object.end() - word_object.start(), fmt)
Пример #2
0
    def highlightBlock(self, text):
        if not self.enabled:
            return
        fmt = QTextCharFormat()
        fmt.setUnderlineColor(Qt.red)
        fmt.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline)

        for word_object in re.finditer(self.WORDS, text):
            if not self.spellcheck.check(word_object.group()):
                self.setFormat(word_object.start(),
                               word_object.end() - word_object.start(), fmt)
Пример #3
0
    def highlightBlock(self, text):
        text = unicode(text)

        tformat = QTextCharFormat()
        tformat.setUnderlineColor(Qt.red)
        tformat.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline)

        for word_object in re.finditer(self.WORDS, text):
            if not self.spell_dict.check(word_object.group()):
                self.setFormat(word_object.start(),
                               word_object.end() - word_object.start(),
                               tformat)
Пример #4
0
    def highlightBlock(self, text):
        if not self.dict:
            return

        text = unicode(text)

        format = QTextCharFormat()
        format.setUnderlineColor(Qt.red)
        format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline)

        for word_object in re.finditer(self.WORDS, text):
            if not self.dict.check(word_object.group()):
                self.setFormat(word_object.start(),
                               word_object.end() - word_object.start(), format)
Пример #5
0
    def highlightBlock(self, text):
        if not self.dict:
            return

        text = unicode(text)

        format = QTextCharFormat()
        #format.setUnderlineColor(Qt.red)
        format.setUnderlineStyle(QTextCharFormat.DotLine)

        for word_object in re.finditer(self.WORDS, text):
            if not self.dict.check(word_object.group()):
                self.setFormat(word_object.start(),
                               word_object.end() - word_object.start(), format)
Пример #6
0
def highlight_to_char_format(h):
    ans = QTextCharFormat()
    if h.bold:
        ans.setFontWeight(QFont.Bold)
    if h.italic:
        ans.setFontItalic(True)
    if h.fg is not None:
        ans.setForeground(h.fg)
    if h.bg is not None:
        ans.setBackground(h.bg)
    if h.underline is not None:
        ans.setUnderlineStyle(underline_styles[h.underline])
        if h.underline_color is not None:
            ans.setUnderlineColor(h.underline_color.color())
    return ans
Пример #7
0
 def highlightBlock(self, text):
     if not self.dict:
         return
     if not text:
         return
     txt = unicode(text)
     #if len(txt.split())==1:
     #    txt=""
     #else:
     #    txt=txt.rsplit(' ',1)[0]            
     format = QTextCharFormat()
     format.setUnderlineColor(Qt.red)
     format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline)
     unicode_pattern=regex.compile(self.pattern,regex.UNICODE)
     for word_object in unicode_pattern.finditer(txt):
         if not self.dict.spell(word_object.group().encode('utf-8')):
             self.setFormat(word_object.start(), word_object.end() - word_object.start(), format)
             self.errorcount+=1
     print self.errorcount
Пример #8
0
 def highlightBlock(self, text):
     if not self.dict:
         return
     if not text:
         return
     txt = unicode(text)
     #if len(txt.split())==1:
     #    txt=""
     #else:
     #    txt=txt.rsplit(' ',1)[0]
     format = QTextCharFormat()
     format.setUnderlineColor(Qt.red)
     format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline)
     unicode_pattern = regex.compile(self.pattern, regex.UNICODE)
     for word_object in unicode_pattern.finditer(txt):
         if not self.dict.spell(word_object.group().encode('utf-8')):
             self.setFormat(word_object.start(),
                            word_object.end() - word_object.start(), format)
             self.errorcount += 1
     print self.errorcount