9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 import sys |
12 import sys |
13 import unicodedata |
13 import unicodedata |
14 try: # Py3 |
14 try: |
|
15 # Py3 |
15 import html.entities as html_entities |
16 import html.entities as html_entities |
16 except (ImportError): |
17 except (ImportError): |
17 chr = unichr # __IGNORE_WARNING__ |
18 # Py2 |
18 import htmlentitydefs as html_entities # __IGNORE_WARNING__ |
19 str = unicode # __IGNORE_WARNING__ |
|
20 chr = unichr # __IGNORE_WARNING__ |
|
21 import htmlentitydefs as html_entities # __IGNORE_WARNING__ |
19 |
22 |
20 from PyQt5.QtCore import pyqtSlot, pyqtSignal, QAbstractTableModel, \ |
23 from PyQt5.QtCore import pyqtSlot, pyqtSignal, QAbstractTableModel, \ |
21 QModelIndex, Qt, qVersion, QItemSelectionModel |
24 QModelIndex, Qt, qVersion, QItemSelectionModel |
22 from PyQt5.QtGui import QColor |
25 from PyQt5.QtGui import QColor |
23 from PyQt5.QtWidgets import QWidget, QHeaderView, QAbstractItemView |
26 from PyQt5.QtWidgets import QWidget, QHeaderView, QAbstractItemView |
425 Private method to check, if a character is a digit. |
428 Private method to check, if a character is a digit. |
426 |
429 |
427 @param char character to test (one character string) |
430 @param char character to test (one character string) |
428 @return flag indicating a digit (boolean) |
431 @return flag indicating a digit (boolean) |
429 """ |
432 """ |
430 return unicodedata.category(char) == "Nd" |
433 return unicodedata.category(str(char)) == "Nd" |
431 |
434 |
432 def __isLetter(self, char): |
435 def __isLetter(self, char): |
433 """ |
436 """ |
434 Private method to check, if a character is a letter. |
437 Private method to check, if a character is a letter. |
435 |
438 |
436 @param char character to test (one character string) |
439 @param char character to test (one character string) |
437 @return flag indicating a letter (boolean) |
440 @return flag indicating a letter (boolean) |
438 """ |
441 """ |
439 return unicodedata.category(char) in ["Lu", "Ll", "Lt", "Lm", "Lo"] |
442 return unicodedata.category(str(char)) in ["Lu", "Ll", "Lt", "Lm", |
|
443 "Lo"] |
440 |
444 |
441 def __isMark(self, char): |
445 def __isMark(self, char): |
442 """ |
446 """ |
443 Private method to check, if a character is a mark character. |
447 Private method to check, if a character is a mark character. |
444 |
448 |
445 @param char character to test (one character string) |
449 @param char character to test (one character string) |
446 @return flag indicating a mark character (boolean) |
450 @return flag indicating a mark character (boolean) |
447 """ |
451 """ |
448 return unicodedata.category(char) in ["Mn", "Mc", "Me"] |
452 return unicodedata.category(str(char)) in ["Mn", "Mc", "Me"] |
449 |
453 |
450 def __isSymbol(self, char): |
454 def __isSymbol(self, char): |
451 """ |
455 """ |
452 Private method to check, if a character is a symbol. |
456 Private method to check, if a character is a symbol. |
453 |
457 |
454 @param char character to test (one character string) |
458 @param char character to test (one character string) |
455 @return flag indicating a symbol (boolean) |
459 @return flag indicating a symbol (boolean) |
456 """ |
460 """ |
457 return unicodedata.category(char) in ["Sm", "Sc", "Sk", "So"] |
461 return unicodedata.category(str(char)) in ["Sm", "Sc", "Sk", "So"] |
458 |
462 |
459 def __isPunct(self, char): |
463 def __isPunct(self, char): |
460 """ |
464 """ |
461 Private method to check, if a character is a punctuation character. |
465 Private method to check, if a character is a punctuation character. |
462 |
466 |
463 @param char character to test (one character string) |
467 @param char character to test (one character string) |
464 @return flag indicating a punctuation character (boolean) |
468 @return flag indicating a punctuation character (boolean) |
465 """ |
469 """ |
466 return unicodedata.category(char) in ["Pc", "Pd", "Ps", "Pe", "Pi", |
470 return unicodedata.category(str(char)) in ["Pc", "Pd", "Ps", "Pe", |
467 "Pf", "Po"] |
471 "Pi", "Pf", "Po"] |
468 |
472 |
469 |
473 |
470 class SymbolsWidget(QWidget, Ui_SymbolsWidget): |
474 class SymbolsWidget(QWidget, Ui_SymbolsWidget): |
471 """ |
475 """ |
472 Class implementing a widget to select a symbol in various formats. |
476 Class implementing a widget to select a symbol in various formats. |