def __init__(self): super(TRGlyphBasic, self).__init__() # -- Edit fileds self.edt_glyphName = TRGLineEdit() self.edt_glyphTags = TRGLineEdit() self.edt_glyphUnis = TRGLineEdit() self.edt_glyphName.setPlaceholderText('Glyph Name') self.edt_glyphTags.setPlaceholderText('Glyph Tags') self.edt_glyphUnis.setPlaceholderText('Glyph Unicodes') self.edt_glyphName.setToolTip(help_numeration) # -- Buttons self.btn_setName = QtGui.QPushButton('Set &Name') self.btn_setFlag = QtGui.QPushButton('Set &Flag') self.btn_setTags = QtGui.QPushButton('Set &Tags') self.btn_setUnis = QtGui.QPushButton('Set &Unicode') self.btn_setUnis.setEnabled(False) self.btn_setName.clicked.connect(lambda: self.glyph_setBasics('name')) self.btn_setFlag.clicked.connect(lambda: self.glyph_setBasics('flag')) self.btn_setTags.clicked.connect(lambda: self.glyph_setBasics('tags')) self.btn_setName.setToolTip(help_setName) # -- Combo box #fontMarkColors = [(QtGui.QColor(name).hue(), name) for name in QtGui.QColor.fontMarkColors()] self.cmb_select_color = QtGui.QComboBox() self.color_codes = { name: value for name, value, discard in fontMarkColors } for i in range(len(fontMarkColors)): self.cmb_select_color.addItem(fontMarkColors[i][0]) self.cmb_select_color.setItemData( i, QtGui.QColor(fontMarkColors[i][2]), QtCore.Qt.DecorationRole) self.cmb_select_color.setMinimumWidth(40) self.edt_glyphName.setMinimumWidth(40) # - Build self.addWidget(QtGui.QLabel('Glyph Basics:'), 0, 0, 1, 8) self.addWidget(QtGui.QLabel('Name:'), 1, 0, 1, 1) self.addWidget(self.edt_glyphName, 1, 1, 1, 5) self.addWidget(self.btn_setName, 1, 6, 1, 2) self.addWidget(QtGui.QLabel('Flag:'), 2, 0, 1, 1) self.addWidget(self.cmb_select_color, 2, 1, 1, 5) self.addWidget(self.btn_setFlag, 2, 6, 1, 2) self.addWidget(QtGui.QLabel('Tags:'), 3, 0, 1, 1) self.addWidget(self.edt_glyphTags, 3, 1, 1, 5) self.addWidget(self.btn_setTags, 3, 6, 1, 2) self.addWidget(QtGui.QLabel('Uni:'), 4, 0, 1, 1) self.addWidget(self.edt_glyphUnis, 4, 1, 1, 5) self.addWidget(self.btn_setUnis, 4, 6, 1, 2)
def markDiff(self): #!!! Ineffecient but will do self.blockSignals(True) root = self.invisibleRootItem() init_diff = [] for i in range(root.childCount()): item = root.child(i) init_diff.append( [item.child(n).text(0) for n in range(item.childCount())]) for i in range(root.childCount()): item = root.child(i) for n in range(item.childCount()): if all([item.child(n).text(0) in test for test in init_diff]): item.child(n).setData(0, QtCore.Qt.DecorationRole, QtGui.QColor('LimeGreen')) else: item.child(n).setData(0, QtCore.Qt.DecorationRole, QtGui.QColor('Crimson')) self.blockSignals(False)
def __init__(self): super(GroupTableView, self).__init__() # - Init self.flag_valueChanged = QtGui.QColor('powderblue') self.header = self.horizontalHeader() # - Behavior self.itemChanged.connect(self.markChange) # - Styling self.verticalHeader().hide() self.setAlternatingRowColors(True) self.setShowGrid(False) self.setSortingEnabled(True)
def setTable(self, data, data_check=[], reset=False): name_row, name_column = [], [] self.blockSignals(True) self.setColumnCount(max(map(len, data.values()))) self.setRowCount(len(data.keys())) # - Populate for n, layer in enumerate(sorted(data.keys())): name_row.append(layer) for m, key in enumerate(data[layer].keys()): # -- Build name column name_column.append(key) # -- Add first data column newitem = QtGui.QTableWidgetItem(str( data[layer][key])) if m == 0 else QtGui.QTableWidgetItem() # -- Selectively colorize missing data if m == 0 and len( data_check) and data[layer][key] not in data_check: newitem.setBackground(QtGui.QColor('red')) # -- Build Checkbox columns if m > 0: newitem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) if m > 0: newitem.setCheckState( QtCore.Qt.Unchecked if not data[layer][key] else QtCore.Qt.Checked) self.setItem(n, m, newitem) self.setHorizontalHeaderLabels(name_column) self.setVerticalHeaderLabels(name_row) self.blockSignals(False)
import Filter as Panel # - Init -------------------------- app_version = '0.15' app_name = 'TypeRig Filter' ignorePanel = '__' # -- Global parameters pMode = 0 pLayers = (True, False, False, False) # -- Inital config for Get Layers dialog column_names = ('Layer Name', 'Layer Type') column_init = (None, None) table_dict = {1:OrderedDict(zip(column_names, column_init))} color_dict = {'Master': QtGui.QColor(0, 255, 0, 20), 'Service': QtGui.QColor(0, 0, 255, 20), 'Mask': QtGui.QColor(255, 0, 0, 20)} # - Style ------------------------- ss_Toolbox_none = """/* EMPTY STYLESHEET */ """ # - Interface ----------------------------- # - Widgets -------------------------------- class TRTableView(QtGui.QTableWidget): def __init__(self, data): super(TRTableView, self).__init__() # - Init self.setColumnCount(max(map(len, data.values()))) self.setRowCount(len(data.keys())) # - Set
def __init__(self): super(TRDropGuide, self).__init__() # -- Editing fields self.edt_guideName = QtGui.QLineEdit() self.edt_guideName.setPlaceholderText('New Guideline') self.edt_guideTag = TRGLineEdit() self.edt_guideTag.setPlaceholderText('Tag') self.edt_sourceName = QtGui.QLineEdit() self.edt_sourceName.setPlaceholderText('Source name / Current') self.edt_sourceName.setToolTip( 'Source glyph name, or Active Glyph if Blank') # -- Combo box self.cmb_select_V = QtGui.QComboBox() self.cmb_select_H = QtGui.QComboBox() self.cmb_select_color = QtGui.QComboBox() self.cmb_select_V.addItems(['BBox width', 'Adv. width']) self.cmb_select_H.addItems([ 'BBox height', 'X-Height', 'Caps Height', 'Ascender', 'Descender', 'Adv. height' ]) colorNames = QtGui.QColor.colorNames() for i in range(len(colorNames)): self.cmb_select_color.addItem(colorNames[i]) self.cmb_select_color.setItemData(i, QtGui.QColor(colorNames[i]), QtCore.Qt.DecorationRole) self.cmb_select_color.setCurrentIndex(colorNames.index('red')) self.cmb_select_color.setMinimumWidth(40) self.edt_guideName.setMinimumWidth(40) self.edt_guideTag.setMinimumWidth(40) # -- SpinBox self.spb_prc_V = QtGui.QSpinBox() self.spb_prc_V.setMaximum(300) self.spb_prc_V.setSuffix('%') self.spb_prc_V.setMinimumWidth(45) self.spb_prc_H = QtGui.QSpinBox() self.spb_prc_H.setMaximum(300) self.spb_prc_H.setSuffix('%') self.spb_prc_H.setMinimumWidth(45) self.spb_unit_V = QtGui.QSpinBox() self.spb_unit_V.setMaximum(300) self.spb_unit_V.setMinimum(-300) self.spb_unit_V.setSuffix(' U') self.spb_unit_V.setMinimumWidth(45) self.spb_unit_H = QtGui.QSpinBox() self.spb_unit_H.setMaximum(300) self.spb_unit_H.setMinimum(-300) self.spb_unit_H.setSuffix(' U') self.spb_unit_H.setMinimumWidth(45) # -- Button self.btn_dropGuide = QtGui.QPushButton('&Drop') self.btn_dropFlipX = QtGui.QPushButton('Drop: Flip &X') self.btn_dropFlipY = QtGui.QPushButton('Drop: Flip &Y') self.btn_dropLayer_V = QtGui.QPushButton('Vertical') self.btn_dropLayer_H = QtGui.QPushButton('Horizontal') self.btn_getName = QtGui.QPushButton('Get &Name') self.btn_dropGuide.setToolTip( 'Drop guideline between any two selected nodes.\nIf single node is selected a vertical guide is\ndropped (using the italic angle if present).' ) self.btn_dropFlipX.setToolTip( 'Drop flipped guideline between any two selected nodes.') self.btn_dropFlipY.setToolTip( 'Drop flipped guideline between any two selected nodes.') self.btn_getName.setToolTip('Get the name of the current active glyph') self.btn_dropGuide.clicked.connect(lambda: self.drop_guide_nodes( (1, 1))) self.btn_dropFlipX.clicked.connect(lambda: self.drop_guide_nodes( (-1, 1))) self.btn_dropFlipY.clicked.connect(lambda: self.drop_guide_nodes( (1, -1))) self.btn_getName.clicked.connect( lambda: self.edt_sourceName.setText(pGlyph().name)) self.btn_dropLayer_V.clicked.connect(self.drop_guide_V) self.btn_dropLayer_H.clicked.connect(self.drop_guide_H) # - Build self.addWidget(QtGui.QLabel('Name:'), 1, 0, 1, 4) self.addWidget(QtGui.QLabel('Tag:'), 1, 4, 1, 4) self.addWidget(QtGui.QLabel('Color:'), 1, 8, 1, 4) self.addWidget(self.edt_guideName, 2, 0, 1, 4) self.addWidget(self.cmb_select_color, 2, 8, 1, 4) self.addWidget(self.edt_guideTag, 2, 4, 1, 4) self.addWidget(QtGui.QLabel('Selected Nodes:'), 3, 0, 1, 9) self.addWidget(self.btn_dropGuide, 4, 0, 1, 4) self.addWidget(self.btn_dropFlipX, 4, 4, 1, 4) self.addWidget(self.btn_dropFlipY, 4, 8, 1, 4) self.addWidget(QtGui.QLabel('Glyph Layer:'), 5, 0, 1, 4) self.addWidget(self.edt_sourceName, 6, 0, 1, 8) self.addWidget(self.btn_getName, 6, 8, 1, 4) self.addWidget(self.cmb_select_V, 7, 0, 1, 4) self.addWidget(self.spb_prc_V, 7, 4, 1, 2) self.addWidget(self.spb_unit_V, 7, 6, 1, 2) self.addWidget(self.btn_dropLayer_V, 7, 8, 1, 4) self.addWidget(self.cmb_select_H, 8, 0, 1, 4) self.addWidget(self.spb_prc_H, 8, 4, 1, 2) self.addWidget(self.spb_unit_H, 8, 6, 1, 2) self.addWidget(self.btn_dropLayer_H, 8, 8, 1, 4)
def markChange(self, item): item.setBackground(QtGui.QColor('powderblue'))
# - Init -------------------------- app_version = '0.10' app_name = 'TypeRig Kern' ignorePanel = '__' # -- Global parameters pMode = 0 pLayers = (True, False, False, False) # -- Inital config for Get Layers dialog column_names = ('Layer Name', 'Layer Type') column_init = (None, None) table_dict = {1: OrderedDict(zip(column_names, column_init))} color_dict = { 'Master': QtGui.QColor(0, 255, 0, 20), 'Service': QtGui.QColor(0, 0, 255, 20), 'Mask': QtGui.QColor(255, 0, 0, 20) } # - Style ------------------------- ss_Toolbox_none = """/* EMPTY STYLESHEET */ """ # - Interface ----------------------------- # - Widgets -------------------------------- class TRTableView(QtGui.QTableWidget): def __init__(self, data): super(TRTableView, self).__init__() # - Init
from typerig.core.func.math import linInterp as lerp from PythonQt import QtCore from typerig.gui import QtGui from typerig.gui.widgets import getProcessGlyphs, TRSliderCtrl # - Init global pLayers global pMode pLayers = None pMode = 0 app_name, app_version = 'TypeRig | Layers', '1.28' # -- Inital config for Get Layers dialog column_names = ('Name', 'Type', 'Color') column_init = (None, None, QtGui.QColor(0, 255, 0, 10)) init_table_dict = {1: OrderedDict(zip(column_names, column_init))} color_dict = { 'Master': QtGui.QColor(0, 255, 0, 10), 'Service': QtGui.QColor(0, 0, 255, 10), 'Mask': QtGui.QColor(255, 0, 0, 10) } # - Sub widgets ------------------------ class TRWLayerSelect(QtGui.QVBoxLayout): # - Split/Break contour def __init__(self): super(TRWLayerSelect, self).__init__() # - Init
def markChange(self, item): item.setText(3, ('B: %s', 'T: %s')[float(item.text(2)) > 0] % item.text(1)) for col in range(item.columnCount()): item.setBackground(col, QtGui.QColor('powderblue'))