Esempio n. 1
0
    def __init__(self, name, default_position='right', parent=None, folded=False):
        """
        All of the panel constructors follow the same format so that the construction can be
        automated.
        :param name: Title of the panel and the key for accessing it
        :param default_position: 'bottom', 'right'...
        :param parent: self.main
        """
        Panel.__init__(self, name, default_position, parent, folded)
        inner = QtWidgets.QWidget()
        #inner.preferred_size = QtCore.QSize(220, 130)
        inner.setMinimumSize(160, 130)
        inner.setMaximumSize(220, 400)
        inner.setMinimumWidth(160)

        layout = QtWidgets.QVBoxLayout()
        self.selector = SelectionBox(self)
        self.selector.add_items([(table_dict[item], item) for item in table_names])
        self.selector.activated.connect(self.change_symbol_set)
        self.selector.setFocusPolicy(QtCore.Qt.TabFocus)
        layout.addWidget(self.selector)
        self.symlist = QtWidgets.QListWidget()
        self.symlist.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
         QtWidgets.QSizePolicy.Expanding)
        self.symlist.setSpacing(8)
        self.symlist.setMouseTracking(True)
        self.symlist.setFocusPolicy(QtCore.Qt.NoFocus)
        self.symlist.setViewMode(QtWidgets.QListWidget.IconMode)
        f = qt_prefs.get_font(g.MAIN_FONT)
        self.symlist.setStyleSheet('font-family: "%s"; font-size: %spx;' % (
            f.family(), int(f.pointSize() * 1.5)))
        self.symlist.itemEntered.connect(self.item_entered)
        self.symlist.itemClicked.connect(self.item_clicked)
        layout.addWidget(self.symlist)
        hlayout = box_row(layout)
        self.info = QtWidgets.QLabel('')
        hlayout.addWidget(self.info)
        self.resize_grip = QtWidgets.QSizeGrip(self)
        self.resize_grip.hide()
        hlayout.addWidget(self.resize_grip, 0, QtCore.Qt.AlignRight)
        inner.setLayout(layout)
        self.tables = {}
        keys = list(latex_to_unicode.keys())
        for name in table_names:
            self.tables[name] = []
        keys.sort()
        for key in keys:
            char, description, table_key = latex_to_unicode[key]
            self.tables[table_key].append(key)
        self.tables['greek'] = greek_letters
        self.tables['arrows'] = arrows
        self.tables['more arrows'] = more_arrows
        self.tables['common'] = common
        # self.tables['arrows'] = arrows
        self.prepare_symbols('common')
        self.setWidget(inner)
        self.finish_init()
Esempio n. 2
0
    def __init__(self,
                 name,
                 default_position='right',
                 parent=None,
                 folded=False):
        """
        All of the panel constructors follow the same format so that the construction can be
        automated.
        :param name: Title of the panel and the key for accessing it
        :param default_position: 'bottom', 'right'...
        :param parent: self.main
        """
        Panel.__init__(self, name, default_position, parent, folded)
        inner = QtWidgets.QWidget()
        #inner.preferred_size = QtCore.QSize(220, 130)
        inner.setMinimumSize(160, 130)
        inner.setMaximumSize(220, 400)
        inner.setMinimumWidth(160)

        layout = QtWidgets.QVBoxLayout()
        self.selector = SelectionBox(self)
        self.selector.add_items([(table_dict[item], item)
                                 for item in table_names])
        self.selector.activated.connect(self.change_symbol_set)
        self.selector.setFocusPolicy(QtCore.Qt.TabFocus)
        layout.addWidget(self.selector)
        self.symlist = QtWidgets.QListWidget()
        self.symlist.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                   QtWidgets.QSizePolicy.Expanding)
        self.symlist.setSpacing(8)
        self.symlist.setMouseTracking(True)
        self.symlist.setFocusPolicy(QtCore.Qt.NoFocus)
        self.symlist.setViewMode(QtWidgets.QListWidget.IconMode)
        f = qt_prefs.get_font(g.MAIN_FONT)
        self.symlist.setStyleSheet('font-family: "%s"; font-size: %spx;' %
                                   (f.family(), int(f.pointSize() * 1.5)))
        self.symlist.itemEntered.connect(self.item_entered)
        self.symlist.itemClicked.connect(self.item_clicked)
        layout.addWidget(self.symlist)
        hlayout = box_row(layout)
        self.info = QtWidgets.QLabel('')
        hlayout.addWidget(self.info)
        self.resize_grip = QtWidgets.QSizeGrip(self)
        self.resize_grip.hide()
        hlayout.addWidget(self.resize_grip, 0, QtCore.Qt.AlignRight)
        inner.setLayout(layout)
        self.tables = {}
        keys = list(latex_to_unicode.keys())
        for name in table_names:
            self.tables[name] = []
        keys.sort()
        for key in keys:
            char, description, table_key = latex_to_unicode[key]
            self.tables[table_key].append(key)
        self.tables['greek'] = greek_letters
        self.tables['arrows'] = arrows
        self.tables['more arrows'] = more_arrows
        self.tables['common'] = common
        # self.tables['arrows'] = arrows
        self.prepare_symbols('common')
        self.setWidget(inner)
        self.finish_init()
Esempio n. 3
0
from kataja.parser.latex_to_unicode import latex_to_unicode

greek = []
latin = []
combining = []
rest = []
keys = list(latex_to_unicode.keys())
keys.sort()
d = {}

tables = [
    'cyrchar', 'ding', 'ElsevierGlyph', 'mathbb', 'mathbf', 'mathbit',
    'mathfrak', 'mathmit', 'mathscr', 'mathsfbfsl', 'mathsfbf', 'mathsfsl',
    'mathsf', 'mathslbb', 'mathsl', 'mathtt'
]

for table in tables:
    d[table] = []

for key in keys:
    char, description = latex_to_unicode[key]
    if 'greek' in description:
        greek.append(key)
    elif description.startswith('latin'):
        latin.append(key)
    elif description.startswith('combining'):
        combining.append(key)
    else:
        found = False
        for tname in tables:
            if key.startswith(tname):