本文整理汇总了Python中AppKit.NSColor.whiteColor方法的典型用法代码示例。如果您正苦于以下问题:Python NSColor.whiteColor方法的具体用法?Python NSColor.whiteColor怎么用?Python NSColor.whiteColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKit.NSColor
的用法示例。
在下文中一共展示了NSColor.whiteColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawWithFrame_inView_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def drawWithFrame_inView_(self, frame, view):
row = view.selectedRow()
columnCount = len(view.tableColumns())
frames = [view.frameOfCellAtColumn_row_(i, row) for i in xrange(columnCount)]
selected = frame in frames
(x, y), (w, h) = frame
y += 1
h -= 2
if selected:
pillTextAttributes[NSForegroundColorAttributeName] = self._color
foregroundColor = NSColor.whiteColor()
else:
pillTextAttributes[NSForegroundColorAttributeName] = NSColor.whiteColor()
foregroundColor = self._color
text = self.title()
text = NSAttributedString.alloc().initWithString_attributes_(text, pillTextAttributes)
textRect = text.boundingRectWithSize_options_((w, h), 0)
(textX, textY), (textW, textH) = textRect
foregroundColor.set()
path = NSBezierPath.bezierPath()
radius = h / 2.0
path.appendBezierPathWithOvalInRect_(((x, y), (h, h)))
path.appendBezierPathWithOvalInRect_(((x + textW - 1, y), (h, h)))
path.appendBezierPathWithRect_(((x + radius, y), (textW - 1, h)))
path.fill()
text.drawInRect_(((x + radius, y), (textW, textH)))
示例2: drawRect_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def drawRect_(self, rect):
NSColor.whiteColor().set()
NSRectFill(self.bounds())
origin = (self.center[0]-self.radius, self.center[1]-self.radius)
size = (2 * self.radius, 2 * self.radius)
dotRect = (origin, size)
self.color.set()
NSBezierPath.bezierPathWithOvalInRect_(dotRect).fill()
示例3: drawRect_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def drawRect_(self, rect):
printB("drawRect", rect )
"""."""
NSColor.whiteColor().set()
NSBezierPath.fillRect_(rect)
self.itemColor().set()
NSBezierPath.fillRect_(self.calculatedItemBounds())
示例4: drawRect_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def drawRect_(self, rect):
frame = self.frame()
NSColor.whiteColor().set()
NSRectFill(frame)
try:
if self._glyph is not None:
if self._glyph.__class__.__name__ in ("NSKVONotifying_GSLayer", "GSLayer"):
layer = self._glyph
elif isinstance(self._glyph, RGlyph):
layer = self._glyph._layer
if layer:
layer.drawInFrame_(frame)
except:
print traceback.format_exc()
示例5: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def __init__(self, posSize, layer = None, backgroundColor = None):
self._setupView(self.nsViewClass, posSize)
self.layer = layer
if backgroundColor != None:
self.backgroundColor = backgroundColor
else:
self.backgroundColor = NSColor.whiteColor()
示例6: attributed_text_at_size
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def attributed_text_at_size(text, size):
paragraph_style = NSMutableParagraphStyle.new()
paragraph_style.setAlignment_(NSCenterTextAlignment)
attrs = {
NSParagraphStyleAttributeName: paragraph_style,
NSFontAttributeName: NSFont.boldSystemFontOfSize_(size),
NSForegroundColorAttributeName: NSColor.whiteColor()
}
return NSAttributedString.alloc().initWithString_attributes_(text, attrs)
示例7: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def __init__(self):
self.modifiedGlyph = None
self.w = FloatingWindow((400, 170), "Corner Tool")
self.w.getNSWindow().setBackgroundColor_(NSColor.whiteColor())
self.modes = ["Break", "Build", "Pit"]
self.objectTypes = {"Build": "Segment", "Break": "Corner point", "Pit": "Corner point"}
self.parameters = {
"radius": VanillaSingleValueParameter("radius", 20, (-200, 200), numType="int"),
"roundness": VanillaSingleValueParameter("roundness", 1.25, (0, 4), numType="float"),
"depth": VanillaSingleValueParameter("depth", 30, (-100, 100), numType="int"),
"breadth": VanillaSingleValueParameter("breadth", 30, (0, 150), numType="int"),
"bottom": VanillaSingleValueParameter("bottom", 5, (0, 40), numType="int"),
}
self.currentMode = "Break"
self.previewGlyph = None
self.w.modes = RadioGroup((15, 15, 70, -15), self.modes, callback=self.changeMode)
for i, mode in enumerate(self.modes):
setattr(self.w, mode, Group((120, 15, -15, -15)))
modeGroup = getattr(self.w, mode)
modeGroup.apply = GradientButton((-35, 0, -0, -0), title=u">", callback=self.apply)
modeGroup.infoBox = Box((0, 0, -50, 35))
modeGroup.info = TextBox((10, 8, -50, 20), "No selection")
if i > 0:
modeGroup.show(False)
self.w.Break.radius = ParameterSliderTextInput(
self.parameters["radius"], (0, 60, -25, 25), title="Radius", callback=self.makePreviewGlyph
)
self.w.Break.roundness = ParameterSliderTextInput(
self.parameters["roundness"], (0, 95, -25, 25), title="Roundness", callback=self.makePreviewGlyph
)
self.w.Pit.depth = ParameterSliderTextInput(
self.parameters["depth"], (0, 50, -25, 25), title="Depth", callback=self.makePreviewGlyph
)
self.w.Pit.breadth = ParameterSliderTextInput(
self.parameters["breadth"], (0, 80, -25, 25), title="Breadth", callback=self.makePreviewGlyph
)
self.w.Pit.bottom = ParameterSliderTextInput(
self.parameters["bottom"], (0, 110, -25, 25), title="bottom", callback=self.makePreviewGlyph
)
addObserver(self, "preview", "draw")
addObserver(self, "preview", "drawInactive")
addObserver(self, "previewSolid", "drawPreview")
addObserver(self, "makePreviewGlyph", "mouseDown")
addObserver(self, "makePreviewGlyph", "mouseDragged")
addObserver(self, "makePreviewGlyph", "keyDown")
addObserver(self, "makePreviewGlyph", "keyUp")
addObserver(self, "setControls", "mouseUp")
addObserver(self, "setControls", "selectAll")
addObserver(self, "setControls", "deselectAll")
addObserver(self, "setControls", "currentGlyphChanged")
self.w.bind("close", self.windowClose)
self.setControls()
self.w.open()
示例8: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def __init__(self, dimensions, font):
font_name = font.info.familyName
attribution = "{} by {}".format(font_name, font.info.designer)
attribution_attributes = {
NSFontAttributeName: NSFont.systemFontOfSize_(NSFont.systemFontSize()),
NSForegroundColorAttributeName: NSColor.whiteColor()
}
formatted_attribution = NSMutableAttributedString.alloc().initWithString_attributes_(attribution, attribution_attributes)
formatted_attribution.addAttribute_value_range_(NSFontAttributeName, NSFont.boldSystemFontOfSize_(NSFont.systemFontSize()), [0, len(font_name)])
super(AttributionText, self).__init__(dimensions, formatted_attribution)
示例9: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def __init__(self):
self.modifiedGlyph = None
self.w = FloatingWindow((400, 170), 'Corner Tool')
self.w.getNSWindow().setBackgroundColor_(NSColor.whiteColor())
self.modes = ['Break', 'Build','Pit']
self.objectTypes = {'Build':'Segment', 'Break':'Corner point', 'Pit':'Corner point'}
self.parameters = {
'radius': VanillaSingleValueParameter('radius', 20, (-200, 200), numType='int'),
'roundness': VanillaSingleValueParameter('roundness', 1.25, (0, 4), numType='float'),
'depth': VanillaSingleValueParameter('depth', 30, (-100, 100), numType='int'),
'breadth': VanillaSingleValueParameter('breadth', 30, (0, 150), numType='int'),
'bottom': VanillaSingleValueParameter('bottom', 5, (0, 40), numType='int')
}
self.currentMode = 'Break'
self.previewGlyph = None
self.w.modes = RadioGroup((15, 15, 70, -15), self.modes, callback=self.changeMode)
for i, mode in enumerate(self.modes):
setattr(self.w, mode, Group((120, 15, -15, -15)))
modeGroup = getattr(self.w, mode)
modeGroup.apply = GradientButton((-35, 0, -0, -0), title=u'>', callback=self.apply)
modeGroup.infoBox = Box((0, 0, -50, 35))
modeGroup.info = TextBox((10, 8, -50, 20), 'No selection')
if i > 0: modeGroup.show(False)
self.w.Break.radius = ParameterSliderTextInput(self.parameters['radius'], (0, 60, -25, 25), title='Radius', callback=self.makePreviewGlyph)
self.w.Break.roundness = ParameterSliderTextInput(self.parameters['roundness'], (0, 95, -25, 25), title='Roundness', callback=self.makePreviewGlyph)
self.w.Pit.depth = ParameterSliderTextInput(self.parameters['depth'], (0, 50, -25, 25), title='Depth', callback=self.makePreviewGlyph)
self.w.Pit.breadth = ParameterSliderTextInput(self.parameters['breadth'], (0, 80, -25, 25), title='Breadth', callback=self.makePreviewGlyph)
self.w.Pit.bottom = ParameterSliderTextInput(self.parameters['bottom'], (0, 110, -25, 25), title='bottom', callback=self.makePreviewGlyph)
addObserver(self, 'preview', 'draw')
addObserver(self, 'preview', 'drawInactive')
addObserver(self, 'makePreviewGlyph', 'mouseDown')
addObserver(self, 'makePreviewGlyph', 'mouseDragged')
addObserver(self, 'makePreviewGlyph', 'keyDown')
addObserver(self, 'makePreviewGlyph', 'keyUp')
addObserver(self, 'setControls', 'mouseUp')
addObserver(self, 'setControls', 'selectAll')
addObserver(self, 'setControls', 'deselectAll')
addObserver(self, 'setControls', 'currentGlyphChanged')
self.w.bind('close', self.windowClose)
self.setControls()
self.w.open()
示例10: init
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def init(self):
self = super(DefconAppKitGlyphNSView, self).init()
self._glyph = None
# drawing attributes
self._layerDrawingAttributes = {}
self._fallbackDrawingAttributes = dict(
showGlyphFill=True,
showGlyphStroke=True,
showGlyphOnCurvePoints=True,
showGlyphStartPoints=True,
showGlyphOffCurvePoints=False,
showGlyphPointCoordinates=False,
showGlyphAnchors=True,
showGlyphImage=False,
showGlyphMargins=True,
showFontVerticalMetrics=True,
showFontVerticalMetricsTitles=True,
showFontPostscriptBlues=False,
showFontPostscriptFamilyBlues=False
)
# cached vertical metrics
self._unitsPerEm = 1000
self._descender = -250
self._capHeight = 750
self._ascender = 750
# drawing data cache
self._drawingRect = None
self._fitToFrame = None
self._scale = 1.0
self._inverseScale = 0.1
self._impliedPointSize = 1000
# drawing calculation
self._centerVertically = True
self._centerHorizontally = True
self._noPointSizePadding = 200
self._verticalCenterYBuffer = 0
self._backgroundColor = NSColor.whiteColor()
return self
示例11: init
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def init(self):
self = super(DefconAppKitGlyphLineNSView, self).init()
self._showLayers = False
self._layerDrawingAttributes = {}
self._fallbackDrawingAttributes = dict(
showGlyphFill=True,
showGlyphStroke=False,
showGlyphOnCurvePoints=False,
showGlyphStartPoints=False,
showGlyphOffCurvePoints=False,
showGlyphPointCoordinates=False,
showGlyphAnchors=False,
showGlyphImage=False,
showGlyphMargins=False,
showFontVerticalMetrics=False,
showFontPostscriptBlues=False,
showFontPostscriptFamilyBlues=False
)
self._glyphRecords = []
self._alternateRects = {}
self._currentZeroZeroPoint = NSPoint(0, 0)
self._rightToLeft = False
self._pointSize = 150
self._impliedPointSize = 150
self._scale = 1.0
self._inverseScale = 0.1
self._upm = 1000
self._descender = -250
self._bufferLeft = self._bufferRight = self._bufferBottom = self._bufferTop = 15
self._fitToFrame = None
self._backgroundColor = NSColor.whiteColor()
self._glyphColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, 0, 1)
self._alternateHighlightColor = defaultAlternateHighlightColor
self._notdefBackgroundColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(1, 0, 0, .25)
return self
示例12: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def __init__(self, posSize, pointSize=100, rightToLeft=False, applyKerning=False,
glyphColor=None, backgroundColor=None, alternateHighlightColor=None,
autohideScrollers=True, showPointSizePlacard=False):
if glyphColor is None:
glyphColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, 0, 1)
if backgroundColor is None:
backgroundColor = NSColor.whiteColor()
if alternateHighlightColor is None:
alternateHighlightColor = defaultAlternateHighlightColor
self._applyKerning = applyKerning
self._glyphLineView = self.glyphLineViewClass.alloc().init()
self._glyphLineView.setPointSize_(pointSize)
self._glyphLineView.setRightToLeft_(rightToLeft)
self._glyphLineView.setGlyphColor_(glyphColor)
self._glyphLineView.setBackgroundColor_(backgroundColor)
self._glyphLineView.setAlternateHighlightColor_(alternateHighlightColor)
self._glyphLineView.vanillaWrapper = weakref.ref(self)
# don't autohide if the placard is to be visible.
# bad things will happen if this is not the case.
if showPointSizePlacard:
autohideScrollers = False
# setup the scroll view
super(GlyphLineView, self).__init__(posSize, self._glyphLineView, autohidesScrollers=autohideScrollers, backgroundColor=backgroundColor)
# placard
if showPointSizePlacard:
self._pointSizes = ["Auto"] + [str(i) for i in pointSizes]
placardW = 55
placardH = 16
self._placard = vanilla.Group((0, 0, placardW, placardH))
self._placard.button = PlacardPopUpButton((0, 0, placardW, placardH),
self._pointSizes, callback=self._placardSelection, sizeStyle="mini")
self.setPlacard(self._placard)
pointSize = str(pointSize)
if pointSize in self._pointSizes:
index = self._pointSizes.index(pointSize)
self._placard.button.set(index)
示例13: GlyphCellFactory
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
from AppKit import NSColor, NSGraphicsContext, NSForegroundColorAttributeName, NSAttributedString, NSFont, \
NSFontAttributeName, NSAffineTransform, NSRectFill, NSRectFillListUsingOperation, NSImage, NSParagraphStyleAttributeName, \
NSBezierPath, NSMutableParagraphStyle, NSCenterTextAlignment, NSLineBreakByTruncatingMiddle, NSCompositeSourceOver
from defconAppKit.tools.drawing import colorToNSColor
GlyphCellHeaderHeight = 14
GlyphCellMinHeightForHeader = 40
cellBackgroundColor = NSColor.whiteColor()
cellHeaderBaseColor = NSColor.colorWithCalibratedWhite_alpha_(0.968, 1.0)
cellHeaderHighlightColor = NSColor.colorWithCalibratedWhite_alpha_(0.98, 1.0)
cellHeaderLineColor = NSColor.colorWithCalibratedWhite_alpha_(0, .2)
cellMetricsLineColor = NSColor.colorWithCalibratedWhite_alpha_(0, .08)
cellMetricsFillColor = NSColor.colorWithCalibratedWhite_alpha_(0, .08)
def GlyphCellFactory(glyph, width, height, drawHeader=False, drawMetrics=False):
obj = GlyphCellFactoryDrawingController(glyph=glyph, font=glyph.font, width=width, height=height, drawHeader=drawHeader, drawMetrics=drawMetrics)
return obj.getImage()
class GlyphCellFactoryDrawingController(object):
"""
This draws the cell with the layers stacked in this order:
------------------
header text
------------------
header background
------------------
foreground
示例14: PlacardScrollView
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
class PlacardScrollView(vanilla.ScrollView):
nsScrollViewClass = DefconAppKitPlacardNSScrollView
def setPlacard(self, placard):
if isinstance(placard, vanilla.VanillaBaseObject):
placard = placard.getNSView()
self._nsObject.setPlacard_(placard)
# -------------
# Button Colors
# -------------
placardGradientColor1 = NSColor.whiteColor()
placardGradientColor2 = NSColor.colorWithCalibratedWhite_alpha_(.9, 1)
placardGradientColorFallback = NSColor.colorWithCalibratedWhite_alpha_(.95, 1)
# ----------------
# Segmented Button
# ----------------
class DefconAppKitPlacardNSSegmentedCell(NSSegmentedCell):
def drawingRectForBounds_(self, rect):
return rect
def cellSizeForBounds_(self, rect):
return rect.size
示例15: WhiteText
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import whiteColor [as 别名]
def WhiteText(string):
attributes = {
NSForegroundColorAttributeName: NSColor.whiteColor()
}
return NSAttributedString.alloc().initWithString_attributes_(string, attributes)