Esempio n. 1
0
	def __init__( self ):
		# Window 'self.w':
		windowWidth  = 350
		windowHeight = 140
		windowWidthResize  = 100 # user can resize width by this value
		windowHeightResize = 0   # user can resize height by this value
		self.w = vanilla.FloatingWindow(
			( windowWidth, windowHeight ), # default window size
			"Set Family Alignment Zones", # window title
			minSize = ( windowWidth, windowHeight ), # minimum size (for resizing)
			maxSize = ( windowWidth + windowWidthResize, windowHeight + windowHeightResize ), # maximum size (for resizing)
			autosaveName = "com.mekkablue.SetFamilyAlignmentZones.mainwindow" # stores last window position and size
		)
		
		# UI elements:
		linePos, inset, lineHeight = 12, 15, 22
		
		self.w.descriptionText = vanilla.TextBox( (inset, linePos+2, -inset, lineHeight*2), u"Choose an instance (typically the Regular), and insert its zones as PostScript Family Alignment Zones.", sizeStyle='small', selectable=True )
		linePos += lineHeight*2
		
		self.w.instanceText = vanilla.TextBox( (inset, linePos+2, inset+55, 14), u"Instance:", sizeStyle='small', selectable=True )
		
		self.w.instancePicker = vanilla.PopUpButton( (inset+55, linePos, -inset-25, 17), (), sizeStyle='small' )
		self.w.instancePicker.getNSPopUpButton().setToolTip_("Inactive instances are marked.")
		# set font to tabular figures:
		popUpFont = NSFont.monospacedDigitSystemFontOfSize_weight_(NSFont.smallSystemFontSize(), 0.0)
		self.w.instancePicker.getNSPopUpButton().setFont_(popUpFont)
		
		self.w.updateButton = vanilla.SquareButton( (-inset-20, linePos, -inset, 18), u"↺", sizeStyle='small', callback=self.updateInstancePicker )
		self.w.updateButton.getNSButton().setToolTip_("Click to update the menu with the instances of the current font.")
		linePos += lineHeight
		
		# Run Button:
		self.w.runButton = vanilla.Button( (-110-inset, -20-inset, -inset, -inset), "Insert FAZ", sizeStyle='regular', callback=self.SetFamilyAlignmentZonesMain )
		self.w.setDefaultButton( self.w.runButton )
		
		
		# Open window and focus on it:
		self.updateInstancePicker()
		self.w.open()
		self.w.makeKey()