本文整理汇总了Python中AppKit.NSColor.blackColor方法的典型用法代码示例。如果您正苦于以下问题:Python NSColor.blackColor方法的具体用法?Python NSColor.blackColor怎么用?Python NSColor.blackColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKit.NSColor
的用法示例。
在下文中一共展示了NSColor.blackColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawRect_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def drawRect_(self, rect):
from AppKit import NSRectFill, NSBezierPath, NSColor
self.color.set()
NSRectFill(self.bounds())
NSColor.blackColor().set()
p = NSBezierPath.bezierPathWithRect_(self.bounds())
p.setLineWidth_(10)
p.stroke()
示例2: drawTextAtPoint
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def drawTextAtPoint(self, text, textPosition, fontSize=10.0, fontColor=NSColor.blackColor(), align='bottomleft'):
"""
Use self.drawTextAtPoint("blabla", myNSPoint) to display left-aligned text at myNSPoint.
"""
try:
alignment = {
'topleft': 6,
'topcenter': 7,
'topright': 8,
'left': 3,
'center': 4,
'right': 5,
'bottomleft': 0,
'bottomcenter': 1,
'bottomright': 2
}
currentZoom = self.getScale()
fontAttributes = {
NSFontAttributeName: NSFont.labelFontOfSize_(fontSize / currentZoom),
NSForegroundColorAttributeName: fontColor}
displayText = NSAttributedString.alloc().initWithString_attributes_(unicode(text), fontAttributes)
textAlignment = alignment[align] # top left: 6, top center: 7, top right: 8, center left: 3, center center: 4, center right: 5, bottom left: 0, bottom center: 1, bottom right: 2
displayText.drawAtPoint_alignment_(textPosition, textAlignment)
except:
self.logError(traceback.format_exc())
示例3: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def __init__(self, posSize, title=None):
self._setupView(self.nsBoxClass, posSize)
if title:
self._nsObject.setTitle_(title)
if osVersionCurrent < osVersion10_10:
self._nsObject.titleCell().setTextColor_(NSColor.blackColor())
font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSSmallControlSize))
self._nsObject.setTitleFont_(font)
else:
self._nsObject.setTitlePosition_(NSNoTitle)
示例4: applicationDidFinishLaunching_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def applicationDidFinishLaunching_(self, aNotification):
d = {'StderrColor': NSArchiver.archivedDataWithRootObject_(NSColor.redColor()),
'StdoutColor': NSArchiver.archivedDataWithRootObject_(NSColor.blueColor()),
'CodeColor': NSArchiver.archivedDataWithRootObject_(NSColor.blackColor()),
}
defaults = NSUserDefaults.standardUserDefaults()
defaults.registerDefaults_(d)
self.textView.setFont_(self.font())
self._stderrColor = NSUnarchiver.unarchiveObjectWithData_(defaults['StderrColor'])
self._stdoutColor = NSUnarchiver.unarchiveObjectWithData_(defaults['StdoutColor'])
self._codeColor = NSUnarchiver.unarchiveObjectWithData_(defaults['CodeColor'])
self._executeWithRedirectedIO_args_kwds_(self._interp, (), {})
示例5: transformedValue_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def transformedValue_(self, priority):
if priority > 4:
return NSColor.redColor()
elif priority > 3:
return NSColor.orangeColor()
elif priority > 2:
return NSColor.blueColor()
elif priority > 1:
return NSColor.greenColor()
elif priority > 0:
return NSColor.brownColor()
else:
return NSColor.blackColor()
示例6: drawCellGlyph
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def drawCellGlyph(self):
layers = self.font.layers
for layerName in reversed(layers.layerOrder):
layer = layers[layerName]
if self.glyph.name not in layer:
continue
layerColor = None
if layer.color is not None:
layerColor = colorToNSColor(layer.color)
if layerColor is None:
layerColor = NSColor.blackColor()
glyph = layer[self.glyph.name]
path = glyph.getRepresentation("defconAppKit.NSBezierPath")
layerColor.set()
path.fill()
示例7: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def __init__(self):
self.w = Window((400, 400), "Layer Preview", minSize=(400, 300))
self.w.preview = GlyphLayerPreview((0, 0, -0, -30))
self.currentGlyphChanged()
self.w.useColor = CheckBox((10, -30, 100, 22), "Use Color:", callback=self.useColorCallback)
self.w.color = ColorWell((120, -35, 40, 30), color=NSColor.blackColor(), callback=self.colorCallback)
self.w.testInstall = Button((-170, -30, -10, 22), "Test Install Layers", callback=self.testInstallCallback)
addObserver(self, "currentGlyphChanged", "currentGlyphChanged")
self.setUpBaseWindowBehavior()
self.w.open()
示例8: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def __init__(self, posSize, text, callback=None):
# there must be a callback as it triggers the creation of the delegate
if callback is None:
callback = self._fallbackCallback
super(FeatureTextEditor, self).__init__(posSize, "", callback=callback)
self._nsObject.setHasHorizontalScroller_(True)
font = NSFont.fontWithName_size_("Monaco", 10)
self._textView.setFont_(font)
self._textView.setUsesFindPanel_(True)
## line numbers
#ruler = DefconAppKitLineNumberView.alloc().init()
#ruler.setClientView_(self._textView)
#self._nsObject.setVerticalRulerView_(ruler)
#self._nsObject.setHasHorizontalRuler_(False)
#self._nsObject.setHasVerticalRuler_(True)
#self._nsObject.setRulersVisible_(True)
#notificationCenter = NSNotificationCenter.defaultCenter()
#notificationCenter.addObserver_selector_name_object_(
# ruler, "clientViewSelectionChanged:", NSTextViewDidChangeSelectionNotification, self._textView
#)
# colors
self._mainColor = NSColor.blackColor()
self._commentColor = NSColor.colorWithCalibratedWhite_alpha_(.6, 1)
self._keywordColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, 0, 0, 1)
self._tokenColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, .4, 0, 1)
self._classNameColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, .8, 1)
self._includeColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, 0, .8, 1)
self._stringColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, .6, 0, 1)
# build the placard
placardW = 65
placardH = 16
self._placardJumps = []
self._placard = vanilla.Group((0, 0, placardW, placardH))
self._placard.featureJumpButton = PlacardPopUpButton((0, 0, placardW, placardH),
[], callback=self._placardFeatureSelectionCallback, sizeStyle="mini")
self._nsObject.setPlacard_(self._placard.getNSView())
# registed for syntax coloring notifications
self._programmaticallySettingText = False
delegate = self._textViewDelegate
delegate.vanillaWrapper = weakref.ref(self)
notificationCenter = NSNotificationCenter.defaultCenter()
notificationCenter.addObserver_selector_name_object_(
self._textViewDelegate, "textStorageDidProcessEditing", NSTextStorageDidProcessEditingNotification, self._textView.textStorage())
# set the text
self.set(text)
示例9: arrangeObjects_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def arrangeObjects_(self, objects):
"Filtering is not yet connected in IB!"
# XXX: This doesn't work yet, so disable
if self.shouldFilter:
self.shouldFilter = False
if not self.shouldFilter:
return super(GraphicsArrayController, self).arrangeObjects_(objects)
if self.filterColor is None:
self.filterColor = NSColor.blackColor().colorUsingColorSpaceName_(NSCalibratedRGBColorSpace)
filterHue = self.filterColor.hueComponent()
filteredObjects = []
for item in objects:
hue = item.color.hueComponent()
if ((fabs(hue - filterHue) < 0.05) or
(fabs(hue - filterHue) > 0.95) or
(item is self.newCircle)):
filteredObjects.append(item)
self.newCircle = None
return super(GraphicsArrayController, self).arrangeObjects_(filteredObjects)
示例10: drawRect_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def drawRect_(self, rect):
# drawing a full black rectangle
# set current drawing color
NSColor.blackColor().set()
#fill with black
NSRectFill(rect)
示例11: drawRect_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def drawRect_(self, rect): ## needs to be `drawRect_` -- nothing else
bounds = self.bounds()
# thisUPM = self._layer.parent.parent.upm
scaleFactor = self._scaleFactor
thisUPM = self._upm * scaleFactor
rectX, rectY, rectWidth, rectHeight = 0, 0, thisUPM, thisUPM
self.rect = rect
# self._layer.drawInFrame_(bounds) # used in Georgs GlyphView
try:
layerWidth = self._layer.width * scaleFactor
descender = self._layer.glyphMetrics()[3] * scaleFactor
## this order is important! Wont work the other way around
try: # pre Glyphs 2.3
bezierPathOnly = self._layer.copy().bezierPath() # Path Only
bezierPathWithComponents = self._layer.copyDecomposedLayer().bezierPath() # Path & Components
except: # Glyphs 2.3
bezierPathOnly = self._layer.copy().bezierPath # Path Only
bezierPathWithComponents = self._layer.copyDecomposedLayer().bezierPath # Path & Components
scale = NSAffineTransform.transform()
scale.translateXBy_yBy_( rectWidth/2 - (layerWidth / 2.0) + self._margin/2, -descender + self._margin/2 )
scale.scaleBy_( scaleFactor )
if bezierPathWithComponents:
bezierPathWithComponents.transformUsingAffineTransform_( scale )
if bezierPathOnly:
bezierPathOnly.transformUsingAffineTransform_( scale )
## DRAW COMPONENTS IN GRAY
NSColor.darkGrayColor().set() # lightGrayColor
bezierPathWithComponents.fill()
## CHANGE COLOR FOR NON-EXPORTED GLYPHS
thisGlyph = self._layer.parent
if thisGlyph.export:
NSColor.blackColor().set()
## DRAW ONLY PATH IN BLACK
if bezierPathOnly:
bezierPathOnly.fill()
else:
NSColor.orangeColor().set()
bezierPathWithComponents.fill()
# print self.bounds()
## AUTO-WIDTH LABEL
if self._layer.hasAlignedWidth():
paragraphStyle = NSMutableParagraphStyle.alloc().init()
paragraphStyle.setAlignment_(2) ## 0=L, 1=R, 2=C, 3=justified
attributes = {}
attributes[NSFontAttributeName] = NSFont.systemFontOfSize_(10)
attributes[NSForegroundColorAttributeName] = NSColor.lightGrayColor()
attributes[NSParagraphStyleAttributeName] = paragraphStyle
String = NSAttributedString.alloc().initWithString_attributes_("Auto-Width", attributes)
# String.drawAtPoint_((rectWidth, 0))
NSColor.redColor().set()
# NSRectFill(((0, 0), (self.rect.size.width, 15)))
String.drawInRect_(((0, 0), (self.rect.size.width, 15)))
except:
# pass
print traceback.format_exc()
示例12: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def __init__(self):
if len(AllFonts()) == 0:
print "Please open at least one font before using Ground Control"
return
# [windowWidth, maxWindowWidth, minWindowWidth]
self.xDimensions = [1200, 2880, 400]
# [windowHeight, maxWindowHeight, minWindowHeight headerHeight, footerHeight]
self.yDimensions = [600, 1800, 400, 50, 28]
self.allLinesHeight = self.yDimensions[0] - (self.yDimensions[3] + self.yDimensions[4])
self.lineNames = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth"]
self.pointSizeList = ["36", "48", "56", "64", "72", "96", "128", "160", "192", "256", "364", "512"]
self.trackingValuesList = ["%+d" % i for i in range(-100, -60, 20)] + ["%+d" % i for i in range(-60, -30, 10)] + ["%+d" % i for i in range(-30, -10, 6)] + ["%+d" % i for i in range(-10, 10, 2)] + ["%+d" % i for i in range(10, 30, 6)] + ["%+d" % i for i in range(30, 60, 10)] + ["%+d" % i for i in range(60, 120, 20)]
self.fontsOnBench = []
self.charMap = CurrentFont().getCharacterMapping()
self.glyphSet = ["A", "B", "C"]
self.lastModifiedFont = None
self.globalTrackingValue = 0
self.minNumberOfLines = 2
self.maxNumberOfLines = 9
self.selectedLine = None
self.showAllControls = False
self.displaySettings = {"Show Metrics": [[False, False] for i in range(self.maxNumberOfLines)], "Inverse": [[False, False] for i in range(self.maxNumberOfLines)], "Upside Down": [[False, False] for i in range(self.maxNumberOfLines)]}
self.baseColor = NSColor.blackColor()
self.selectionColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.3, .1, .1, 0.8)
self.w = Window((self.xDimensions[0], self.yDimensions[0]), "Ground Control " + GCVersion, maxSize=(self.xDimensions[1], self.yDimensions[1]), minSize=(self.xDimensions[2], self.yDimensions[2]))
self.w.header = Group((0, 0, -0, self.yDimensions[3]))
self.w.allLines = Group((0, self.w.header.getPosSize()[3], -0, self.allLinesHeight))
self.w.footer = Group((0, -self.yDimensions[4], -0, self.yDimensions[4]))
import os
if os.path.isfile("GroundControlPrefList.txt"):
with open("GroundControlPrefList.txt") as myfile:
prefList = myfile.read().split("\n")
else:
prefList = ["ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz", "HHH0HHH00HHH000HHH", "nnnonnnoonnnooonnn"]
self.w.header.inputText = ComboBox((10, 10, -320, 22),
prefList,
continuous = True,
completes = True,
callback = self.inputCallback)
self.w.header.pointSizePopUp = PopUpButton((-305, 10, 60, 22), self.pointSizeList, callback=self.pointSizePopUpCallback)
self.w.header.pointSizePopUp.setTitle("128")
self.w.header.globalTrackingPopUp = PopUpButton((-175, 10, 60, 22), self.trackingValuesList, callback=self.trackingPopUpCallback)
self.w.header.globalTrackingPopUp.setTitle("+0")
self.w.header.applyAllTrackingButton = Button((-110, 10, 100, 22), "Apply All", callback=self.ApplyAllTracking)
self.w.footer.toggleAllControlsButton = Button((-260, 7, 100, 14), "All Controls", sizeStyle="mini", callback=self.toggleAllLineControlsCallback)
self.w.footer.addLineButton = Button((-135, 7, 60, 14), "Add", sizeStyle="mini", callback=self.addBenchLine)
self.w.footer.removeLineButton = Button((-70, 7, 60, 14), "Remove", sizeStyle="mini", callback=self.removeLastBenchLine)
self.w.footer.options = Group((10, 5, -260, 18))
self.w.footer.options.fontName = TextBox((0, 2, 50, 18), "All", sizeStyle="small")
self.w.footer.options.showMetrics = CheckBox((50, 0, 90, 18), "Show Metrics", sizeStyle="small", callback=self.showMetricsCallback)
self.w.footer.options.inverse = CheckBox((150, 0, 60, 18), "Inverse", sizeStyle="small", callback=self.inverseCallback)
self.w.footer.options.upsideDown = CheckBox((220, 0, 90, 18), "Flip", sizeStyle="small", callback=self.flipCallback)
index = 0
for lineName in self.lineNames:
# One part of the object is Methods & Attributes
setattr(self.w.allLines, lineName + "MethAttr", BenchLine(index))
thisLineMethAttr = getattr(self.w.allLines, lineName + "MethAttr")
# The second part of the object corresponds to the Vanilla objects, MultiLineView, buttons and such
setattr(self.w.allLines, lineName + "Vanillas", thisLineMethAttr.display())
thisLineVanillas = getattr(self.w.allLines, lineName + "Vanillas")
thisLineVanillas.show(False)
thisLineMethAttr.setFontCombo(self.allFontsList())
thisLineMethAttr.setTrackingCombo(self.trackingValuesList)
index += 1
self.getFontsOnBench()
self.setBench()
addObserver(self, "_currentGlyphChanged", "currentGlyphChanged")
addObserver(self, "updateCurrentGlyphInView", "keyDown")
addObserver(self, "updateCurrentGlyphInView", "mouseDown")
addObserver(self, "updateCurrentGlyphInView", "mouseDragged")
addObserver(self, "updateFontsCallback", "fontDidOpen")
addObserver(self, "updateFontsCallback", "fontDidClose")
self.w.bind("resize", self.resizeWindowCallback)
self.w.open()
示例13: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
class Size:
""" A class representing dimensions in pixel of an object """
def __init__(self, width, height):
self.width = width
self.height = height
class Color:
""" A class representing a color """
def __init__(self, ns_color):
self.ns_color = ns_color
Color.BLACK = Color(NSColor.blackColor())
Color.BLUE = Color(NSColor.blueColor())
Color.BROWN = Color(NSColor.brownColor())
Color.CYAN = Color(NSColor.cyanColor())
Color.DARK_GRAY = Color(NSColor.darkGrayColor())
Color.GRAY = Color(NSColor.grayColor())
Color.GREEN = Color(NSColor.greenColor())
Color.MAGENTA = Color(NSColor.magentaColor())
Color.ORANGE = Color(NSColor.orangeColor())
Color.PURPLE = Color(NSColor.purpleColor())
Color.RED = Color(NSColor.redColor())
Color.WHITE = Color(NSColor.whiteColor())
Color.YELLOW = Color(NSColor.yellowColor())
class Font:
示例14: drawPreviewNeighBors
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def drawPreviewNeighBors(self, info):
if not RamsayStData.showPreview:
return
fillColor = NSColor.blackColor()
fillColor.set()
self._drawNeighborsGlyphs(info["glyph"], stroke=False)
示例15: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import blackColor [as 别名]
def __init__(self):
f = CurrentFont()
if f is None:
return
self.shapeColor = None
self.backgroundColor = None
self.extrapolateMinValue = 0
self.extrapolateMaxValue = 1
self.w = vanilla.Window((500, 600), "Responsive Lettering", minSize=(300,200))
self.w.preview = HTMLView((0,0,-0, -140))
self.w.exportButton = vanilla.Button((-150, -30, -10, 20), "Export SVG", callback=self.cbExport)
columnDescriptions = [
dict(title="Glyphname", key="name", width=125),
dict(title="Width", key="width", width=50),
dict(title="Height", key="height", width=50),
dict(title="Bounds?", key="bounds", width=75),
dict(title="Contours", key="contours", width=50),
dict(title="Points", key="points", width=50),
]
self.w.l = vanilla.List((0,-140,-0,-40), self.wrapGlyphs(), columnDescriptions=columnDescriptions, doubleClickCallback=self.callbackListClick)
self.w.t = vanilla.TextBox((70,-27,-160,20), "FontName", sizeStyle="small")
self.w.backgroundColorWell = vanilla.ColorWell((10,-30, 20, 20), callback=self.backgroundColorWellCallback, color=NSColor.blackColor())
self.w.shapeColorWell = vanilla.ColorWell((35,-30, 20, 20), callback=self.shapeColorWellCallback, color=NSColor.whiteColor())
self.w.bind("became main", self.windowBecameMainCallback)
self.setColorsFromLib()
self.update()
self.w.open()
self.cbMakePreview(None)