本文整理汇总了Python中PySide.QtCore.QRegExp.setMinimal方法的典型用法代码示例。如果您正苦于以下问题:Python QRegExp.setMinimal方法的具体用法?Python QRegExp.setMinimal怎么用?Python QRegExp.setMinimal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtCore.QRegExp
的用法示例。
在下文中一共展示了QRegExp.setMinimal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide.QtCore import QRegExp [as 别名]
# 或者: from PySide.QtCore.QRegExp import setMinimal [as 别名]
def __init__(self, parent=None):
super(PythonSyntax, self).__init__(parent)
# common statement words
self.keywordF.setForeground(self.TM_GET("keyword"))
self.keywordF.setFontWeight(QFont.Bold)
keyword_list = (r"False|class|finally|is|return",
r"None|continue|for|lambda|try",
r"True|def|from|nonlocal|while",
r"and|del|global|not|with|as",
r"elif|if|or|yield|assert|else",
r"import|pass|break|except|in|raise")
for word in keyword_list:
pattern = QRegExp("\\b" + word +"\\b")
rule = HighlightingRule(pattern, self.keywordF)
self.highlighting_rules.append(rule)
# special methods
self.keyword_reservedF.setForeground(self.TM_GET("keyword_reserved"))
self.keyword_reservedF.setFontWeight(QFont.Bold)
keywords_reserved = (r"__\w*__ | _\w* | __\w*",)
for method in keywords_reserved:
pattern = QRegExp("\\b" + method +"\\b")
rule = HighlightingRule(pattern, self.keyword_reservedF)
self.highlighting_rules.append(rule)
# number
self.numberF.setForeground(self.TM_GET("number"))
pattern = QRegExp("[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?")
pattern.setMinimal(True)
rule = HighlightingRule(pattern, self.numberF)
self.highlighting_rules.append(rule)
#number long
self.number_longF.setForeground(self.TM_GET("number_long"))
pattern = QRegExp(r"\d+L")
rule = HighlightingRule(pattern, self.number_longF)
self.highlighting_rules.append(rule)
# builtin functions
self.keyword_builtinF.setForeground(self.TM_GET("keyword_builtin"))
keywords_builtin_list = (r"abs|divmod|input|open|staticmethod|all",
r"enumerate|int|ord",
r"str|any|eval|isinstance|pow|sum",
r"basestring|execfile|issubclass|print",
r"super|bin|file|iter|property",
r"tuple|bool|filter|len|range|type",
r"bytearray|float|list|raw_input|unichr",
r"callable|format|locals|reduce|unicode",
r"chr|frozenset|long|reload|vars",
r"classmethod|getattr|map|repr|xrange",
r"cmp|globals|max|reversed|zip",
r"compile|hasattr|memoryview|round",
r"complex|hash|min|set",
r"apply|delattr|help|next|setattr",
r"buffer|dict|hex|object|slice|coerce",
r"dir|id|oct|sorted|intern",)
# this (?<!\.) belongs in the following list
keywords_exceptions_list = (r"ArithmeticError|AssertionError|AttributeError|"
r"BaseException|DeprecationWarning|EOFError|EnvironmentError|"
r"Exception|FloatingPointError|FutureWarning|GeneratorExit|IOError|"
r"ImportError|ImportWarning|IndentationError|IndexError|KeyError|"
r"KeyboardInterrupt|LookupError|MemoryError|NameError|"
r"NotImplemented|NotImplementedError|OSError|OverflowError|"
r"OverflowWarning|PendingDeprecationWarning|ReferenceError|"
r"RuntimeError|RuntimeWarning|StandardError|StopIteration|"
r"SyntaxError|SyntaxWarning|SystemError|SystemExit|TabError|"
r"TypeError|UnboundLocalError|UnicodeDecodeError|"
r"UnicodeEncodeError|UnicodeError|UnicodeTranslateError|"
r"UnicodeWarning|UserWarning|ValueError|VMSError|Warning|"
r"WindowsError|ZeroDivisionError",)
for word in keywords_builtin_list:
pattern = QRegExp(r"\b"+word+"(?=[(])+")
rule = HighlightingRule(pattern, self.keyword_builtinF)
self.highlighting_rules.append(rule)
for word in keywords_exceptions_list:
pattern = QRegExp("\b"+word+"\\b")
rule = HighlightingRule(pattern, self.keyword_builtinF)
self.highlighting_rules.append(rule)
# names
self.name_builtinF.setForeground(self.TM_GET("name_builtin"))
name_pattern_list = ["(def)((\s)+)(?:.*)(?=[(])",
"(class)((\s)+)(?:.*)(?=[(])",
]
for word in name_pattern_list:
pattern = QRegExp(word)
rule = HighlightingRule(pattern, self.name_builtinF)
self.highlighting_rules.append(rule)
# function keywords
self.keyword_functionF.setForeground(self.TM_GET("keyword_function"))
keywords_functions = (r"class|def",)
#.........这里部分代码省略.........