def Blaster( self, wordlist ): layout = self.w.radioGroup.get() # 0=stacked 1=sidebyside wordlist = self.Sanitise(wordlist) repeater = "" wlist = "" for w in wordlist: s=0 while s<masterlen: if layout==1: repeater = repeater + w + " " else: repeater = repeater + w + "\n" s=s+1 wlist = wlist + repeater + "\n" repeater = "" Glyphs.currentDocument.windowController().addTabWithString_( wlist ) # add text currentEditViewController = Glyphs.currentDocument.windowController().activeEditViewController() currentTab = currentEditViewController.graphicView() s=0 location_start = 0 listlen = len(wordlist) while s<listlen: myRangeOfGlyphs = NSRange() t=0 while t<masterlen: myRangeOfGlyphs.location = location_start myRangeOfGlyphs.length = len(wordlist[s]) # assign master value to range masterID = f.masters[t].id Attributes = { "GSLayerIdAttrib": masterID } currentTab.textStorage().text().addAttributes_range_( Attributes, myRangeOfGlyphs ) location_start = location_start + len(wordlist[s]) + 1 t+=1 location_start+=1 s=s+1 if not self.SaveP( self ): print("Could not save preferences." ) currentEditViewController.forceRedraw()
#MenuTitle: Show Masters of Previous Glyph # -*- coding: utf-8 -*- from __future__ import division, print_function, unicode_literals __doc__ = """ Shows all masters for the previous glyph. """ from Foundation import NSRange from PyObjCTools.AppHelper import callAfter zeroPosition = NSRange() zeroPosition.location = 0 zeroPosition.length = 0 def showAllMastersOfGlyphInCurrentTab(thisGlyphName): try: escapedGlyphName = "/" + thisGlyphName thisDoc = Glyphs.currentDocument thisWindow = thisDoc.windowController() thisEditView = thisWindow.activeEditViewController() # current tab if thisEditView is None: # opens new Edit tab if none was open: callAfter(thisWindow.addTabWithString_, escapedGlyphName) else: thisGraphicView = thisEditView.graphicView( ) # current display string thisGraphicView.setDisplayString_( escapedGlyphName) # set the display string to this glyph thisGraphicView.setSelectedRange_(