本文整理汇总了Python中AppKit.NSColor.colorWithWhite_alpha_方法的典型用法代码示例。如果您正苦于以下问题:Python NSColor.colorWithWhite_alpha_方法的具体用法?Python NSColor.colorWithWhite_alpha_怎么用?Python NSColor.colorWithWhite_alpha_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKit.NSColor
的用法示例。
在下文中一共展示了NSColor.colorWithWhite_alpha_方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: attr_string_fits_in_rect
# 需要导入模块: from AppKit import NSColor [as 别名]
# 或者: from AppKit.NSColor import colorWithWhite_alpha_ [as 别名]
return NSAttributedString.alloc().initWithString_attributes_(text, attrs)
def attr_string_fits_in_rect(attr_string, rect):
height = attr_string.boundingRectWithSize_options_(NSMakeSize(rect.size.width, 99999), NSStringDrawingUsesLineFragmentOrigin).size.height
return height <= rect.size.height
class TextView(NSView):
def drawRect_(self, rect):
rect = NSInsetRect(rect, 40, 40)
size = 50
stride = 10
while attr_string_fits_in_rect(attributed_text_at_size(text, size+stride), rect):
size += stride
attr = attributed_text_at_size(text, size)
attr.drawInRect_(rect)
window.setExcludedFromWindowsMenu_(True)
window.setOpaque_(False)
window.setBackgroundColor_(NSColor.colorWithWhite_alpha_(0, 0.7))
window.setAlphaValue_(0)
window.setCollectionBehavior_(NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary | NSWindowCollectionBehaviorIgnoresCycle)
window.setContentView_(TextView.new())
NSApp.activateIgnoringOtherApps_(True)
window.makeKeyAndOrderFront_(None)
from PyObjCTools import AppHelper
AppHelper.runEventLoop()