PluginColorString.py

changeset 40
e0086d2cb15d
parent 39
a72b02f76b16
child 42
6a5cd4a132e2
equal deleted inserted replaced
39:a72b02f76b16 40:e0086d2cb15d
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the 'Color String' tool plug-in. 7 Module implementing the 'Color String' tool plug-in.
8 """ 8 """
9
10 from __future__ import unicode_literals
11 9
12 import os 10 import os
13 11
14 from PyQt5.QtCore import QObject, QTranslator 12 from PyQt5.QtCore import QObject, QTranslator
15 from PyQt5.QtGui import QColor 13 from PyQt5.QtGui import QColor
21 # Start-Of-Header 19 # Start-Of-Header
22 name = "Color String Plug-in" 20 name = "Color String Plug-in"
23 author = "Detlev Offenbach <detlev@die-offenbachs.de>" 21 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
24 autoactivate = True 22 autoactivate = True
25 deactivateable = True 23 deactivateable = True
26 version = "2.2.3" 24 version = "3.0.0"
27 className = "ColorStringPlugin" 25 className = "ColorStringPlugin"
28 packageName = "ColorString" 26 packageName = "ColorString"
29 shortDescription = "Insert color as string" 27 shortDescription = "Insert color as string"
30 longDescription = \ 28 longDescription = (
31 """This plug-in implements a tool to select a color via a""" \ 29 """This plug-in implements a tool to select a color via a"""
32 """ color selection dialog and insert it as a hex string at the""" \ 30 """ color selection dialog and insert it as a hex string at the"""
33 """ current cursor position. Selected text is used to initialize""" \ 31 """ current cursor position. Selected text is used to initialize"""
34 """ the dialog and is replaced with the new color.""" 32 """ the dialog and is replaced with the new color."""
33 )
35 needsRestart = False 34 needsRestart = False
36 pyqtApi = 2 35 pyqtApi = 2
37 python2Compatible = True
38 # End-Of-Header 36 # End-Of-Header
39 37
40 error = "" 38 error = ""
41 39
42 40
219 Private method to check, if a given text is a hex string. 217 Private method to check, if a given text is a hex string.
220 218
221 @param text text to check (string) 219 @param text text to check (string)
222 @return flag indicating a hex string (boolean) 220 @return flag indicating a hex string (boolean)
223 """ 221 """
224 isHex = True 222 return all(map(lambda c: c in "0123456789abcdefABCDEF", text))
225 for c in text:
226 isHex = isHex and c in "0123456789abcdefABCDEF"
227 return isHex
228 223
229 def __isValidColor(self, name): 224 def __isValidColor(self, name):
230 """ 225 """
231 Private method to check for a valid color name. 226 Private method to check for a valid color name.
232 227

eric ide

mercurial