def __init__(self, parentWidget): super(WFontMetrics, self).__init__() # - Init self.grid = QtGui.QGridLayout() self.upperWidget = parentWidget self.activeFont = pFont() self.metricData = {layer:self.activeFont.fontMetrics().asDict(layer) for layer in self.activeFont.masters()} # - Interface self.btn_apply = QtGui.QPushButton('Apply Changes') self.btn_reset = QtGui.QPushButton('Reset') self.btn_open = QtGui.QPushButton('Open') self.btn_save = QtGui.QPushButton('Save') self.btn_apply.clicked.connect(self.applyChanges) self.btn_reset.clicked.connect(self.resetChanges) self.btn_save.clicked.connect(self.exportMetrics) self.btn_open.clicked.connect(self.importMetrics) self.tab_fontMetrics = trTableView(self.metricData) # - Build lbl_name = QtGui.QLabel('Font Metrics (All Masters)') lbl_name.setMaximumHeight(20) self.grid.addWidget(lbl_name, 0, 0, 1, 24) self.grid.addWidget(self.tab_fontMetrics, 1, 0, 5, 21) self.grid.addWidget(self.btn_save, 1, 21, 1, 3) self.grid.addWidget(self.btn_open, 2, 21, 1, 3) self.grid.addWidget(self.btn_reset, 4, 21, 1, 3) self.grid.addWidget(self.btn_apply, 5, 21, 1, 3) for i in range(1,6): self.grid.setRowStretch(i,2) self.setLayout(self.grid)
def __init__(self, aux): super(QanchorBasic, self).__init__() # - Init self.aux = aux self.types = 'Anchor PinPoint'.split(' ') self.posY = 'Coord,Above,Below,Center,Baseline,Copy'.split(',') self.posX = 'Coord,Left,Right,Center,Highest,Lowest'.split(',') posYvals = (None, 'T', 'B', 'C', None) posXvals = (None, 'L', 'R', 'C', 'AT', 'A') self.posYctrl = dict(zip(self.posY, posYvals)) self.posXctrl = dict(zip(self.posX, posXvals)) # -- Basic Tool buttons self.lay_grid = QtGui.QGridLayout() self.btn_clearSel = QtGui.QPushButton('Clear Selected') self.btn_clearAll = QtGui.QPushButton('Clear All') self.btn_anchorAdd = QtGui.QPushButton('Add') self.btn_anchorMov = QtGui.QPushButton('Move') self.chk_italic = QtGui.QCheckBox('Use Italic Angle') # -- Edit fields self.edt_anchorName = ALineEdit() self.edt_simpleX = QtGui.QLineEdit() self.edt_simpleY = QtGui.QLineEdit() self.edt_autoT = QtGui.QLineEdit() self.edt_anchorName.setPlaceholderText('New Anchor') self.edt_simpleX.setText('0') self.edt_simpleY.setText('0') self.edt_autoT.setText('5') # -- Combo box self.cmb_posX = QtGui.QComboBox() self.cmb_posY = QtGui.QComboBox() self.cmb_type = QtGui.QComboBox() self.cmb_posX.addItems(self.posX) self.cmb_posY.addItems(self.posY) self.cmb_type.addItems(self.types) self.cmb_type.setEnabled(False) # -- Constrains self.btn_clearSel.setMinimumWidth(90) self.btn_clearAll.setMinimumWidth(90) self.edt_anchorName.setMinimumWidth(50) self.edt_simpleX.setMinimumWidth(30) self.edt_simpleY.setMinimumWidth(30) # -- Link functions self.btn_clearAll.clicked.connect(lambda: self.clearAnchors(True)) self.btn_clearSel.clicked.connect(lambda: self.clearAnchors(False)) self.btn_anchorAdd.clicked.connect(lambda: self.addAnchors(False)) self.btn_anchorMov.clicked.connect(lambda: self.addAnchors(True)) # - Build layout self.lay_grid.addWidget(QtGui.QLabel('Remove anchor:'), 0, 0, 1, 4) self.lay_grid.addWidget(self.btn_clearSel, 1, 0, 1, 4) self.lay_grid.addWidget(self.btn_clearAll, 1, 4, 1, 4) self.lay_grid.addWidget(QtGui.QLabel('Add/move anchor:'), 2, 0, 1, 4) self.lay_grid.addWidget(QtGui.QLabel('N:'), 3, 0, 1, 1) self.lay_grid.addWidget(self.edt_anchorName, 3, 1, 1, 3) self.lay_grid.addWidget(self.cmb_type, 3, 4, 1, 4) self.lay_grid.addWidget(QtGui.QLabel('X:'), 4, 0, 1, 1) self.lay_grid.addWidget(self.cmb_posX, 4, 1, 1, 2) self.lay_grid.addWidget(self.edt_simpleX, 4, 3, 1, 1) self.lay_grid.addWidget(QtGui.QLabel('Tolerance:'), 4, 4, 1, 1) self.lay_grid.addWidget(self.edt_autoT, 4, 5, 1, 3) self.lay_grid.addWidget(QtGui.QLabel('Y:'), 5, 0, 1, 1) self.lay_grid.addWidget(self.cmb_posY, 5, 1, 1, 2) self.lay_grid.addWidget(self.edt_simpleY, 5, 3, 1, 1) self.lay_grid.addWidget(self.chk_italic, 5, 4, 1, 4) self.lay_grid.addWidget(self.btn_anchorAdd, 6, 0, 1, 4) self.lay_grid.addWidget(self.btn_anchorMov, 6, 4, 1, 4) # - Build self.addLayout(self.lay_grid)
def __init__(self): super(typerig_filter, self).__init__() #self.setStyleSheet(ss_Toolbox_none) # - Layers -------------------------- self.chk_ActiveLayer = QtGui.QCheckBox('Active') self.chk_Masters = QtGui.QCheckBox('Masters') self.chk_Masks = QtGui.QCheckBox('Masks') self.chk_Service = QtGui.QCheckBox('Services') self.chk_ActiveLayer.setCheckState(QtCore.Qt.Checked) #self.chk_ActiveLayer.setStyleSheet('QCheckBox::indicator:checked {background-color: limegreen; border: 1px Solid limegreen;}') self.chk_ActiveLayer.stateChanged.connect(self.refreshLayers) self.chk_Masters.stateChanged.connect(self.refreshLayers) self.chk_Masks.stateChanged.connect(self.refreshLayers) self.chk_Service.stateChanged.connect(self.refreshLayers) self.refreshLayers() # - Glyphs -------------------------- self.rad_glyph = QtGui.QRadioButton('Glyph') self.rad_window = QtGui.QRadioButton('Window') self.rad_selection = QtGui.QRadioButton('Selection') self.rad_font = QtGui.QRadioButton('Font') self.rad_glyph.toggled.connect(self.refreshMode) self.rad_window.toggled.connect(self.refreshMode) self.rad_selection.toggled.connect(self.refreshMode) self.rad_font.toggled.connect(self.refreshMode) self.rad_glyph.setChecked(True) self.rad_glyph.setEnabled(True) self.rad_window.setEnabled(True) self.rad_selection.setEnabled(True) self.rad_font.setEnabled(False) self.rad_glyph.setToolTip('Affect current glyph') self.rad_window.setToolTip('Affect glyphs in active window') self.rad_selection.setToolTip('Affect selected glyphs') self.rad_font.setToolTip('Affect the entire font') # - Fold Button --------------------- self.btn_fold = QtGui.QPushButton('^') self.btn_unfold = QtGui.QPushButton('Restore Panel') self.btn_fold.setFixedHeight(self.chk_ActiveLayer.sizeHint.height() * 2.5) self.btn_fold.setFixedWidth(self.chk_ActiveLayer.sizeHint.height()) self.btn_unfold.setFixedHeight(self.chk_ActiveLayer.sizeHint.height() + 5) self.btn_fold.setToolTip('Fold Panel') self.btn_unfold.setToolTip('Unfold Panel') self.btn_fold.clicked.connect(self.fold) self.btn_unfold.clicked.connect(self.fold) self.flag_fold = False # - Tabs -------------------------- # -- Dynamically load all tabs self.tabs = QtGui.QTabWidget() self.tabs.setTabPosition(QtGui.QTabWidget.East) # --- Load all tabs from this directory as modules. Check __init__.py # --- <dirName>.modules tabs/modules manifest in list format for toolName in Panel.modules: if ignorePanel not in toolName: self.tabs.addTab(eval('Panel.%s.tool_tab()' % toolName), toolName) # - Layouts ------------------------------- layoutV = QtGui.QVBoxLayout() layoutV.setContentsMargins(0, 0, 0, 0) self.lay_controller = QtGui.QGridLayout() self.fr_controller = QtGui.QFrame() self.lay_controller.setContentsMargins(15, 5, 5, 3) # -- Build layouts ------------------------------- self.lay_controller.addWidget(self.chk_ActiveLayer, 0, 0, 1, 1) self.lay_controller.addWidget(self.chk_Masters, 0, 1, 1, 1) self.lay_controller.addWidget(self.chk_Masks, 0, 2, 1, 1) self.lay_controller.addWidget(self.chk_Service, 0, 3, 1, 1) self.lay_controller.addWidget(self.btn_fold, 0, 4, 2, 1) self.lay_controller.addWidget(self.rad_glyph, 1, 0, 1, 1) self.lay_controller.addWidget(self.rad_window, 1, 1, 1, 1) self.lay_controller.addWidget(self.rad_selection, 1, 2, 1, 1) self.lay_controller.addWidget(self.rad_font, 1, 3, 1, 1) layoutV.addWidget(self.btn_unfold) self.fr_controller.setLayout(self.lay_controller) layoutV.addWidget(self.fr_controller) layoutV.addWidget(self.tabs) self.btn_unfold.hide() # - Set Widget ------------------------------- self.setLayout(layoutV) self.setWindowTitle('%s %s' % (app_name, app_version)) self.setGeometry(300, 300, 240, 440) self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) # Always on top!! #self.setMinimumWidth(300) self.show()
def __init__(self): super(tool_tab, self).__init__() # - Init layoutV = QtGui.QVBoxLayout() layoutH = QtGui.QHBoxLayout() # - Build panel if sysReady: self.head = mixerHead() self.tail = mixerTail() self.head.btn_refresh.clicked.connect(self.refresh) self.head.btn_set_axis.clicked.connect(self.set_axis) self.head.btn_getVstem.clicked.connect(self.get_v_stems) self.head.btn_getHstem.clicked.connect(self.get_h_stems) layoutV.addLayout(self.head) layoutV.addSpacing(15) # -- Set Sliders # --- Mixer layoutV.addWidget(QtGui.QLabel('Interpolate: X (Vertical Stems)')) self.mixer_dx = trSliderCtrl('1', '1000', '0', 10) self.mixer_dx.sld_axis.valueChanged.connect( lambda: self.process_scale(self.head.chk_single.isChecked(), self.head.chk_preview.isChecked())) layoutV.addLayout(self.mixer_dx) layoutV.addWidget( QtGui.QLabel('Interpolate: Y (Horizontal Stems)')) self.mixer_dy = trSliderCtrl('1', '1000', '0', 10) self.mixer_dy.sld_axis.valueChanged.connect( lambda: self.process_scale(self.head.chk_single.isChecked(), self.head.chk_preview.isChecked())) layoutV.addLayout(self.mixer_dy) # - Constant width Button #self.btn_revWidth = QtGui.QPushButton('Constant width for weight') #self.btn_revWidth.setCheckable(True) #layoutV.addWidget(self.btn_revWidth) layoutV.addSpacing(15) # --- Scaler layoutV.addWidget(QtGui.QLabel('Compensative scaler: Width')) self.scaler_dx = trSliderCtrl('1', '200', '100', 10) self.scaler_dx.sld_axis.valueChanged.connect( lambda: self.process_scale(self.head.chk_single.isChecked(), self.head.chk_preview.isChecked())) layoutV.addLayout(self.scaler_dx) layoutV.addSpacing(15) layoutV.addWidget(QtGui.QLabel('Compensative scaler: Height')) self.scaler_dy = trSliderCtrl('1', '200', '100', 10) self.scaler_dy.sld_axis.valueChanged.connect( lambda: self.process_scale(self.head.chk_single.isChecked(), self.head.chk_preview.isChecked())) layoutV.addLayout(self.scaler_dy) layoutV.addSpacing(25) layoutV.addLayout(self.tail) # - Process Button self.btn_process = QtGui.QPushButton('Process Transformation') self.btn_process.clicked.connect(lambda: self.process_scale( self.head.chk_single.isChecked(), True, True)) layoutV.addWidget(self.btn_process) # -- Initialize self.refresh() # -- Finish layoutV.addStretch() else: # - Throw an error layoutV.addLayout(trMsgSimple(warnMessage)) # - Set panel self.setLayout(layoutV)
def __init__(self, aux): super(QanchorBasic, self).__init__() # - Init self.aux = aux self.types = 'Anchor PinPoint'.split(' ') self.posY = 'Exact,Shift,Above,Below,Center,Baseline'.split(',') self.posX = 'Exact,Shift,Left,Right,Center,Highest,Highest Left,Highest Right,Lowest,Lowest Left,Lowest Right'.split( ',') posYvals = (None, 'S', 'T', 'B', 'C', None) posXvals = (None, 'S', 'L', 'R', 'C', 'AT', 'ATL', 'ATR', 'A', 'AL', 'AR') self.posYctrl = dict(zip(self.posY, posYvals)) self.posXctrl = dict(zip(self.posX, posXvals)) # -- Basic Tool buttons self.lay_grid = QtGui.QGridLayout() self.btn_anchorCopy = QtGui.QPushButton('Copy') self.btn_anchorPaste = QtGui.QPushButton('Paste') self.btn_clearSel = QtGui.QPushButton('Clear Selected') self.btn_clearAll = QtGui.QPushButton('Clear All') self.btn_anchorAdd = QtGui.QPushButton('Add') self.btn_anchorMov = QtGui.QPushButton('Move') self.chk_italic = QtGui.QCheckBox('Use Italic Angle') # -- Edit fields self.edt_anchorName = ALineEdit() self.edt_simpleX = QtGui.QLineEdit() self.edt_simpleY = QtGui.QLineEdit() self.edt_autoT = QtGui.QLineEdit() self.edt_simpleX.setToolTip( 'Layer Order: ' + ', '.join(self.aux.wLayers)) # helper for layer order self.edt_simpleY.setToolTip( 'Layer Order: ' + ', '.join(self.aux.wLayers)) # helper for layer order self.btn_anchorCopy.setToolTip( 'Copy selected Anchors from layers choosen.') self.btn_anchorPaste.setToolTip('Paste Anchors at layers choosen.') self.edt_anchorName.setPlaceholderText('New Anchor') self.edt_simpleX.setText('0') self.edt_simpleY.setText('0') self.edt_autoT.setText('5') # -- Combo box self.cmb_posX = QtGui.QComboBox() self.cmb_posY = QtGui.QComboBox() self.cmb_type = QtGui.QComboBox() self.cmb_posX.addItems(self.posX) self.cmb_posY.addItems(self.posY) self.cmb_type.addItems(self.types) self.cmb_type.setEnabled(False) # -- Constrains self.btn_clearSel.setMinimumWidth(90) self.btn_clearAll.setMinimumWidth(90) self.edt_anchorName.setMinimumWidth(50) self.edt_simpleX.setMinimumWidth(30) self.edt_simpleY.setMinimumWidth(30) # -- Link functions self.btn_clearAll.clicked.connect(lambda: self.clearAnchors(True)) self.btn_clearSel.clicked.connect(lambda: self.clearAnchors(False)) self.btn_anchorAdd.clicked.connect(lambda: self.addAnchors(False)) self.btn_anchorMov.clicked.connect(lambda: self.addAnchors(True)) self.btn_anchorCopy.clicked.connect(lambda: self.copyAnchors(False)) self.btn_anchorPaste.clicked.connect(lambda: self.copyAnchors(True)) # - Build layout self.lay_grid.addWidget(QtGui.QLabel('Anchor actions:'), 0, 0, 1, 4) self.lay_grid.addWidget(self.btn_anchorCopy, 1, 0, 1, 4) self.lay_grid.addWidget(self.btn_anchorPaste, 1, 4, 1, 4) self.lay_grid.addWidget(self.btn_clearSel, 2, 0, 1, 4) self.lay_grid.addWidget(self.btn_clearAll, 2, 4, 1, 4) self.lay_grid.addWidget(QtGui.QLabel('Add/move anchor:'), 3, 0, 1, 4) self.lay_grid.addWidget(QtGui.QLabel('N:'), 4, 0, 1, 1) self.lay_grid.addWidget(self.edt_anchorName, 4, 1, 1, 3) self.lay_grid.addWidget(self.cmb_type, 4, 4, 1, 4) self.lay_grid.addWidget(QtGui.QLabel('X:'), 5, 0, 1, 1) self.lay_grid.addWidget(self.cmb_posX, 5, 1, 1, 3) self.lay_grid.addWidget(self.edt_simpleX, 5, 4, 1, 4) self.lay_grid.addWidget(QtGui.QLabel('Y:'), 6, 0, 1, 1) self.lay_grid.addWidget(self.cmb_posY, 6, 1, 1, 3) self.lay_grid.addWidget(self.edt_simpleY, 6, 4, 1, 4) self.lay_grid.addWidget(QtGui.QLabel('Tolerance:'), 7, 1, 1, 2) self.lay_grid.addWidget(self.edt_autoT, 7, 3, 1, 1) self.lay_grid.addWidget(self.chk_italic, 7, 4, 1, 1) self.lay_grid.addWidget(self.btn_anchorAdd, 8, 0, 1, 4) self.lay_grid.addWidget(self.btn_anchorMov, 8, 4, 1, 4) # - Build self.addLayout(self.lay_grid)
def markChange(self, item): item.setBackground(QtGui.QColor('powderblue'))
def __init__(self): super(dlg_DeltaMachine, self).__init__() # - Init #self.setStyleSheet(ss_controls) self.pMode = 0 self.active_font = pFont() #self.data_glyphs = getProcessGlyphs(self.pMode) self.data_coordArrays = {} self.data_stems = {} self.ratio_source = {} self.ratio_target = {} # - Basic Widgets # -- Master table self.tab_masters = WTableView(table_dict) self.table_populate() self.tab_masters.selectionModel().selectionChanged.connect( self.set_sliders) # -- Combos self.cmb_infoArrays = QtGui.QComboBox() # -- Buttons self.btn_execute = QtGui.QPushButton('Execute transformation') self.btn_tableRefresh = QtGui.QPushButton('Reset') self.btn_tableSave = QtGui.QPushButton('Save') self.btn_tableLoad = QtGui.QPushButton('Load') self.btn_getVstems = QtGui.QPushButton('Get V-stems') self.btn_getHstems = QtGui.QPushButton('Get H-stems') self.btn_tableCheck = QtGui.QPushButton('Check All') self.btn_resetT = QtGui.QPushButton('Reset dX dY') self.btn_getTx = QtGui.QPushButton('Get V[dX]') self.btn_getTy = QtGui.QPushButton('Get H[dY]') self.btn_getArrays = QtGui.QPushButton('Get Master Sources') self.btn_getPart = QtGui.QPushButton('Get Part') self.btn_getWhole = QtGui.QPushButton('Get Whole') self.btn_pushWidthPW = QtGui.QPushButton('Eval Width') self.btn_pushHeightPW = QtGui.QPushButton('Eval Height') self.btn_pushWidth = QtGui.QPushButton('Set Width Ratio') self.btn_pushHeight = QtGui.QPushButton('Set Height Ratio') self.btn_tableCheck.clicked.connect(self.table_check_all) self.btn_tableRefresh.clicked.connect(self.table_populate) self.btn_tableSave.clicked.connect(self.file_save_deltas) self.btn_tableLoad.clicked.connect(self.file_load_deltas) self.btn_execute.clicked.connect(self.table_execute) self.btn_getPart.clicked.connect(lambda: self.get_ratio(True)) self.btn_getWhole.clicked.connect(lambda: self.get_ratio(False)) self.btn_pushWidthPW.clicked.connect( lambda: self.push_ratio(False, True)) self.btn_pushHeightPW.clicked.connect( lambda: self.push_ratio(True, True)) self.btn_pushWidth.clicked.connect( lambda: self.push_ratio(False, False)) self.btn_pushHeight.clicked.connect( lambda: self.push_ratio(True, False)) self.btn_getArrays.clicked.connect(self.get_coordArrays) self.btn_getVstems.clicked.connect(lambda: self.get_Stems(True)) self.btn_getHstems.clicked.connect(lambda: self.get_Stems(False)) self.btn_getTx.clicked.connect(lambda: self.get_Stems(True, False)) self.btn_getTy.clicked.connect(lambda: self.get_Stems(False, False)) # -- Check buttons self.chk_italic = QtGui.QPushButton('Italic') self.chk_single = QtGui.QPushButton('Anisotropic') self.chk_preview = QtGui.QPushButton('Live Preview') self.chk_boundry = QtGui.QPushButton('Fix Boundry') self.chk_single.setToolTip( 'Active: Use X and Y to control interpolation.') self.chk_single.setCheckable(True) self.chk_italic.setCheckable(True) self.chk_preview.setCheckable(True) self.chk_boundry.setCheckable(True) self.chk_single.setChecked(False) self.chk_italic.setChecked(False) self.chk_preview.setChecked(False) self.chk_boundry.setChecked(True) # -- Radio self.rad_glyph = QtGui.QRadioButton('Glyph') self.rad_window = QtGui.QRadioButton('Window') self.rad_selection = QtGui.QRadioButton('Selection') self.rad_font = QtGui.QRadioButton('Font') self.rad_glyph.setChecked(True) self.rad_glyph.setEnabled(True) self.rad_window.setEnabled(False) self.rad_selection.setEnabled(False) self.rad_font.setEnabled(False) self.rad_glyph.toggled.connect(self.table_refresh) self.rad_window.toggled.connect(self.table_refresh) self.rad_selection.toggled.connect(self.table_refresh) self.rad_font.toggled.connect(self.table_refresh) # -- Sliders self.mixer_dx = trSliderCtrl('1', '1000', '0', 1) self.mixer_dy = trSliderCtrl('1', '1000', '0', 1) self.scaler_dx = trSliderCtrl('1', '200', '100', 1) self.scaler_dy = trSliderCtrl('1', '200', '100', 1) self.mixer_dx.sld_axis.valueChanged.connect(lambda: self.process_scale( eGlyph(), anisotropic=self.chk_single.isChecked(), live_update=self.chk_preview.isChecked())) self.mixer_dy.sld_axis.valueChanged.connect(lambda: self.process_scale( eGlyph(), anisotropic=self.chk_single.isChecked(), live_update=self.chk_preview.isChecked())) self.scaler_dx.sld_axis.valueChanged.connect( lambda: self.process_scale(eGlyph(), anisotropic=self.chk_single.isChecked(), live_update=self.chk_preview.isChecked( ))) self.scaler_dy.sld_axis.valueChanged.connect( lambda: self.process_scale(eGlyph(), anisotropic=self.chk_single.isChecked(), live_update=self.chk_preview.isChecked( ))) # - Build layout layoutV = QtGui.QGridLayout() layoutV.addWidget(QtGui.QLabel('Preferences:'), 0, 0, 1, 1) layoutV.addWidget(self.btn_tableCheck, 0, 1, 1, 2) layoutV.addWidget(self.btn_tableSave, 0, 3, 1, 1) layoutV.addWidget(self.btn_tableLoad, 0, 4, 1, 4) layoutV.addWidget(self.btn_tableRefresh, 0, 8, 1, 1) layoutV.addWidget(QtGui.QLabel('Source:'), 0, 10, 1, 1, QtCore.Qt.AlignRight) layoutV.addWidget(self.btn_getVstems, 0, 11, 1, 2) layoutV.addWidget(self.btn_getHstems, 0, 13, 1, 2) layoutV.addWidget(QtGui.QLabel('Ratio BBOX:'), 0, 15, 1, 1, QtCore.Qt.AlignRight) layoutV.addWidget(self.btn_getPart, 0, 16, 1, 1) layoutV.addWidget(self.btn_getWhole, 0, 17, 1, 1) layoutV.addWidget(self.btn_pushWidthPW, 0, 18, 1, 1) layoutV.addWidget(self.btn_pushHeightPW, 0, 19, 1, 1) layoutV.addWidget(QtGui.QLabel('Master data:'), 1, 0, 1, 1) layoutV.addWidget(self.cmb_infoArrays, 1, 1, 1, 2) layoutV.addWidget(self.btn_getArrays, 1, 3, 1, 6) layoutV.addWidget(QtGui.QLabel('Target:'), 1, 10, 1, 1, QtCore.Qt.AlignRight) layoutV.addWidget(self.btn_getTx, 1, 11, 1, 2) layoutV.addWidget(self.btn_getTy, 1, 13, 1, 2) layoutV.addWidget(QtGui.QLabel('Populate:'), 1, 15, 1, 1, QtCore.Qt.AlignRight) layoutV.addWidget(self.btn_pushWidth, 1, 16, 1, 2) layoutV.addWidget(self.btn_pushHeight, 1, 18, 1, 2) layoutV.addWidget(self.tab_masters, 2, 0, 15, 20) layoutV.addWidget(QtGui.QLabel('LERP [dX]:'), 23, 0, 1, 1, QtCore.Qt.AlignTop) layoutV.addLayout(self.mixer_dx, 23, 1, 1, 4) layoutV.addWidget(QtGui.QLabel('[dY]:'), 23, 5, 1, 1, QtCore.Qt.AlignTop | QtCore.Qt.AlignRight) layoutV.addLayout(self.mixer_dy, 23, 6, 1, 4) layoutV.addWidget(QtGui.QLabel('Width:'), 23, 10, 1, 1, QtCore.Qt.AlignTop | QtCore.Qt.AlignRight) layoutV.addLayout(self.scaler_dx, 23, 11, 1, 4) layoutV.addWidget(QtGui.QLabel('Height:'), 23, 15, 1, 1, QtCore.Qt.AlignTop | QtCore.Qt.AlignRight) layoutV.addLayout(self.scaler_dy, 23, 16, 1, 4) layoutV.addWidget(QtGui.QLabel('Process:'), 25, 0, 1, 1) layoutV.addWidget(self.rad_glyph, 25, 1, 1, 1) layoutV.addWidget(self.rad_window, 25, 2, 1, 1) layoutV.addWidget(self.rad_selection, 25, 3, 1, 1) layoutV.addWidget(self.rad_font, 25, 4, 1, 1) layoutV.addWidget(QtGui.QLabel('Mode:'), 25, 5, 1, 1) layoutV.addWidget(self.chk_single, 25, 6, 1, 2) layoutV.addWidget(self.chk_italic, 25, 8, 1, 2) layoutV.addWidget(self.chk_boundry, 25, 10, 1, 2) layoutV.addWidget(self.chk_preview, 25, 12, 1, 3) layoutV.addWidget(self.btn_execute, 25, 15, 1, 5) # - Set Widget self.setLayout(layoutV) self.setWindowTitle('%s %s' % (app_name, app_version)) self.setGeometry(300, 300, 1150, 700) self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) # Always on top!! self.show()
def __init__(self, parentWidget): super(WFontZones, self).__init__() # - Init self.grid = QtGui.QGridLayout() self.upperWidget = parentWidget self.activeFont = pFont() self.zoneData = {master:self.activeFont.zonesToTuples(master) for master in self.activeFont.masters()} # - Interface self.btn_apply = QtGui.QPushButton('Apply Changes') self.btn_reset = QtGui.QPushButton('Reset') self.btn_open = QtGui.QPushButton('Open') self.btn_save = QtGui.QPushButton('Save') self.btn_new = QtGui.QPushButton('Add New') self.btn_del = QtGui.QPushButton('Delete') self.cmb_layer = QtGui.QComboBox() self.cmb_layer.addItems(['All Layers'] + self.activeFont.masters()) self.edt_pos = ZLineEdit() self.edt_width = QtGui.QLineEdit() self.edt_pos.setPlaceholderText('Position') self.edt_width.setPlaceholderText('Width') self.btn_apply.clicked.connect(self.applyChanges) self.btn_reset.clicked.connect(self.resetChanges) self.btn_save.clicked.connect(self.exportZones) self.btn_open.clicked.connect(self.importZones) self.btn_new.clicked.connect(self.addZone) self.btn_del.clicked.connect(self.delZone) self.tree_fontZones = WTreeWidget(self.zoneData) # - Build lbl_name = QtGui.QLabel('Font Zones (Local)') lbl_name.setMaximumHeight(20) self.grid.addWidget(lbl_name, 0, 0, 1, 24) self.grid.addWidget(self.tree_fontZones,1, 0, 6, 18) self.grid.addWidget(self.cmb_layer, 1, 18, 1, 3) self.grid.addWidget(self.edt_pos, 2, 18, 1, 3) self.grid.addWidget(self.edt_width, 3, 18, 1, 3) self.grid.addWidget(self.btn_new, 4, 18, 1, 3) self.grid.addWidget(self.btn_del, 5, 18, 1, 3) self.grid.addWidget(self.btn_save, 1, 21, 1, 3) self.grid.addWidget(self.btn_open, 2, 21, 1, 3) self.grid.addWidget(self.btn_reset, 4, 21, 1, 3) self.grid.addWidget(self.btn_apply, 5, 21, 1, 3) ''' self.grid.setRowStretch(0,0) for i in range(1,6): self.grid.setRowStretch(i,6) self.grid.setColumnStretch(0,18) self.grid.setColumnStretch(18,3) self.grid.setColumnStretch(21,3) ''' self.setLayout(self.grid)
def __init__(self): super(basicOps, self).__init__() # - Basic operations self.btn_insert = QtGui.QPushButton('&Insert') self.btn_remove = QtGui.QPushButton('&Remove') self.btn_mitre = QtGui.QPushButton('&Mitre') self.btn_knot = QtGui.QPushButton('&Overlap') self.btn_trapA = QtGui.QPushButton('&Trap') self.btn_rebuild = QtGui.QPushButton('Rebuil&d') self.btn_insert.setMinimumWidth(80) self.btn_remove.setMinimumWidth(80) self.btn_mitre.setMinimumWidth(80) self.btn_knot.setMinimumWidth(80) self.btn_trapA.setMinimumWidth(80) self.btn_rebuild.setMinimumWidth(80) self.btn_insert.setToolTip('Insert Node after Selection\nat given time T.') self.btn_remove.setToolTip('Remove Selected Nodes!\nFor proper curve node deletion\nalso select the associated handles!') self.btn_mitre.setToolTip('Mitre corner using size X.') self.btn_knot.setToolTip('Overlap corner using radius -X.') self.btn_trapA.setToolTip('Insert Angular (generic) Ink Trap at node selected') self.btn_rebuild.setToolTip('Rebuild corner from nodes selected.') self.btn_insert.clicked.connect(self.insertNode) self.btn_remove.clicked.connect(self.removeNode) self.btn_mitre.clicked.connect(lambda: self.cornerMitre(False)) self.btn_knot.clicked.connect(lambda: self.cornerMitre(True)) self.btn_trapA.clicked.connect(lambda: self.cornerTrap()) self.btn_rebuild.clicked.connect(lambda: self.cornerRebuild()) # - Edit fields self.edt_time = QtGui.QLineEdit('0.5') self.edt_radius = QtGui.QLineEdit('5') self.edt_trap = QtGui.QLineEdit('5, 30, 2') self.edt_time.setToolTip('Insertion Time.') self.edt_radius.setToolTip('Mitre size/Overlap or Round Radius.') self.edt_trap.setToolTip('Ink trap: Incision into glyphs flesh, Side depth, Trap size') # -- Build: Basic Ops self.addWidget(self.btn_insert, 0, 0) self.addWidget(QtGui.QLabel('T:'), 0, 1) self.addWidget(self.edt_time, 0, 2) self.addWidget(self.btn_remove, 0, 3) self.addWidget(self.btn_mitre, 1, 0) self.addWidget(QtGui.QLabel('X:'), 1, 1) self.addWidget(self.edt_radius, 1, 2) self.addWidget(self.btn_knot, 1, 3) self.addWidget(self.btn_trapA, 2, 0) self.addWidget(QtGui.QLabel('P:'), 2, 1) self.addWidget(self.edt_trap, 2, 2) self.addWidget(self.btn_rebuild, 2, 3)
def __init__(self): super(alignNodes, self).__init__() # - Init self.copyLine = {} # - Buttons self.btn_left = QtGui.QPushButton('Left') self.btn_right = QtGui.QPushButton('Right') self.btn_top = QtGui.QPushButton('Top') self.btn_bottom = QtGui.QPushButton('Bottom') self.btn_bboxCenterX = QtGui.QPushButton('Outline Center X') self.btn_bboxCenterY = QtGui.QPushButton('Outline Center Y') self.btn_peerCenterX = QtGui.QPushButton('Neighbors Center X') self.btn_peerCenterY = QtGui.QPushButton('Neighbors Center Y') self.btn_toAscender = QtGui.QPushButton('Asc.') self.btn_toCapsHeight = QtGui.QPushButton('Caps') self.btn_toDescender = QtGui.QPushButton('Desc.') self.btn_toXHeight = QtGui.QPushButton('X Hgt.') self.btn_toBaseline = QtGui.QPushButton('Base') self.btn_toYpos = QtGui.QPushButton('Y Pos') self.btn_toMpos = QtGui.QPushButton('Measure') self.btn_solveY = QtGui.QPushButton('Lineup Min/Max Y') self.btn_solveX = QtGui.QPushButton('Lineup Min/Max X') self.btn_copy = QtGui.QPushButton('Copy Slope') self.btn_italic = QtGui.QPushButton('Italic') self.btn_pasteMinY = QtGui.QPushButton('Min Y') self.btn_pasteMaxY = QtGui.QPushButton('Max Y') self.btn_pasteFMinY = QtGui.QPushButton('Flip Min') self.btn_pasteFMaxY = QtGui.QPushButton('Flip Max') self.btn_copy.setCheckable(True) self.btn_copy.setChecked(False) self.btn_italic.setCheckable(True) self.btn_italic.setChecked(False) self.btn_solveY.setToolTip('Channel Process selected nodes according to Y values') self.btn_solveX.setToolTip('Channel Process selected nodes according to X values') self.btn_copy.setToolTip('Copy slope between lowest and highest of selected nodes.') self.btn_italic.setToolTip('Use Italic Angle as slope.') self.btn_pasteMinY.setToolTip('Apply slope to selected nodes.\nReference at MIN Y value.') self.btn_pasteMaxY.setToolTip('Apply slope to selected nodes.\nReference at MAX Y value.') self.btn_pasteFMinY.setToolTip('Apply X flipped slope to selected nodes.\nReference at MIN Y value.') self.btn_pasteFMaxY.setToolTip('Apply X flipped slope to selected nodes.\nReference at MAX Y value.') self.btn_toAscender.setToolTip('Send selected nodes to Ascender height.') self.btn_toCapsHeight.setToolTip('Send selected nodes to Caps Height.') self.btn_toDescender.setToolTip('Send selected nodes to Descender height.') self.btn_toXHeight.setToolTip('Send selected nodes to X Height.') self.btn_toBaseline.setToolTip('Send selected nodes to Baseline.') self.btn_toYpos.setToolTip('Send selected nodes to Y coordinate.') self.btn_toMpos.setToolTip('Send selected nodes to Measurment Line.\nSHIFT + Click switch intercept.') self.btn_alignLayer_V = QtGui.QPushButton('Vertical') self.btn_alignLayer_H = QtGui.QPushButton('Horizontal') # - Combo boxes self.cmb_select_V = QtGui.QComboBox() self.cmb_select_H = 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']) # - Spin Boxes self.edt_toYpos = QtGui.QSpinBox() self.edt_toYpos.setToolTip('Destination Y Coordinate') self.edt_toYpos.setMaximum(1500) self.edt_toYpos.setMinimum(-1500) self.spb_prc_V = QtGui.QSpinBox() self.spb_prc_V.setMaximum(100) self.spb_prc_V.setSuffix('%') self.spb_prc_V.setMinimumWidth(40) self.spb_prc_H = QtGui.QSpinBox() self.spb_prc_H.setMaximum(100) self.spb_prc_H.setSuffix('%') self.spb_prc_H.setMinimumWidth(40) self.spb_unit_V = QtGui.QSpinBox() self.spb_unit_V.setMaximum(100) self.spb_unit_V.setMinimum(-100) self.spb_unit_V.setSuffix(' U') self.spb_unit_V.setMinimumWidth(40) self.spb_unit_H = QtGui.QSpinBox() self.spb_unit_H.setMaximum(100) self.spb_unit_H.setMinimum(-100) self.spb_unit_H.setSuffix(' U') self.spb_unit_H.setMinimumWidth(40) # - Properties self.btn_left.setMinimumWidth(40) self.btn_right.setMinimumWidth(40) self.btn_top.setMinimumWidth(40) self.btn_bottom.setMinimumWidth(40) self.btn_pasteFMinY.setMinimumWidth(40) self.btn_pasteFMaxY.setMinimumWidth(40) self.btn_pasteMinY.setMinimumWidth(40) self.btn_pasteMaxY.setMinimumWidth(40) self.btn_toAscender.setMinimumWidth(40) self.btn_toCapsHeight.setMinimumWidth(40) self.btn_toDescender.setMinimumWidth(40) self.btn_toXHeight.setMinimumWidth(40) self.btn_toYpos.setMinimumWidth(40) self.edt_toYpos.setMinimumWidth(20) self.btn_copy.clicked.connect(self.copySlope) self.btn_left.clicked.connect(lambda: self.alignNodes('L')) self.btn_right.clicked.connect(lambda: self.alignNodes('R')) self.btn_top.clicked.connect(lambda: self.alignNodes('T')) self.btn_bottom.clicked.connect(lambda: self.alignNodes('B')) self.btn_solveY.clicked.connect(lambda: self.alignNodes('Y')) self.btn_solveX.clicked.connect(lambda: self.alignNodes('X')) self.btn_pasteMinY.clicked.connect(lambda: self.pasteSlope('MinY')) self.btn_pasteMaxY.clicked.connect(lambda: self.pasteSlope('MaxY')) self.btn_pasteFMinY.clicked.connect(lambda: self.pasteSlope('FLMinY')) self.btn_pasteFMaxY.clicked.connect(lambda: self.pasteSlope('FLMaxY')) self.btn_bboxCenterX.clicked.connect(lambda: self.alignNodes('BBoxCenterX')) self.btn_bboxCenterY.clicked.connect(lambda: self.alignNodes('BBoxCenterY')) self.btn_peerCenterX.clicked.connect(lambda: self.alignNodes('peerCenterX')) self.btn_peerCenterY.clicked.connect(lambda: self.alignNodes('peerCenterY')) self.btn_toAscender.clicked.connect(lambda: self.alignNodes('FontMetrics_0')) self.btn_toCapsHeight.clicked.connect(lambda: self.alignNodes('FontMetrics_1')) self.btn_toDescender.clicked.connect(lambda: self.alignNodes('FontMetrics_2')) self.btn_toXHeight.clicked.connect(lambda: self.alignNodes('FontMetrics_3')) self.btn_toBaseline.clicked.connect(lambda: self.alignNodes('FontMetrics_4')) self.btn_toYpos.clicked.connect(lambda: self.alignNodes('FontMetrics_5')) self.btn_toMpos.clicked.connect(lambda: self.alignNodes('FontMetrics_6')) self.btn_alignLayer_V.clicked.connect(lambda: self.alignNodes('Layer_V')) self.btn_alignLayer_H.clicked.connect(lambda: self.alignNodes('Layer_H')) # - Check box self.chk_slope = QtGui.QPushButton('Intercept') self.chk_slope.setCheckable(True) self.chk_slope.setToolTip('Find intersections of selected font metric\nwith slopes on which selected nodes resign.') # - Build Layout self.addWidget(self.btn_left, 0,0) self.addWidget(self.btn_right, 0,1) self.addWidget(self.btn_top, 0,2) self.addWidget(self.btn_bottom, 0,3) self.addWidget(self.btn_bboxCenterX, 1,0,1,2) self.addWidget(self.btn_bboxCenterY, 1,2,1,2) self.addWidget(self.btn_peerCenterX, 2,0,1,2) self.addWidget(self.btn_peerCenterY, 2,2,1,2) self.addWidget(QtGui.QLabel('Align to Font & Glyph metrics'), 3,0,1,2) self.addWidget(self.btn_toAscender, 4,0,1,1) self.addWidget(self.btn_toCapsHeight, 4,1,1,1) self.addWidget(self.btn_toDescender, 4,2,1,1) self.addWidget(self.btn_toXHeight, 4,3,1,1) self.addWidget(self.btn_toBaseline, 5,0,1,1) self.addWidget(self.edt_toYpos, 5,1,1,1) self.addWidget(self.btn_toYpos, 5,2,1,1) self.addWidget(self.btn_toMpos, 5,3,1,1) self.addWidget(self.chk_slope, 6,0,1,4) #self.addWidget(QtGui.QLabel('Align to Glyph Layer'), 6, 0, 1, 4) self.addWidget(self.cmb_select_V, 7, 0) self.addWidget(self.spb_prc_V, 7, 1) self.addWidget(self.spb_unit_V, 7, 2) self.addWidget(self.btn_alignLayer_V, 7, 3) self.addWidget(self.cmb_select_H, 8, 0) self.addWidget(self.spb_prc_H, 8, 1) self.addWidget(self.spb_unit_H, 8, 2) self.addWidget(self.btn_alignLayer_H, 8, 3) self.addWidget(QtGui.QLabel('Channel processing and slopes'), 9,0,1,4) self.addWidget(self.btn_solveY, 10,0,1,2) self.addWidget(self.btn_solveX, 10,2,1,2) self.addWidget(self.btn_copy, 11,0,1,3) self.addWidget(self.btn_italic, 11,3,1,1) self.addWidget(self.btn_pasteMinY, 12,0,1,1) self.addWidget(self.btn_pasteMaxY, 12,1,1,1) self.addWidget(self.btn_pasteFMinY, 12,2,1,1) self.addWidget(self.btn_pasteFMaxY, 12,3,1,1)
def transform(self, shapes=False): if self.aux.doCheck() and len(self.aux.lst_layers.selectedItems()): # - Init wGlyph = self.aux.glyph inpShift = self.edt_shift.text.split(',') if len( self.edt_shift.text ) and ',' in self.edt_shift.text else '0.0, 0.0' inpScale = self.edt_scale.text.split(',') if len( self.edt_scale.text ) and ',' in self.edt_scale.text else '100, 100' wSift_x = float(inpShift[0].strip()) wSift_y = float(inpShift[1].strip()) wScale_x = float(inpScale[0].strip()) / 100 wScale_y = float(inpScale[1].strip()) / 100 wSlant = radians(float(self.edt_slant.text.strip())) if len( self.edt_slant.text) else 0. wRotate = -float(self.edt_rotate.text.strip()) if len( self.edt_rotate.text) else 0. # m11, m12, m13, m21, m22, m23, m31, m32, m33 = 1 # ! Note: wrong but will do... new_transform = QtGui.QTransform().scale( wScale_x, wScale_y).rotate(wRotate).shear(wSlant, 0).translate(wSift_x, wSift_y) for item in self.aux.lst_layers.selectedItems(): wLayer = wGlyph.layer(item.text()) if not shapes: # - Transform at origin wBBox = wLayer.boundingBox wCenter = (wBBox.width() / 2 + wBBox.x(), wBBox.height() / 2 + wBBox.y()) transform_to_origin = QtGui.QTransform().translate( -wCenter[0], -wCenter[1]) transform_from_origin = QtGui.QTransform().translate( *wCenter) # - Transform wLayer.applyTransform(transform_to_origin) wLayer.applyTransform(new_transform) wLayer.applyTransform(transform_from_origin) else: wShapes = wGlyph.shapes(item.text()) for shape in wShapes: # - Transform at origin and move to new location according to transformation wBBox = shape.boundingBox wCenter = (wBBox.width() / 2 + wBBox.x(), wBBox.height() / 2 + wBBox.y()) newCenter = new_transform.map(QtCore.QPointF(*wCenter)) transform_to_origin = QtGui.QTransform().translate( -wCenter[0], -wCenter[1]) transform_from_origin = QtGui.QTransform().translate( newCenter.x(), wCenter[1]) #transform_from_origin = QtGui.QTransform().translate(*wCenter) # - Transform shape.applyTransform(transform_to_origin) shape.applyTransform(new_transform) shape.applyTransform(transform_from_origin) self.aux.glyph.updateObject( self.aux.glyph.fl, ' Glyph: %s; Transform Layers: %s' % (self.aux.glyph.fl.name, '; '.join([ item.text() for item in self.aux.lst_layers.selectedItems() ]))) self.aux.glyph.update()
def __init__(self, aux): super(QlayerMultiEdit, self).__init__() # - Init self.aux = aux self.backup = {} self.contourClipboard = {} # -- Edit fileds self.edt_shift = QtGui.QLineEdit('0.0, 0.0') self.edt_scale = QtGui.QLineEdit('100, 100') self.edt_slant = QtGui.QLineEdit('0.0') self.edt_rotate = QtGui.QLineEdit('0.0') self.edt_shift.setToolTip('Translate Layer by X, Y (comma separated)') self.edt_scale.setToolTip( 'Scale Layer by X percent, Y percent(comma separated)') self.edt_slant.setToolTip('Slant/Shear degrees') self.edt_rotate.setToolTip('Rotate degrees') # -- Quick Tool buttons self.lay_buttons = QtGui.QGridLayout() self.btn_unfold = QtGui.QPushButton('Unfold Layers') self.btn_restore = QtGui.QPushButton('Fold Layers') self.btn_copy = QtGui.QPushButton('Copy Outline') self.btn_paste = QtGui.QPushButton('Paste Outline') self.btn_transform = QtGui.QPushButton('Transform Layer') self.btn_transform_shape = QtGui.QPushButton('Transform Elements') self.btn_restore.setEnabled(False) self.btn_paste.setEnabled(False) self.btn_unfold.setToolTip( 'Reposition selected layers side by side. Selection order does matter!' ) self.btn_restore.setToolTip('Restore Layer Metrics.') self.btn_copy.setToolTip( 'Copy selected outline to cliboard for each of selected layers.') self.btn_paste.setToolTip( 'Paste outline from cliboard layer by layer (by name). Non existing layers are discarded! New Element is created upon Paste!' ) self.btn_transform.setToolTip('Affine transform selected layers') self.btn_unfold.clicked.connect(self.unfold) self.btn_restore.clicked.connect(self.restore) self.btn_copy.clicked.connect(self.copy) self.btn_paste.clicked.connect(self.paste) self.btn_transform.clicked.connect(lambda: self.transform(False)) self.btn_transform_shape.clicked.connect(lambda: self.transform(True)) self.lay_buttons.addWidget(self.btn_unfold, 0, 0, 1, 4) self.lay_buttons.addWidget(self.btn_restore, 0, 4, 1, 4) self.lay_buttons.addWidget(self.btn_copy, 1, 0, 1, 4) self.lay_buttons.addWidget(self.btn_paste, 1, 4, 1, 4) self.lay_buttons.addWidget(QtGui.QLabel('Translate:'), 2, 0, 1, 2) self.lay_buttons.addWidget(QtGui.QLabel('Scale:'), 2, 2, 1, 2) self.lay_buttons.addWidget(QtGui.QLabel('Shear:'), 2, 4, 1, 2) self.lay_buttons.addWidget(QtGui.QLabel('Rotate:'), 2, 6, 1, 2) self.lay_buttons.addWidget(self.edt_shift, 3, 0, 1, 2) self.lay_buttons.addWidget(self.edt_scale, 3, 2, 1, 2) self.lay_buttons.addWidget(self.edt_slant, 3, 4, 1, 2) self.lay_buttons.addWidget(self.edt_rotate, 3, 6, 1, 2) self.lay_buttons.addWidget(self.btn_transform, 4, 0, 1, 4) self.lay_buttons.addWidget(self.btn_transform_shape, 4, 4, 1, 4) self.addLayout(self.lay_buttons)
def __init__(self, aux): super(QlayerTools, self).__init__() # - Init self.aux = aux # -- Mode checks self.lay_checks = QtGui.QGridLayout() self.chk_outline = QtGui.QCheckBox('Outline') self.chk_guides = QtGui.QCheckBox('Guides') self.chk_anchors = QtGui.QCheckBox('Anchors') self.chk_lsb = QtGui.QCheckBox('LSB') self.chk_adv = QtGui.QCheckBox('Advance') self.chk_rsb = QtGui.QCheckBox('RSB') # -- Set States self.chk_outline.setCheckState(QtCore.Qt.Checked) self.chk_adv.setCheckState(QtCore.Qt.Checked) # -- Build self.lay_checks.addWidget(self.chk_outline, 0, 0) self.lay_checks.addWidget(self.chk_guides, 0, 1) self.lay_checks.addWidget(self.chk_anchors, 0, 2) self.lay_checks.addWidget(self.chk_lsb, 1, 0) self.lay_checks.addWidget(self.chk_adv, 1, 1) self.lay_checks.addWidget(self.chk_rsb, 1, 2) self.addLayout(self.lay_checks) # -- Quick Tool buttons self.lay_buttons = QtGui.QGridLayout() self.btn_swap = QtGui.QPushButton('Swap') self.btn_copy = QtGui.QPushButton('Copy') self.btn_paste = QtGui.QPushButton('Paste') self.btn_clean = QtGui.QPushButton('Remove') self.btn_unlock = QtGui.QPushButton('Unlock') self.btn_expand = QtGui.QPushButton('Expand') #self.btn_unlock.setEnabled(False) self.btn_expand.setEnabled(False) self.btn_swap.setToolTip('Swap Selected Layer with Active Layer') self.btn_copy.setToolTip('Copy Active Layer to Selected Layer') self.btn_paste.setToolTip('Paste Selected Layer to Active Layer') self.btn_clean.setToolTip('Remove contents from selected layers') self.btn_unlock.setToolTip( 'Unlock all locked references.\nSHIFT+Click will lock all references.' ) self.btn_expand.setToolTip( 'Expand transformations for selected layers') self.btn_swap.clicked.connect(self.swap) self.btn_copy.clicked.connect(self.copy) self.btn_paste.clicked.connect(self.paste) self.btn_clean.clicked.connect(self.clean) self.btn_unlock.clicked.connect(self.unlock) #self.btn_expand.clicked.connect(self.expand) self.lay_buttons.addWidget(self.btn_swap, 0, 0, 1, 1) self.lay_buttons.addWidget(self.btn_copy, 0, 1, 1, 1) self.lay_buttons.addWidget(self.btn_paste, 0, 2, 1, 1) self.lay_buttons.addWidget(self.btn_clean, 1, 0, 1, 1) self.lay_buttons.addWidget(self.btn_unlock, 1, 1, 1, 1) self.lay_buttons.addWidget(self.btn_expand, 1, 2, 1, 1) self.addLayout(self.lay_buttons)
def process_insert(self): # - Init self.active_font = pFont() current_glyph = eGlyph() getUniGlyph = lambda c: self.active_font.fl.findUnicode(ord( c)).name if all(['uni' not in c, '.' not in c, '_' not in c] ) else c # - Parse input ------------------------------------------------------------ for line in self.txt_editor.toPlainText().splitlines(): # - Init process_glyphs = {} dst_store, src_store = [], [] w_layer = syn_passlayer # Pass all commands - no specific layer selected if syn_insert in line and syn_comment not in line: init_parse = line.split(syn_insert) if len(init_parse) == 2: # No specific layer given left, rigth = init_parse elif len(init_parse) == 3: # Layer explicitly set w_layer, left, rigth = init_parse w_layer = w_layer.strip() else: print 'ERROR:\tInvalid syntax! Skipping Line: %s\n' % line continue # - Set basics #dst_store = [getUniGlyph(name) if syn_currglyph not in name else current_glyph.name for name in rigth.split()] dst_store = [ name if syn_currglyph not in name else current_glyph.name for name in rigth.split() ] src_temp = [ item.strip().split(syn_pos) for item in left.split() ] src_temp = [[item[0], item[1].split(syn_transform)] if len(item) > 1 else item for item in src_temp] process_glyphs = {glyph: src_temp for glyph in dst_store} # - Process ------------------------------------------------------------ for glyph_name, insert_command in process_glyphs.iteritems(): # - Set working glyph w_glyph = eGlyph(self.active_font.glyph(glyph_name).fl) process_layers = w_glyph._prepareLayers(pLayers) for layer in process_layers: # - Process insertions for insert in insert_command: if len(insert): # - Init # -- Shape retrieval and origin determination if len(insert[0]): if syn_bboxBL in insert[ 0]: # Shape origin: measured at Shapes BBox Bottom Left insert_name = insert[0].replace( syn_bboxBL, '') w_shape = self.active_font.findShape( insert_name, layer) insert_origin = Coord( w_shape.boundingBox.x(), w_shape.boundingBox.y()) elif syn_bboxBR in insert[ 0]: # Shape origin: measured at Shapes BBox Bottom Right insert_name = insert[0].replace( syn_bboxBR, '') w_shape = self.active_font.findShape( insert_name, layer) insert_origin = Coord( w_shape.boundingBox.x() + w_shape.boundingBox.width(), w_shape.boundingBox.y()) elif syn_bboxTL in insert[ 0]: # Shape origin: measured at Shapes BBox Top Left insert_name = insert[0].replace( syn_bboxTL, '') w_shape = self.active_font.findShape( insert_name, layer) insert_origin = Coord( w_shape.boundingBox.x(), w_shape.boundingBox.y() + w_shape.boundingBox.height()) elif syn_bboxTR in insert[ 0]: # Shape origin: measured at Shapes BBox Top Right insert_name = insert[0].replace( syn_bboxTR, '') w_shape = self.active_font.findShape( insert_name, layer) insert_origin = Coord( w_shape.boundingBox.x() + w_shape.boundingBox.height(), w_shape.boundingBox.y() + w_shape.boundingBox.width()) elif syn_label in insert[ 0]: # Shape origin: At source Glyphs Labeled Node insert_name, node_label = insert[ 0].split(syn_label) for glyph in self.active_font.pGlyphs( ): w_shape = glyph.findShape( insert_name, layer) if w_shape is not None: insert_origin = Coord( glyph.findNodeCoords( node_label, layer)) break else: # Shape origin: Not set insert_name = insert[0] w_shape = self.active_font.findShape( insert_name, layer) insert_origin = Coord(0, 0) else: print 'ERROR:\tInvalid command! Skipping insertion command: %s\n' % insert continue # -- In-glyph positioning insert_position = None if len( insert ) == 1: # Position: Simplest case no positional tags insert_coord = Coord((0, 0)) else: if len(insert[1]): w_bbox = w_glyph.getBounds(layer) if syn_currnode == insert[1][ 0]: # Position: Destination Glyphs Currently selected node position = w_glyph.selectedCoords( layer, applyTransform=True) insert_position = position[ 0] if len(position) else None elif syn_bboxBL == insert[1][ 0]: # Position: Destination Glyphs BBox Bottom Left insert_position = (w_bbox.x(), w_bbox.y()) elif syn_bboxBR == insert[1][ 0]: # Position: Destination Glyphs BBox Bottom Right insert_position = (w_bbox.x() + w_bbox.width(), w_bbox.y()) elif syn_bboxTL == insert[1][ 0]: # Position: Destination Glyphs BBox Top Left insert_position = (w_bbox.x(), w_bbox.y() + w_bbox.height()) elif syn_bboxTR == insert[1][ 0]: # Position: Destination Glyphs BBox Top Right insert_position = (w_bbox.x() + w_bbox.height(), w_bbox.y() + w_bbox.width()) elif syn_label in insert[1][ 0]: # Position: Destination Glyphs Labeled Node insert_position = w_glyph.findNodeCoords( insert[1][0].strip(syn_label), layer) elif syn_anchor in insert[1][ 0]: # Position: Destination Glyphs Anchor insert_position = w_glyph.findAnchorCoords( insert[1][0].strip(syn_anchor), layer) elif syn_coordsep in insert[1][ 0]: # Position: Destination Glyphs Coordinates insert_position = eval( '(%s)' % insert[1][0]) if len( insert[1] ) > 1: # Positional correction in format (x,y) insert_correction = Coord( eval('(%s)' % insert[1][1])) else: insert_correction = Coord((0, 0)) if insert_position is None: print 'ERROR:\tInvalid positional tags! Skipping insertion command: %s\n' % insert continue # - Set insertion coordinates insert_coord = Coord( insert_position) + insert_correction # - Insert and reposition # !!! A quirky way of adding shapes follows # !!! This is so very wrong - adding the shape twice and removing the first, # !!! forces FL to make a proper clone of the shape!? temp_shape = w_glyph.addShape( w_shape, layer) # A dummy that helps ??! new_shape = w_glyph.addShape(w_shape, layer) w_glyph.layer(layer).removeShape(temp_shape) new_shape.assignStyle( w_shape ) # The only way to copy the 'non-spacing' property for now new_position = insert_coord - insert_origin new_transform = QtGui.QTransform( 1, 0, 0, 0, 1, 0, new_position.x, new_position.y, 1) new_shape.transform = new_transform w_glyph.update() #print 'New: %s; Insert: %s; Origin: %s' %(new_position, insert_coord, insert_origin) # - Finish w_glyph.updateObject( w_glyph.fl, 'Shapes inserted to glyph: %s' % w_glyph.name) print 'DONE:\t Glyphs processed: %s' % ' '.join(dst_store) print 'Done.'
def __init__(self): super(QStringGen, self).__init__() # - Init data val_fillerLeft, val_fillerRight = zip(*fillerList) self.defEncoding = 'utf-8' self.glyphNames = baseGlyphset # -- Init Interface self.edt_inputA = QtGui.QLineEdit() self.edt_inputB = QtGui.QLineEdit() self.edt_suffixA = QtGui.QLineEdit() self.edt_suffixB = QtGui.QLineEdit() self.edt_output = QtGui.QTextEdit() self.edt_sep = QtGui.QLineEdit() self.edt_inputA.setToolTip( 'Manual Glyph names input. [SPACE] delimited.\nNOTE: This field overrides the input combo box!' ) self.edt_inputB.setToolTip( 'Manual Glyph names input. [SPACE] delimited.\nNOTE: This field overrides the input combo box!' ) self.edt_suffixA.setToolTip('Suffix to be added to each glyph name.') self.edt_suffixB.setToolTip('Suffix to be added to each glyph name.') self.edt_sep.setText('/') #self.edt_inputA.setEnabled(False) #self.edt_inputB.setEnabled(False) self.cmb_fillerPattern = QtGui.QComboBox() self.cmb_inputA = QtGui.QComboBox() self.cmb_inputB = QtGui.QComboBox() self.cmb_fillerLeft = QtGui.QComboBox() self.cmb_fillerRight = QtGui.QComboBox() self.cmb_join = QtGui.QComboBox() self.cmb_inputA.addItems(sorted(self.glyphNames.keys())) self.cmb_inputB.addItems(sorted(self.glyphNames.keys())) self.cmb_fillerPattern.setEditable(True) self.cmb_fillerLeft.setEditable(True) self.cmb_fillerRight.setEditable(True) self.cmb_join.addItems(joinOpt.keys()) self.cmb_fillerPattern.addItems(filler_patterns) self.cmb_inputA.setToolTip('Glyph names list.') self.cmb_inputB.setToolTip('Glyph names list.') self.cmb_fillerLeft.setToolTip('Left Filler String.') self.cmb_fillerRight.setToolTip('Right Filler String.') self.cmb_join.setToolTip('Joining method for generated string pairs.') self.edt_sep.setToolTip('Glyph Separator.') self.cmb_fillerPattern.setToolTip( 'Generator pattern expression.\n<< Filed names >> in any order, [SPACE] separated.' ) self.cmb_fillerLeft.addItems(val_fillerLeft) self.cmb_fillerRight.addItems(val_fillerRight) self.btn_genCopy = QtGui.QPushButton('Generate') self.btn_genUni = QtGui.QPushButton('Unicode Str.') self.btn_populate = QtGui.QPushButton('&Populate lists') self.btn_clear = QtGui.QPushButton('&Rest fields') self.btn_glyphNames = QtGui.QPushButton('Get Selected Names') self.btn_genCopy.setToolTip( 'Generate the pair string using Glyph Names and send it to the clipboard.' ) self.btn_genUni.setToolTip( 'Generate the pair string using Unicode Characters and send it to the clipboard.' ) self.btn_populate.setToolTip( 'Populate name lists with existing glyph names in active font.') self.btn_clear.setToolTip('Clear all manual input fields.') self.btn_glyphNames.setToolTip( 'Get Names of currently selected glyphs.') self.btn_clear.clicked.connect(self.clear) self.btn_populate.clicked.connect(self.populate) self.btn_genCopy.clicked.connect(self.generate) self.btn_genUni.clicked.connect(self.generateUni) self.btn_glyphNames.clicked.connect(self.getNames) # - Build self.addWidget(QtGui.QLabel('A:'), 0, 0, 1, 1) self.addWidget(self.cmb_inputA, 0, 1, 1, 5) self.addWidget(QtGui.QLabel('Suffix:'), 0, 6, 1, 1) self.addWidget(self.edt_suffixA, 0, 7, 1, 2) self.addWidget(self.edt_inputA, 1, 1, 1, 8) self.addWidget(QtGui.QLabel('B:'), 2, 0, 1, 1) self.addWidget(self.cmb_inputB, 2, 1, 1, 5) self.addWidget(QtGui.QLabel('Suffix:'), 2, 6, 1, 1) self.addWidget(self.edt_suffixB, 2, 7, 1, 2) self.addWidget(self.edt_inputB, 3, 1, 1, 8) self.addWidget(QtGui.QLabel('FL:'), 4, 0, 1, 1) self.addWidget(self.cmb_fillerLeft, 4, 1, 1, 8) self.addWidget(QtGui.QLabel('FR:'), 5, 0, 1, 1) self.addWidget(self.cmb_fillerRight, 5, 1, 1, 8) self.addWidget(QtGui.QLabel('E:'), 6, 0, 1, 1) self.addWidget(self.cmb_fillerPattern, 6, 1, 1, 8) self.addWidget(QtGui.QLabel('Join:'), 7, 0, 1, 1) self.addWidget(self.cmb_join, 7, 1, 1, 5) self.addWidget(QtGui.QLabel('Sep.:'), 7, 6, 1, 1) self.addWidget(self.edt_sep, 7, 7, 1, 2) self.addWidget(QtGui.QLabel(''), 8, 0, 1, 1) self.addWidget(self.btn_populate, 9, 1, 1, 5) self.addWidget(self.btn_clear, 9, 6, 1, 3) self.addWidget(self.btn_genCopy, 10, 1, 1, 5) self.addWidget(self.btn_genUni, 10, 6, 1, 3) self.addWidget(QtGui.QLabel('OUT:'), 11, 0, 1, 1) self.addWidget(self.edt_output, 11, 1, 4, 8) self.addWidget(self.btn_glyphNames, 16, 1, 4, 8) self.setColumnStretch(0, 0) self.setColumnStretch(1, 2) self.setColumnStretch(6, 0) self.setColumnStretch(7, 1)
def markChange(self, item): item.setText(0, ('B: %s', 'T: %s')[float(item.text(2)) > 0] %item.text(1)) for col in range(item.columnCount()): item.setBackground(col, QtGui.QColor('powderblue'))
def __init__(self, aux): super(advMovement, self).__init__() # - Init self.aux = aux self.methodList = ['Move', 'Simple Move', 'Interpolated Move', 'Slanted Grid Move', 'Slope walker'] # - Methods self.cmb_methodSelector = QtGui.QComboBox() self.cmb_methodSelector.addItems(self.methodList) self.cmb_methodSelector.setToolTip('Select movement method') self.chk_percent = QtGui.QCheckBox('% of BBox') self.chk_percent.setToolTip('Interpret new positional coordinates as if they were scaled by percent given in (X,Y)\nEquivalent to affine scaling of selected nodes in respect to the Layers BoundingBox') # - Arrow buttons self.btn_up = QtGui.QPushButton('Up') self.btn_down = QtGui.QPushButton('Down') self.btn_left = QtGui.QPushButton('Left') self.btn_right = QtGui.QPushButton('Right') self.btn_up.setMinimumWidth(80) self.btn_down.setMinimumWidth(80) self.btn_left.setMinimumWidth(80) self.btn_right.setMinimumWidth(80) self.btn_up.clicked.connect(self.onUp) self.btn_down.clicked.connect(self.onDown) self.btn_left.clicked.connect(self.onLeft) self.btn_right.clicked.connect(self.onRight) self.chk_percent.clicked.connect(self.toggleInput) self.edt_offX = QtGui.QLineEdit('1.0') self.edt_offY = QtGui.QLineEdit('1.0') self.edt_offX.setToolTip('X offset') self.edt_offY.setToolTip('Y offset') # - Layout self.lay_btn = QtGui.QGridLayout() self.lay_btn.addWidget(self.cmb_methodSelector, 0, 0, 1, 5) self.lay_btn.addWidget(self.chk_percent, 0, 5, 1, 1) self.lay_btn.addWidget(QtGui.QLabel('X:'), 1, 0, 1, 1) self.lay_btn.addWidget(self.edt_offX, 1, 1, 1, 1) self.lay_btn.addWidget(self.btn_up, 1, 2, 1, 2) self.lay_btn.addWidget(QtGui.QLabel('Y:'), 1, 4, 1, 1) self.lay_btn.addWidget(self.edt_offY, 1, 5, 1, 1) self.lay_btn.addWidget(self.btn_left, 2, 0, 1, 2) self.lay_btn.addWidget(self.btn_down, 2, 2, 1, 2) self.lay_btn.addWidget(self.btn_right, 2, 4, 1, 2) self.addLayout(self.lay_btn)
def __init__(self, parentWidget): super(WKernGroups, self).__init__() # - Init self.upper_widget = parentWidget self.active_font = pFont() self.kern_group_data = {} #self.active_font.kerning_groups_to_dict() # - Interface lbl_name = QtGui.QLabel('Kerning classes') lbl_act = QtGui.QLabel('Actions (selected items):') lbl_name.setMaximumHeight(20) lbl_act.setMaximumHeight(20) self.cmb_layer = QtGui.QComboBox() self.cmb_layer.addItems(self.active_font.masters()) self.cmb_layer.currentIndexChanged.connect( lambda: self.update_data(self.kern_group_data)) self.btn_apply = QtGui.QPushButton('Apply changes') self.btn_write = QtGui.QPushButton('Write changes') self.btn_reset = QtGui.QPushButton('Clear font classes') self.btn_apply.clicked.connect(lambda: self.apply_changes(False)) self.btn_write.clicked.connect(lambda: self.apply_changes(True)) self.btn_reset.clicked.connect(lambda: self.reset_classes()) self.tab_groupKern = GroupTableView() # - Menus & Actions # -- Main Database actions self.menu_data = QtGui.QMenu('Class Data', self) act_data_open = QtGui.QAction('Open TypeRig Classes (JSON)', self) act_data_save = QtGui.QAction('Save TypeRig Classes (JSON)', self) act_data_import = QtGui.QAction('Import FontLab Classes (JSON)', self) act_data_export = QtGui.QAction('Export FontLab Classes (JSON)', self) act_data_import_font = QtGui.QAction('Import Classes from Font', self) act_data_build_composite = QtGui.QAction( 'Build Classes from References', self) act_data_reset = QtGui.QAction('Reset Font Class Data', self) act_data_write = QtGui.QAction('Write class data to Font', self) self.menu_data.addAction(act_data_open) self.menu_data.addAction(act_data_save) self.menu_data.addSeparator() self.menu_data.addAction(act_data_import) self.menu_data.addAction(act_data_export) self.menu_data.addSeparator() self.menu_data.addAction(act_data_import_font) self.menu_data.addAction(act_data_build_composite) self.menu_data.addSeparator() self.menu_data.addAction(act_data_reset) self.menu_data.addAction(act_data_write) act_data_open.triggered.connect(lambda: self.file_load_groups(True)) act_data_save.triggered.connect(lambda: self.file_save_groups(True)) act_data_import.triggered.connect(lambda: self.file_load_groups(False)) #act_data_export.triggered.connect() act_data_import_font.triggered.connect(lambda: self.from_font()) act_data_build_composite.triggered.connect( lambda: self.from_composites()) act_data_reset.triggered.connect(lambda: self.reset_classes()) act_data_write.triggered.connect(lambda: self.apply_changes(True)) # -- Main Class actions self.menu_class = QtGui.QMenu('Class Management', self) act_class_add = QtGui.QAction('Add new class', self) act_class_find = QtGui.QAction('Find and replace class names', self) act_class_copy = QtGui.QAction('Duplicate classes', self) act_class_merge = QtGui.QAction('Merge classes to new', self) act_class_mdel = QtGui.QAction('Merge and remove classes', self) act_class_del = QtGui.QAction('Remove classes', self) self.menu_class.addAction(act_class_add) self.menu_class.addAction(act_class_find) self.menu_class.addAction(act_class_copy) self.menu_class.addAction(act_class_merge) self.menu_class.addAction(act_class_mdel) self.menu_class.addAction(act_class_del) act_class_add.triggered.connect(lambda: self.class_add_new()) act_class_find.triggered.connect(lambda: self.class_find_replace()) act_class_copy.triggered.connect(lambda: self.class_copy()) act_class_merge.triggered.connect(lambda: self.class_merge(False)) act_class_mdel.triggered.connect(lambda: self.class_merge(True)) act_class_del.triggered.connect(lambda: self.class_del()) # -- Change class type self.menu_type = QtGui.QMenu('Class Type', self) act_type_Left = QtGui.QAction('Set KernLeft (1st)', self) act_type_Right = QtGui.QAction('Set KernRight (2nd)', self) act_type_Both = QtGui.QAction('Set KernBothSide (1st and 2nd)', self) act_type_toggle = QtGui.QAction('Toggle class type', self) act_type_Left.triggered.connect(lambda: self.set_type('KernLeft')) act_type_Right.triggered.connect(lambda: self.set_type('KernRight')) act_type_Both.triggered.connect(lambda: self.set_type('KernBothSide')) act_type_toggle.triggered.connect(lambda: self.toggle_type()) self.menu_type.addAction(act_type_Left) self.menu_type.addAction(act_type_Right) self.menu_type.addAction(act_type_Both) self.menu_type.addAction(act_type_toggle) # -- Modify Members self.menu_memb = QtGui.QMenu('Class Members', self) act_memb_sel = QtGui.QAction('Select Glyphs', self) act_memb_clean = QtGui.QAction('Cleanup', self) act_memb_upper = QtGui.QAction('Members to uppercase', self) act_memb_lower = QtGui.QAction('Members to lowercase', self) act_memb_strip = QtGui.QAction('Strip member suffixes', self) act_memb_suff = QtGui.QAction('Add suffix to members', self) act_memb_addglyphs = QtGui.QAction('Selected glyphs to members', self) act_memb_sel.triggered.connect(lambda: self.memb_select()) act_memb_clean.triggered.connect(lambda: self.memb_cleanup()) act_memb_upper.triggered.connect(lambda: self.memb_change_case(True)) act_memb_lower.triggered.connect(lambda: self.memb_change_case(False)) act_memb_strip.triggered.connect(lambda: self.memb_stripSuffix()) act_memb_suff.triggered.connect(lambda: self.memb_addSuffix()) act_memb_addglyphs.triggered.connect(lambda: self.memb_addGlyphs()) self.menu_memb.addAction(act_memb_sel) self.menu_memb.addAction(act_memb_clean) self.menu_memb.addAction(act_memb_upper) self.menu_memb.addAction(act_memb_lower) self.menu_memb.addAction(act_memb_strip) self.menu_memb.addAction(act_memb_suff) self.menu_memb.addAction(act_memb_addglyphs) # - Table auto preview selection self.chk_preview = QtGui.QCheckBox('Auto select/preview class.') self.tab_groupKern.selectionModel().selectionChanged.connect( lambda: self.auto_preview()) # - Build self.lay_grid = QtGui.QGridLayout() self.lay_grid.addWidget(lbl_name, 0, 0, 1, 42) self.lay_grid.addWidget(QtGui.QLabel('Master:'), 0, 40, 1, 2) self.lay_grid.addWidget(self.cmb_layer, 0, 42, 1, 6) self.lay_grid.addWidget(self.tab_groupKern, 1, 0, 9, 42) self.lay_grid.addWidget(self.chk_preview, 2, 42, 1, 6) self.lay_grid.addWidget(self.btn_apply, 1, 42, 1, 6) self.lay_grid.addWidget(self.btn_reset, 8, 42, 1, 6) self.lay_grid.addWidget(self.btn_write, 9, 42, 1, 6) for i in range(1, 8): self.lay_grid.setRowStretch(i, 2) self.setLayout(self.lay_grid)
def __init__(self): super(metrics_copy, self).__init__() # - Edit Fields self.edt_lsb = QtGui.QLineEdit() self.edt_adv = QtGui.QLineEdit() self.edt_rsb = QtGui.QLineEdit() self.edt_lsb.setPlaceholderText('Glyph Name') self.edt_adv.setPlaceholderText('Glyph Name') self.edt_rsb.setPlaceholderText('Glyph Name') # - Spin Box self.spb_lsb_percent = QtGui.QSpinBox() self.spb_adv_percent = QtGui.QSpinBox() self.spb_rsb_percent = QtGui.QSpinBox() self.spb_lsb_units = QtGui.QSpinBox() self.spb_adv_units = QtGui.QSpinBox() self.spb_rsb_units = QtGui.QSpinBox() self.spb_lsb_percent.setMaximum(200) self.spb_adv_percent.setMaximum(200) self.spb_rsb_percent.setMaximum(200) self.spb_lsb_units.setMaximum(200) self.spb_adv_units.setMaximum(200) self.spb_rsb_units.setMaximum(200) self.spb_lsb_units.setMinimum(-200) self.spb_adv_units.setMinimum(-200) self.spb_rsb_units.setMinimum(-200) self.spb_lsb_percent.setSuffix('%') self.spb_adv_percent.setSuffix('%') self.spb_rsb_percent.setSuffix('%') self.spb_lsb_units.setSuffix(' u') self.spb_adv_units.setSuffix(' u') self.spb_rsb_units.setSuffix(' u') self.spb_lsb_percent.setMaximumWidth(50) self.spb_adv_percent.setMaximumWidth(50) self.spb_rsb_percent.setMaximumWidth(50) self.spb_lsb_units.setMaximumWidth(50) self.spb_adv_units.setMaximumWidth(50) self.spb_rsb_units.setMaximumWidth(50) self.reset_fileds() # - Buttons self.btn_copyMetrics = QtGui.QPushButton('&Copy Metrics') self.btn_copyMetrics.clicked.connect(self.copyMetrics) # - Build self.addWidget(QtGui.QLabel('LSB:'), 0, 0, 1, 1) self.addWidget(self.edt_lsb, 0, 1, 1, 3) self.addWidget(QtGui.QLabel('@'), 0, 4, 1, 1) self.addWidget(self.spb_lsb_percent, 0, 5, 1, 1) self.addWidget(QtGui.QLabel('+'), 0, 6, 1, 1) self.addWidget(self.spb_lsb_units, 0, 7, 1, 1) self.addWidget(QtGui.QLabel('RSB:'), 1, 0, 1, 1) self.addWidget(self.edt_rsb, 1, 1, 1, 3) self.addWidget(QtGui.QLabel('@'), 1, 4, 1, 1) self.addWidget(self.spb_rsb_percent, 1, 5, 1, 1) self.addWidget(QtGui.QLabel('+'), 1, 6, 1, 1) self.addWidget(self.spb_rsb_units, 1, 7, 1, 1) self.addWidget(QtGui.QLabel('ADV:'), 2, 0, 1, 1) self.addWidget(self.edt_adv, 2, 1, 1, 3) self.addWidget(QtGui.QLabel('@'), 2, 4, 1, 1) self.addWidget(self.spb_adv_percent, 2, 5, 1, 1) self.addWidget(QtGui.QLabel('+'), 2, 6, 1, 1) self.addWidget(self.spb_adv_units, 2, 7, 1, 1) self.addWidget(self.btn_copyMetrics, 3, 1, 1, 8)
def setTable(self, data, 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) # -- Selectively add data if m == 0: newitem = QtGui.QTableWidgetItem(str(data[layer][key])) newitem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable) newitem.setCheckState(QtCore.Qt.Unchecked) self.setItem(n, m, newitem) if 0 < m < 3: combo = QtGui.QComboBox() if m % 2: combo.setStyleSheet( 'QComboBox { background-color: rgba(255, 0, 0, 15); }' ) else: combo.setStyleSheet( 'QComboBox { background-color: rgba(0, 255, 0, 15); }' ) combo.addItems(data[layer][key]) self.setCellWidget(n, m, combo) if 2 < m < len(data[layer].keys()): spin = QtGui.QDoubleSpinBox() if m <= 6: spin.setSuffix(' u') if m % 2: spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(255, 0, 0, 15); }' ) else: spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(0, 255, 0, 15); }' ) spin.setMinimum(0.) spin.setMaximum(1000.) if 7 <= m <= 8: spin.setSuffix(' u') if m % 2: spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(255, 200, 0, 25); }' ) else: spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(255, 200, 0, 25); }' ) spin.setMinimum(0.) spin.setMaximum(1000.) if 9 <= m <= 10: spin.setSuffix(' %') spin.setStyleSheet( 'QDoubleSpinBox { background-color: rgba(0, 0, 255, 15); }' ) spin.setMinimum(0.) spin.setMaximum(500.) if 10 < m: spin.setMinimum(0) spin.setMaximum(1) spin.setSingleStep(0.01) spin.setValue(data[layer][key]) self.setCellWidget(n, m, spin) self.setHorizontalHeaderLabels(name_column) self.setVerticalHeaderLabels(name_row) self.blockSignals(False)
def __init__(self): super(metrics_adjust, self).__init__() # - Spin Boxes self.spb_lsb_percent = QtGui.QSpinBox() self.spb_adv_percent = QtGui.QSpinBox() self.spb_rsb_percent = QtGui.QSpinBox() self.spb_lsb_units = QtGui.QSpinBox() self.spb_adv_units = QtGui.QSpinBox() self.spb_rsb_units = QtGui.QSpinBox() self.spb_lsb_percent.setMaximum(200) self.spb_adv_percent.setMaximum(200) self.spb_rsb_percent.setMaximum(200) self.spb_lsb_units.setMaximum(200) self.spb_adv_units.setMaximum(200) self.spb_rsb_units.setMaximum(200) self.spb_lsb_units.setMinimum(-200) self.spb_adv_units.setMinimum(-200) self.spb_rsb_units.setMinimum(-200) self.spb_lsb_percent.setSuffix('%') self.spb_adv_percent.setSuffix('%') self.spb_rsb_percent.setSuffix('%') self.spb_lsb_units.setSuffix(' u') self.spb_adv_units.setSuffix(' u') self.spb_rsb_units.setSuffix(' u') self.resetSpinBox() # - Buttons self.btn_adjMetrics = QtGui.QPushButton('&Adjust Metrics') self.btn_resetSpinBox = QtGui.QPushButton('&Reset') self.btn_adjMetrics.clicked.connect(self.adjMetrics) self.btn_resetSpinBox.clicked.connect(self.resetSpinBox) self.addWidget(QtGui.QLabel('LSB adjust:'), 0, 0, 1, 1) self.addWidget(QtGui.QLabel('RSB adjust:'), 0, 1, 1, 1) self.addWidget(QtGui.QLabel('ADV adjust:'), 0, 2, 1, 1) self.addWidget(self.spb_lsb_percent, 1, 0, 1, 1) self.addWidget(self.spb_rsb_percent, 1, 1, 1, 1) self.addWidget(self.spb_adv_percent, 1, 2, 1, 1) self.addWidget(self.spb_lsb_units, 2, 0, 1, 1) self.addWidget(self.spb_rsb_units, 2, 1, 1, 1) self.addWidget(self.spb_adv_units, 2, 2, 1, 1) self.addWidget(self.btn_resetSpinBox, 3, 0, 1, 1) self.addWidget(self.btn_adjMetrics, 3, 1, 1, 2)
def __init__(self): super(QDropGuide, self).__init__() # -- Editi fileds self.edt_guideName = QtGui.QLineEdit() self.edt_guideName.setPlaceholderText('New Guideline') self.edt_guideTag = GLineEdit() self.edt_guideTag.setPlaceholderText('Tag') # -- 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(100) self.spb_prc_V.setSuffix('%') self.spb_prc_V.setMinimumWidth(45) self.spb_prc_H = QtGui.QSpinBox() self.spb_prc_H.setMaximum(100) self.spb_prc_H.setSuffix('%') self.spb_prc_H.setMinimumWidth(45) self.spb_unit_V = QtGui.QSpinBox() self.spb_unit_V.setMaximum(100) self.spb_unit_V.setMinimum(-100) self.spb_unit_V.setSuffix(' U') self.spb_unit_V.setMinimumWidth(45) self.spb_unit_H = QtGui.QSpinBox() self.spb_unit_H.setMaximum(100) self.spb_unit_H.setMinimum(-100) 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_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_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_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, 9) self.addWidget(self.cmb_select_V, 6, 0, 1, 4) self.addWidget(self.spb_prc_V, 6, 4, 1, 2) self.addWidget(self.spb_unit_V, 6, 6, 1, 2) self.addWidget(self.btn_dropLayer_V, 6, 8, 1, 4) self.addWidget(self.cmb_select_H, 7, 0, 1, 4) self.addWidget(self.spb_prc_H, 7, 4, 1, 2) self.addWidget(self.spb_unit_H, 7, 6, 1, 2) self.addWidget(self.btn_dropLayer_H, 7, 8, 1, 4)
def markChange(self, item): print item.setBackground(QtGui.QColor("aliceblue"))
def __init__(self): super(mixerTail, self).__init__() self.edt_width_0 = QtGui.QLineEdit() self.edt_width_1 = QtGui.QLineEdit() self.edt_width_t = QtGui.QLineEdit() self.edt_height_0 = QtGui.QLineEdit() self.edt_height_1 = QtGui.QLineEdit() self.edt_height_t = QtGui.QLineEdit() self.edt_width_0.setReadOnly(True) self.edt_width_1.setReadOnly(True) self.edt_width_t.setReadOnly(True) self.edt_height_0.setReadOnly(True) self.edt_height_1.setReadOnly(True) self.edt_height_t.setReadOnly(True) self.edt_width_0.setPlaceholderText('BBox width') self.edt_width_1.setPlaceholderText('BBox width') self.edt_width_t.setPlaceholderText('BBox width') self.edt_height_0.setPlaceholderText('BBox height') self.edt_height_1.setPlaceholderText('BBox height') self.edt_height_t.setPlaceholderText('BBox height') self.addWidget(QtGui.QLabel(''), 0, 0, 1, 1) self.addWidget(QtGui.QLabel('Master 0'), 0, 1, 1, 3) self.addWidget(QtGui.QLabel('Master 1'), 0, 4, 1, 3) self.addWidget(QtGui.QLabel('Result'), 0, 7, 1, 1) self.addWidget(QtGui.QLabel('Width:'), 1, 0, 1, 1) self.addWidget(self.edt_width_0, 1, 1, 1, 3) self.addWidget(self.edt_width_1, 1, 4, 1, 3) self.addWidget(self.edt_width_t, 1, 7, 1, 1) self.addWidget(QtGui.QLabel('Height'), 2, 0, 1, 1) self.addWidget(self.edt_height_0, 2, 1, 1, 3) self.addWidget(self.edt_height_1, 2, 4, 1, 3) self.addWidget(self.edt_height_t, 2, 7, 1, 1)
def __init__(self): super(curveEq, self).__init__() # - Basic operations self.btn_tunni = QtGui.QPushButton('&Tunni (Auto)') self.btn_hobby = QtGui.QPushButton('Set &Curvature') self.btn_hobby_get = QtGui.QPushButton('Get') self.btn_hobby_swap = QtGui.QPushButton('Swap') self.btn_prop = QtGui.QPushButton('Set &Handles') self.btn_tunni.setToolTip('Apply Tunni curve optimization') self.btn_hobby.setToolTip('Set Hobby spline curvature') self.btn_hobby_swap.setToolTip('Swap C0, C1 curvatures') self.btn_hobby_get.setToolTip( 'Get curvature for current selected\nsegment at active layer.') self.btn_prop.setToolTip( 'Set handle length in proportion to bezier node distance') self.spn_hobby0 = QtGui.QDoubleSpinBox() self.spn_hobby1 = QtGui.QDoubleSpinBox() self.spn_hobby0.setValue(0.95) self.spn_hobby1.setValue(0.95) self.spn_hobby0.setSingleStep(0.05) self.spn_hobby1.setSingleStep(0.05) self.spn_prop = QtGui.QDoubleSpinBox() self.spn_prop.setValue(0.30) self.spn_prop.setSingleStep(0.1) self.btn_tunni.clicked.connect(lambda: self.eqContour('tunni')) self.btn_hobby_swap.clicked.connect(self.hobby_swap) self.btn_hobby_get.clicked.connect(self.hobby_get) self.btn_hobby.clicked.connect(lambda: self.eqContour('hobby')) self.btn_prop.clicked.connect(lambda: self.eqContour('prop')) # -- Build: Curve optimization self.addWidget(self.btn_tunni, 0, 0, 1, 5) self.addWidget(QtGui.QLabel('Proportional handles'), 1, 0, 1, 5) self.addWidget(self.btn_prop, 2, 0, 1, 3) self.addWidget(QtGui.QLabel('P:'), 2, 3, 1, 1) self.addWidget(self.spn_prop, 2, 4, 1, 1) self.addWidget(QtGui.QLabel('Hobby curvature'), 3, 0, 1, 5) self.addWidget(self.btn_hobby_swap, 4, 0, 1, 1) self.addWidget(QtGui.QLabel('C0'), 4, 1, 1, 1) self.addWidget(self.spn_hobby0, 4, 2, 1, 1) self.addWidget(QtGui.QLabel('C1'), 4, 3, 1, 1) self.addWidget(self.spn_hobby1, 4, 4, 1, 1) self.addWidget(self.btn_hobby_get, 5, 0, 1, 1) self.addWidget(self.btn_hobby, 5, 1, 1, 4) self.setColumnStretch(0, 1) self.setColumnStretch(4, 0) self.setColumnStretch(5, 0) self.setColumnStretch(6, 0) self.setColumnStretch(7, 0)
def __init__(self): super(mixerHead, self).__init__() self.edt_glyphName = QtGui.QLineEdit() self.edt_stemV0 = QtGui.QLineEdit('1') self.edt_stemV1 = QtGui.QLineEdit('1') self.edt_stemH0 = QtGui.QLineEdit('1') self.edt_stemH1 = QtGui.QLineEdit('1') self.btn_refresh = QtGui.QPushButton('&Refresh') self.btn_set_axis = QtGui.QPushButton('Set &Axis') self.btn_getVstem = QtGui.QPushButton('Get &V Stems') self.btn_getHstem = QtGui.QPushButton('Get &H Stems') self.spb_compV = QtGui.QDoubleSpinBox() self.spb_compH = QtGui.QDoubleSpinBox() self.spb_compV.setValue(0.) self.spb_compH.setValue(0.) self.spb_compV.setSingleStep(.01) self.spb_compH.setSingleStep(.01) self.cmb_0 = QtGui.QComboBox() self.cmb_1 = QtGui.QComboBox() self.chk_italic = QtGui.QPushButton('Italic') self.chk_single = QtGui.QPushButton('Anisotropic') self.chk_preview = QtGui.QPushButton('Live Preview') self.chk_single.setToolTip( 'Active: Use X and Y sliders to control interpolation.') self.chk_single.setCheckable(True) self.chk_italic.setCheckable(True) self.chk_preview.setCheckable(True) self.chk_single.setChecked(False) self.chk_italic.setChecked(False) self.chk_preview.setChecked(False) self.addWidget(QtGui.QLabel('Glyph:'), 0, 0, 1, 1) self.addWidget(self.edt_glyphName, 0, 1, 1, 6) self.addWidget(self.btn_refresh, 0, 7, 1, 1) self.addWidget(QtGui.QLabel('Axis:'), 1, 0, 1, 1) self.addWidget(self.cmb_0, 1, 1, 1, 3) self.addWidget(self.cmb_1, 1, 4, 1, 3) self.addWidget(self.btn_set_axis, 1, 7, 1, 1) self.addWidget(QtGui.QLabel('V Stems:'), 2, 0, 1, 1) self.addWidget(self.edt_stemV0, 2, 1, 1, 3) self.addWidget(self.edt_stemV1, 2, 4, 1, 3) self.addWidget(self.btn_getVstem, 2, 7, 1, 1) self.addWidget(QtGui.QLabel('H Stems:'), 3, 0, 1, 1) self.addWidget(self.edt_stemH0, 3, 1, 1, 3) self.addWidget(self.edt_stemH1, 3, 4, 1, 3) self.addWidget(self.btn_getHstem, 3, 7, 1, 1) self.addWidget(QtGui.QLabel('Adj.V/H:'), 4, 0, 1, 1) self.addWidget(self.spb_compV, 4, 1, 1, 3) self.addWidget(self.spb_compH, 4, 4, 1, 3) self.addWidget(self.chk_italic, 4, 7, 1, 1) self.addWidget(QtGui.QLabel('Control:'), 5, 0, 1, 1) self.addWidget(self.chk_single, 5, 1, 1, 4) self.addWidget(self.chk_preview, 5, 5, 1, 3)
def __init__(self, aux, upperWidget): super(QTextBlockBasic, self).__init__() # - Init self.aux = aux #self.activeFont = pFont() self.upperWidget = upperWidget ''' self.active_workspace = pWorkspace() self.active_canvas = self.active_workspace.getCanvas() self.active_textBlock = pTextBlock(self.active_workspace.getTextBlockList()[0]) ''' # - Widgets self.chk_page = QtGui.QCheckBox('Page size:') self.chk_size = QtGui.QCheckBox('Width/Height:') self.chk_pos = QtGui.QCheckBox('Position X/Y:') self.chk_align = QtGui.QCheckBox('Text alignment:') self.chk_kegel = QtGui.QCheckBox('Font Size:') self.chk_page.setCheckState(QtCore.Qt.Checked) self.chk_size.setCheckState(QtCore.Qt.Checked) #self.chk_pos.setCheckState(QtCore.Qt.Checked) #self.chk_align.setCheckState(QtCore.Qt.Checked) self.chk_kegel.setCheckState(QtCore.Qt.Checked) self.cmb_pageSizes = QtGui.QComboBox() self.cmb_text_align = QtGui.QComboBox() self.cmb_pageSizes.addItems(sorted(page_sizes.keys())) self.cmb_text_align.addItems(text_align) self.cmb_pageSizes.currentTextChanged.connect(self.page_changed) self.cmb_text_align.currentTextChanged.connect(self.algn_changed) self.spb_font_size = QtGui.QSpinBox() self.spb_font_size.setSuffix(' pt') self.spb_font_size.setValue(12) self.spb_size_w = QtGui.QSpinBox() self.spb_size_h = QtGui.QSpinBox() self.spb_pos_x = QtGui.QSpinBox() self.spb_pos_y = QtGui.QSpinBox() self.spb_size_w.setMaximum(9999) self.spb_size_h.setMaximum(9999) self.spb_pos_x.setMaximum(9999) self.spb_pos_y.setMaximum(9999) self.spb_pos_x.setMinimum(-9999) self.spb_pos_y.setMinimum(-9999) self.spb_size_w.setValue(page_sizes[self.cmb_pageSizes.currentText][0]) self.spb_size_h.setValue(page_sizes[self.cmb_pageSizes.currentText][1]) self.btn_apply = QtGui.QPushButton('Set Text Block(s)') self.btn_clone = QtGui.QPushButton('Clone') self.btn_lock = QtGui.QPushButton('Lock') self.btn_reformat = QtGui.QPushButton('Reformat') self.btn_remove = QtGui.QPushButton('Remove') self.btn_stack_v = QtGui.QPushButton('Stack Vertically') self.btn_stack_h = QtGui.QPushButton('Stack Horizontally') #self.btn_save = QtGui.QPushButton('Save Layout') #self.btn_load = QtGui.QPushButton('Load Layout') self.btn_apply.clicked.connect(lambda: self.block_action('format')) self.btn_clone.clicked.connect(lambda: self.block_action('clone')) self.btn_remove.clicked.connect(lambda: self.block_action('remove')) self.btn_lock.clicked.connect(lambda: self.block_action('lock')) self.btn_reformat.clicked.connect( lambda: self.block_action('reformat')) self.btn_stack_v.clicked.connect(lambda: self.block_action('stack_v')) self.btn_stack_h.clicked.connect(lambda: self.block_action('stack_h')) #self.btn_save.clicked.connect(self.save) #self.btn_load.clicked.connect(self.load) # - Disable for now self.cmb_text_align.setEnabled(False) self.chk_align.setEnabled(False) # - Build layouts layoutV = QtGui.QGridLayout() layoutV.addWidget(QtGui.QLabel('Text Block: Formatting'), 0, 0, 1, 4) layoutV.addWidget(self.chk_page, 1, 0, 1, 2) layoutV.addWidget(self.cmb_pageSizes, 1, 2, 1, 2) layoutV.addWidget(self.chk_size, 2, 0, 1, 2) layoutV.addWidget(self.spb_size_w, 2, 2, 1, 1) layoutV.addWidget(self.spb_size_h, 2, 3, 1, 1) layoutV.addWidget(self.chk_pos, 3, 0, 1, 2) layoutV.addWidget(self.spb_pos_x, 3, 2, 1, 1) layoutV.addWidget(self.spb_pos_y, 3, 3, 1, 1) layoutV.addWidget(self.chk_align, 4, 0, 1, 2) layoutV.addWidget(self.cmb_text_align, 4, 2, 1, 2) layoutV.addWidget(self.chk_kegel, 5, 0, 1, 2) layoutV.addWidget(self.spb_font_size, 5, 2, 1, 2) layoutV.addWidget(self.btn_apply, 6, 0, 1, 4) layoutV.addWidget(QtGui.QLabel('Text Block: Tools'), 7, 0, 1, 4) layoutV.addWidget(self.btn_clone, 8, 0, 1, 2) layoutV.addWidget(self.btn_remove, 8, 2, 1, 2) layoutV.addWidget(self.btn_lock, 9, 0, 1, 2) layoutV.addWidget(self.btn_reformat, 9, 2, 1, 2) layoutV.addWidget(QtGui.QLabel('Text Block: Alignment'), 10, 0, 1, 4) layoutV.addWidget(self.btn_stack_h, 11, 0, 1, 2) layoutV.addWidget(self.btn_stack_v, 11, 2, 1, 2) ''' layoutV.addWidget(QtGui.QLabel('Text Block: Layout'), 12, 0, 1, 4) layoutV.addWidget(self.btn_save, 13, 0, 1, 2) layoutV.addWidget(self.btn_load, 13, 2, 1, 2) ''' # - Set Widget self.addLayout(layoutV)
def __init__(self, parentWidget): super(QSmartCorner, self).__init__() self.upper_widget = parentWidget # -- Init self.active_font = pFont() self.builder = None self.font_masters = self.active_font.masters() self.empty_preset = lambda row: OrderedDict([(row, OrderedDict([('Preset', 'Preset %s' %row)] + [(master, '0') for master in self.font_masters]))]) self.table_dict = self.empty_preset(0) self.last_preset = 0 # -- Widgets self.lay_head = QtGui.QGridLayout() self.edt_glyphName = QtGui.QLineEdit() self.edt_glyphName.setPlaceholderText('Glyph name') # -- Buttons self.btn_getBuilder = QtGui.QPushButton('Set &Builder') self.btn_findBuilder = QtGui.QPushButton('&From Font') self.btn_addPreset = QtGui.QPushButton('Add') self.btn_delPreset = QtGui.QPushButton('Remove') self.btn_resetPreset = QtGui.QPushButton('Reset') self.btn_loadPreset = QtGui.QPushButton('&Load Presets') self.btn_savePreset = QtGui.QPushButton('&Save Presets') self.btn_apply_smartCorner = QtGui.QPushButton('&Apply Smart Corner') self.btn_remove_smartCorner = QtGui.QPushButton('R&emove Smart Corner') self.btn_remove_presetCorner = QtGui.QPushButton('&Find and Remove') self.btn_apply_smartCorner.setToolTip('Apply Smart Corner preset on SELECTED nodes.') self.btn_remove_smartCorner.setToolTip('Remove Smart Corner on SELECTED nodes.') self.btn_remove_presetCorner.setToolTip('Find and remove all Smart Corners that equal the currently selected preset.') self.btn_apply_round = QtGui.QPushButton('&Round') self.btn_apply_mitre = QtGui.QPushButton('&Mitre') self.btn_apply_overlap = QtGui.QPushButton('&Overlap') self.btn_apply_trap = QtGui.QPushButton('&Trap') self.btn_rebuild = QtGui.QPushButton('Rebuild corner') self.btn_getBuilder.setMinimumWidth(70) self.btn_findBuilder.setMinimumWidth(70) self.btn_apply_round.setMinimumWidth(70) self.btn_apply_mitre.setMinimumWidth(70) self.btn_apply_overlap.setMinimumWidth(70) self.btn_apply_trap.setMinimumWidth(70) self.btn_rebuild.setMinimumWidth(70) self.btn_addPreset.setMinimumWidth(70) self.btn_delPreset.setMinimumWidth(70) self.btn_loadPreset.setMinimumWidth(140) self.btn_savePreset.setMinimumWidth(140) self.btn_apply_smartCorner.setMinimumWidth(140) self.btn_remove_smartCorner.setMinimumWidth(140) self.btn_remove_presetCorner.setMinimumWidth(140) self.btn_getBuilder.setCheckable(True) self.btn_getBuilder.setChecked(False) self.btn_findBuilder.setEnabled(False) self.btn_apply_round.setEnabled(False) self.btn_getBuilder.clicked.connect(lambda: self.getBuilder()) self.btn_addPreset.clicked.connect(lambda: self.preset_modify(False)) self.btn_delPreset.clicked.connect(lambda: self.preset_modify(True)) self.btn_resetPreset.clicked.connect(lambda: self.preset_reset()) self.btn_loadPreset.clicked.connect(lambda: self.preset_load()) self.btn_savePreset.clicked.connect(lambda: self.preset_save()) self.btn_apply_smartCorner.clicked.connect(lambda: self.apply_SmartCorner(False)) self.btn_remove_smartCorner.clicked.connect(lambda: self.apply_SmartCorner(True)) self.btn_remove_presetCorner.clicked.connect(lambda: self.remove_SmartCorner()) #self.btn_apply_round.clicked.connect(lambda: self.apply_round()) self.btn_apply_mitre.clicked.connect(lambda: self.apply_mitre(False)) self.btn_apply_overlap.clicked.connect(lambda: self.apply_mitre(True)) self.btn_apply_trap.clicked.connect(lambda: self.apply_trap()) self.btn_rebuild.clicked.connect(lambda: self.rebuild()) # -- Preset Table self.tab_presets = trTableView(None) self.preset_reset() # -- Build Layout self.lay_head.addWidget(QtGui.QLabel('Value Presets:'), 0,0,1,8) self.lay_head.addWidget(self.btn_loadPreset, 1,0,1,4) self.lay_head.addWidget(self.btn_savePreset, 1,4,1,4) self.lay_head.addWidget(self.btn_addPreset, 2,0,1,2) self.lay_head.addWidget(self.btn_delPreset, 2,2,1,2) self.lay_head.addWidget(self.btn_resetPreset, 2,4,1,4) self.lay_head.addWidget(self.tab_presets, 3,0,5,8) self.lay_head.addWidget(QtGui.QLabel('Corner Actions:'),10, 0, 1, 8) self.lay_head.addWidget(self.btn_apply_round, 11, 0, 1, 2) self.lay_head.addWidget(self.btn_apply_mitre, 11, 2, 1, 2) self.lay_head.addWidget(self.btn_apply_overlap, 11, 4, 1, 2) self.lay_head.addWidget(self.btn_apply_trap, 11, 6, 1, 2) self.lay_head.addWidget(self.btn_rebuild, 12, 0, 1, 8) self.lay_head.addWidget(QtGui.QLabel('Smart Corner:'), 13,0,1,8) self.lay_head.addWidget(QtGui.QLabel('Builder: '), 14,0,1,1) self.lay_head.addWidget(self.edt_glyphName, 14,1,1,3) self.lay_head.addWidget(self.btn_getBuilder, 14,4,1,2) self.lay_head.addWidget(self.btn_findBuilder, 14,6,1,2) self.lay_head.addWidget(self.btn_remove_smartCorner, 15,0,1,4) self.lay_head.addWidget(self.btn_remove_presetCorner, 15,4,1,4) self.lay_head.addWidget(self.btn_apply_smartCorner, 16,0,1,8) self.addLayout(self.lay_head)
def __init__(self, data): super(trTreeView, self).__init__() # - Init self.flag_valueChanged = QtGui.QColor('powderblue')