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, QLocale |
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 |
24 |
27 |
25 from .Ui_SymbolsWidget import Ui_SymbolsWidget |
28 from .Ui_SymbolsWidget import Ui_SymbolsWidget |
26 |
29 |
425 Private method to check, if a character is a digit. |
430 Private method to check, if a character is a digit. |
426 |
431 |
427 @param char character to test (one character string) |
432 @param char character to test (one character string) |
428 @return flag indicating a digit (boolean) |
433 @return flag indicating a digit (boolean) |
429 """ |
434 """ |
430 return unicodedata.category(char) == "Nd" |
435 return unicodedata.category(str(char)) == "Nd" |
431 |
436 |
432 def __isLetter(self, char): |
437 def __isLetter(self, char): |
433 """ |
438 """ |
434 Private method to check, if a character is a letter. |
439 Private method to check, if a character is a letter. |
435 |
440 |
436 @param char character to test (one character string) |
441 @param char character to test (one character string) |
437 @return flag indicating a letter (boolean) |
442 @return flag indicating a letter (boolean) |
438 """ |
443 """ |
439 return unicodedata.category(char) in ["Lu", "Ll", "Lt", "Lm", "Lo"] |
444 return unicodedata.category(str(char)) in ["Lu", "Ll", "Lt", "Lm", |
|
445 "Lo"] |
440 |
446 |
441 def __isMark(self, char): |
447 def __isMark(self, char): |
442 """ |
448 """ |
443 Private method to check, if a character is a mark character. |
449 Private method to check, if a character is a mark character. |
444 |
450 |
445 @param char character to test (one character string) |
451 @param char character to test (one character string) |
446 @return flag indicating a mark character (boolean) |
452 @return flag indicating a mark character (boolean) |
447 """ |
453 """ |
448 return unicodedata.category(char) in ["Mn", "Mc", "Me"] |
454 return unicodedata.category(str(char)) in ["Mn", "Mc", "Me"] |
449 |
455 |
450 def __isSymbol(self, char): |
456 def __isSymbol(self, char): |
451 """ |
457 """ |
452 Private method to check, if a character is a symbol. |
458 Private method to check, if a character is a symbol. |
453 |
459 |
454 @param char character to test (one character string) |
460 @param char character to test (one character string) |
455 @return flag indicating a symbol (boolean) |
461 @return flag indicating a symbol (boolean) |
456 """ |
462 """ |
457 return unicodedata.category(char) in ["Sm", "Sc", "Sk", "So"] |
463 return unicodedata.category(str(char)) in ["Sm", "Sc", "Sk", "So"] |
458 |
464 |
459 def __isPunct(self, char): |
465 def __isPunct(self, char): |
460 """ |
466 """ |
461 Private method to check, if a character is a punctuation character. |
467 Private method to check, if a character is a punctuation character. |
462 |
468 |
463 @param char character to test (one character string) |
469 @param char character to test (one character string) |
464 @return flag indicating a punctuation character (boolean) |
470 @return flag indicating a punctuation character (boolean) |
465 """ |
471 """ |
466 return unicodedata.category(char) in ["Pc", "Pd", "Ps", "Pe", "Pi", |
472 return unicodedata.category(str(char)) in ["Pc", "Pd", "Ps", "Pe", |
467 "Pf", "Po"] |
473 "Pi", "Pf", "Po"] |
|
474 |
|
475 def getLocale(self): |
|
476 """ |
|
477 Public method to get the used locale. |
|
478 |
|
479 @return used locale |
|
480 @rtype QLocale |
|
481 """ |
|
482 return self.__locale |
468 |
483 |
469 |
484 |
470 class SymbolsWidget(QWidget, Ui_SymbolsWidget): |
485 class SymbolsWidget(QWidget, Ui_SymbolsWidget): |
471 """ |
486 """ |
472 Class implementing a widget to select a symbol in various formats. |
487 Class implementing a widget to select a symbol in various formats. |
552 @param index index of the character table (integer) |
567 @param index index of the character table (integer) |
553 """ |
568 """ |
554 self.symbolsTable.setUpdatesEnabled(False) |
569 self.symbolsTable.setUpdatesEnabled(False) |
555 self.__model.selectTable(index) |
570 self.__model.selectTable(index) |
556 self.symbolsTable.setUpdatesEnabled(True) |
571 self.symbolsTable.setUpdatesEnabled(True) |
|
572 self.symbolsTable.resizeColumnsToContents() |
557 |
573 |
558 first, last = self.__model.getTableBoundaries(index) |
574 first, last = self.__model.getTableBoundaries(index) |
559 self.symbolSpinBox.setMinimum(first) |
575 self.symbolSpinBox.setMinimum(first) |
560 self.symbolSpinBox.setMaximum(last) |
576 self.symbolSpinBox.setMaximum(last) |
561 |
577 |