本文整理汇总了Python中AppKit.NSColor.redColor方法的典型用法代码示例。如果您正苦于以下问题:Python NSColor.redColor方法的具体用法?Python NSColor.redColor怎么用?Python NSColor.redColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKit.NSColor
的用法示例。
在下文中一共展示了NSColor.redColor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawRect_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [as 别名]
def drawRect_(self, rect):
if self.inLiveResize():
self._recalcSize()
from random import random
NSColor.redColor().set()
NSRectFill(self.bounds())
width, height = self.frame()[1]
w = width / 5
h = height / 5
for xI in range(5):
for yI in range(5):
x = xI * w
y = height - (yI * h) - h
r = ((x, y), (w, h))
NSColor.colorWithDeviceRed_green_blue_alpha_(random(), random(), random(), 1.0).set()
NSRectFill(r)
示例2: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [as 别名]
def __init__(self):
self.doMarkGlyphs = 0
self.doOverwrite = 1
self.sourceFontList = AllFonts()
self.destinationFontList = AllFonts()
self.source_font = self.sourceFontList[0]
self.destination_fonts = None
self.glyphs = None
self.mark = NSColor.redColor()
## create a window
self.w = Window((700, 500), "Copy Glyphs", minSize=(700, 500))
self.w.sourceTitle = TextBox((15, 20, 200, 20), "Source Font:")
self.w.sourceFont = PopUpButton((15, 42, -410, 20), [f.info.familyName + ' ' + f.info.styleName for f in self.sourceFontList], callback=self.sourceCallback)
self.w.glyphs = GlyphCollectionView((16, 70, -410, -65), initialMode="list", enableDelete=False, allowDrag=False, selectionCallback=self.glyphCallback)
self._sortGlyphs(self.source_font)
self.w.desTitle = TextBox((-400, 20, 200, 20), "Destination Fonts:")
self.w.destinationFonts = FontList((-400, 42, -15, -115), self.destinationFontList, selectionCallback=self.desCallback)
self.w.overwrite = CheckBox((-395, -105, 130, 22), "Overwrite glyphs", callback=self.overwriteCallback, value=self.doOverwrite)
self.w.markGlyphs = CheckBox((-395, -84, 100, 22), "Mark Glyphs", callback=self.markCallback, value=self.doMarkGlyphs)
self.w.copyButton = Button((-115, -40, 100, 20), 'Copy Glyphs', callback=self.copyCallback)
self.w.line = HorizontalLine((10, -50, -10, 1))
self._updateDest()
## open the window
self.w.open()
示例3: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [as 别名]
def __init__(self, drawGrid=False):
self.w = Window((600, 500), "", minSize=(300, 250))
grp = Group((0, 0, 0, 0))
grp.button = Button((10, 10, -10, 20), "Toggle", self.buttonCallback)
self.view1 = TestSplitSubview((0, 0, 0, 0), NSColor.redColor())
paneDescriptions2 = [
dict(view=self.view1, canCollapse=True, size=50, identifier="pane1"),
dict(view=grp, identifier="pane2"),
dict(view=TestSplitSubview((0, 0, 0, 0), NSColor.greenColor()), minSize=50, identifier="pane3"),
dict(view=TestSplitSubview((0, 0, 0, 0), NSColor.yellowColor()), identifier="pane4"),
]
self.nestedSplit = SplitView((0, 0, 0, 0), paneDescriptions2, isVertical=True)
paneDescriptions1 = [
dict(view=self.nestedSplit, identifier="pane5"),
dict(
view=TestSplitSubview((0, 0, 0, 0), NSColor.magentaColor()),
minSize=100,
size=100,
canCollapse=True,
identifier="pane6",
),
]
self.w.splitView = SplitView((10, 10, -10, -10), paneDescriptions1, isVertical=False)
if drawGrid:
self.drawGrid()
self.w.open()
示例4: linearGradient
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [as 别名]
def linearGradient(startPoint=None, endPoint=None, colors=None, locations=None):
global currentGradient
global currentFillColor
if colors is None:
colors = [NSColor.greenColor(), NSColor.redColor()]
if locations is None:
locations = [i / float(len(colors)-1) for i in range(len(colors))]
currentGradient = ("linear", startPoint, endPoint, colors, locations)
currentFillColor = None
示例5: check_signature_matcher
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [as 别名]
def check_signature_matcher(self, obj):
regex = obj.stringValue()
feedback = self.customSignatureMatcherFeedback
try:
re.compile(regex)
feedback.setColor_(NSColor.greenColor())
feedback.setToolTip_("")
except re.error, e:
feedback.setColor_(NSColor.redColor())
feedback.setToolTip_(str(e))
示例6: applicationDidFinishLaunching_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [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, (), {})
示例7: transformedValue_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [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()
示例8: initWithFrame_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [as 别名]
def initWithFrame_(self, frame):
self.center = (50.0, 50.0)
super(DotView, self).initWithFrame_(frame)
self.radius = 10.0
self.color = NSColor.redColor()
return self
示例9: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [as 别名]
def __init__(self):
self.color = "#FF0000"
self.w = vanilla.Window((500, 600), "LettError MathShape Exporter", minSize=(300,200))
self.w.preview = HTMLView((0,0,-0, -200))
self.w.exportButton = vanilla.Button((-150, -30, -10, 20), "Export", callback=self.cbExport)
self.w.previewButton = vanilla.Button((10, -30, -160, 20), "Preview", callback=self.cbMakePreview)
valueWidth = 50
columnDescriptions = [
dict(title="Glyphname", key="name", width=100),
dict(title="Width", key="width"),
dict(title="Bounds", key="bounds", width=100),
]
self.w.l = vanilla.List((0,-200,-0,-60), self.wrapGlyphs(), columnDescriptions=columnDescriptions)
self.w.t = vanilla.TextBox((40,-53,-5,20), "FontName", sizeStyle="small")
self.w.clr = vanilla.ColorWell((10,-55, 20, 20), callback=self.cbColor, color=NSColor.redColor())
self.update()
self.w.open()
示例10: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [as 别名]
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:
""" Text font """
def __init__(self, name, size):
self.ns_font = NSFont.fontWithName_size_(name, size)
class Sound:
""" A system sound """
def __init__(self, path):
示例11: __init__
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [as 别名]
def __init__(self, drawGrid=False):
self.w = Window((150, 180), "Misc. Test")
self.w.spinner1 = ProgressSpinner((10, 10, 32, 32), sizeStyle="regular")
self.w.spinner2 = ProgressSpinner((50, 10, 16, 16), sizeStyle="small")
self.w.bar1 = ProgressBar((10, 50, -10, 16))
self.w.bar2 = ProgressBar((10, 70, -10, 10), isIndeterminate=True, sizeStyle="small")
self.w.progressStartButton = Button((10, 90, -10, 20), "Start Progress", callback=self.startProgress)
self.w.colorWell = ColorWell((10, 130, -10, -10), callback=self.getCallback, color=NSColor.redColor())
if drawGrid:
self.drawGrid()
self.w.open()
示例12: drawRect_
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import redColor [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()