当前位置: 首页>>代码示例>>Python>>正文


Python NSFont.labelFontOfSize_方法代码示例

本文整理汇总了Python中AppKit.NSFont.labelFontOfSize_方法的典型用法代码示例。如果您正苦于以下问题:Python NSFont.labelFontOfSize_方法的具体用法?Python NSFont.labelFontOfSize_怎么用?Python NSFont.labelFontOfSize_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppKit.NSFont的用法示例。


在下文中一共展示了NSFont.labelFontOfSize_方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: drawTextAtPoint

# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import labelFontOfSize_ [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())
开发者ID:schriftgestalt,项目名称:GlyphsSDK,代码行数:29,代码来源:plugins.py

示例2: initWithFrame_view_size_name_captionText_

# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import labelFontOfSize_ [as 别名]
 def initWithFrame_view_size_name_captionText_(self, frame, view, size, name, caption_text):
     self = super(PictureView, self).initWithFrame_(frame)
     if not self:
         return
     _size = iW, iH = size
     xOffset = (frame.size[0] - iW) / 2.0
     yOffset = frame.size[1] - xOffset - iH
     self.dropboxViewFinalPosition = NSRect((xOffset, yOffset), _size)
     self.dropboxView = view
     self.dropboxView.setFrame_(self.dropboxViewFinalPosition)
     self.addSubview_(self.dropboxView)
     self.versionView = NSTextView.alloc().initWithFrame_(NSRect((0, 0), frame.size))
     self.versionView.setDrawsBackground_(NO)
     self.versionView.setEditable_(NO)
     self.versionView.setSelectable_(NO)
     self.versionView.textStorage().beginEditing()
     self.versionView.textStorage().mutableString().setString_(name)
     self.versionView.textStorage().setForegroundColor_(NSColor.whiteColor())
     self.versionView.textStorage().setFont_(NSFont.labelFontOfSize_(18))
     self.versionView.textStorage().endEditing()
     self.versionView.setAlignment_range_(NSCenterTextAlignment, NSMakeRange(0, self.versionView.string().length()))
     self.versionView.layoutManager().glyphRangeForTextContainer_(self.versionView.textContainer())
     textSize1 = self.versionView.layoutManager().usedRectForTextContainer_(self.versionView.textContainer()).size
     textAnchor1 = 0
     self.versionView2 = NSTextView.alloc().initWithFrame_(NSRect((0, 0), frame.size))
     self.versionView2.setDrawsBackground_(NO)
     self.versionView2.setEditable_(NO)
     self.versionView2.setSelectable_(NO)
     self.versionView2.textStorage().beginEditing()
     self.versionView2.textStorage().mutableString().setString_(u'"%s"' % (caption_text,))
     self.versionView2.textStorage().setForegroundColor_(NSColor.whiteColor())
     self.versionView2.textStorage().setFont_(NSFont.labelFontOfSize_(13))
     self.versionView2.textStorage().endEditing()
     self.versionView2.setAlignment_range_(NSCenterTextAlignment, NSMakeRange(0, self.versionView2.string().length()))
     self.versionView2.layoutManager().glyphRangeForTextContainer_(self.versionView2.textContainer())
     textSize2 = self.versionView2.layoutManager().usedRectForTextContainer_(self.versionView2.textContainer()).size
     textAnchor2 = 0
     bottomToLogoViewBaseline = yOffset
     textSeparation = (yOffset - textSize1[1] - textSize2[1]) * 0.2
     combinedHeight = textSize1[1] + textSize2[1] + textSeparation
     self.versionView2FinalPosition = NSRect(((frame.size[0] - textSize2[0]) / 2.0, (bottomToLogoViewBaseline - combinedHeight) / 2.0), (textSize2[0], textSize2[1] + textAnchor2))
     self.versionView2.setFrame_(self.versionView2FinalPosition)
     self.versionViewFinalPosition = NSRect(((frame.size[0] - textSize1[0]) / 2.0, self.versionView2.frame().origin[1] + textSeparation + self.versionView2.frame().size[1]), (textSize1[0], textSize1[1] + textAnchor1))
     self.versionView.setFrame_(self.versionViewFinalPosition)
     self.addSubview_(self.versionView)
     self.addSubview_(self.versionView2)
     return self
开发者ID:,项目名称:,代码行数:49,代码来源:

示例3: init

# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import labelFontOfSize_ [as 别名]
    def init(self):
        self = super(LineNumberNSRulerView, self).init()
        self._font = NSFont.labelFontOfSize_(NSFont.systemFontSizeForControlSize_(NSMiniControlSize))
        self._textColor = NSColor.colorWithCalibratedWhite_alpha_(.42, 1)
        self._rulerBackgroundColor = None

        self._lineIndices = None
        return self
开发者ID:typemytype,项目名称:drawbot,代码行数:10,代码来源:lineNumberRulerView.py

示例4: initWithFrame_imageDir_

# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import labelFontOfSize_ [as 别名]
    def initWithFrame_imageDir_(self, frame, imageDir):
        self = super(IntroView, self).initWithFrame_(frame)
        if not self:
            return None
        dropboxImage = NSImage.alloc().initWithContentsOfFile_(os.path.join(imageDir, u'box_stroked_150.png'))
        iW, iH = dropboxImage.size()
        newHeight = iH * 300.0 / iW
        self.dropboxViewFinalPosition = NSRect((25, frame.size[1] - 43 - newHeight), (300, newHeight))
        self.dropboxView = ShadowedImage.alloc().initWithFrame_(self.dropboxViewFinalPosition)
        self.dropboxView.setImageScaling_(NSScaleToFit)
        self.dropboxView.setImage_(dropboxImage)
        self.dropboxView.setShadowColor_(NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, 0, 0.5))
        self.dropboxView.setShadowOffset_((0.0, -2.0))
        self.dropboxView.setShadowBlurRadius_(5.0)
        logoImage = NSImage.alloc().initWithContentsOfFile_(os.path.join(imageDir, u'dropboxlogo.png'))
        iW, iH = logoImage.size()
        newHeight = iH * 300.0 / iW
        self.logoViewFinalPosition = NSRect((25, frame.size[1] - 334 - newHeight), (300, newHeight))
        self.logoView = NSImageView.alloc().initWithFrame_(self.logoViewFinalPosition)
        self.logoView.setImage_(logoImage)
        self.versionView = NSTextView.alloc().initWithFrame_(NSRect((0, 0), frame.size))
        self.versionView.setDrawsBackground_(NO)
        self.versionView.setEditable_(NO)
        self.versionView.setSelectable_(NO)
        self.versionView.textStorage().mutableString().setString_(u'Version %s' % build_number.VERSION)
        self.versionView.textStorage().setFont_(NSFont.labelFontOfSize_(14))
        self.versionView.layoutManager().glyphRangeForTextContainer_(self.versionView.textContainer())
        textSize1 = self.versionView.layoutManager().usedRectForTextContainer_(self.versionView.textContainer()).size
        textAnchor1 = 5
        self.versionView2 = NSTextView.alloc().initWithFrame_(NSRect((0, 0), frame.size))
        self.versionView2.setDrawsBackground_(NO)
        self.versionView2.setEditable_(NO)
        self.versionView2.setSelectable_(NO)
        self.versionView2.textStorage().mutableString().setString_(u'Copyright \xa9 2007-2010 Dropbox Inc.')
        self.versionView2.setFont_(NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSSmallControlSize)))
        self.versionView2.layoutManager().glyphRangeForTextContainer_(self.versionView2.textContainer())
        textSize2 = self.versionView2.layoutManager().usedRectForTextContainer_(self.versionView2.textContainer()).size
        textAnchor2 = 4
        bottomToLogoViewBaseline = self.logoView.frame().origin[1] + 17
        textSeparation = 10
        combinedHeight = textSize1[1] + textSize2[1] + textSeparation
        self.versionView2FinalPosition = NSRect(((frame.size[0] - textSize2[0]) / 2.0, (bottomToLogoViewBaseline - combinedHeight) / 2.0), (textSize2[0], textSize2[1] + textAnchor2))
        self.versionView2.setFrame_(self.versionView2FinalPosition)
        self.versionViewFinalPosition = NSRect(((frame.size[0] - textSize1[0]) / 2.0, self.versionView2.frame().origin[1] + textSeparation + self.versionView2.frame().size[1]), (textSize1[0], textSize1[1] + textAnchor1))
        self.versionView.setFrame_(self.versionViewFinalPosition)
        for _view in (self.dropboxView,
         self.logoView,
         self.versionView,
         self.versionView2):
            self.addSubview_(_view)

        return self
开发者ID:,项目名称:,代码行数:54,代码来源:

示例5: initWithFrame_

# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import labelFontOfSize_ [as 别名]
    def initWithFrame_(self, frame):
        self = super(GreetingsTo, self).initWithFrame_(frame)
        if not self:
            return
        self.timers = []
        for __text in ('greetings',
         'to',
         'AAPL',
         'GOOG',
         'MSFT',
         (':)', '_smile'),
         (':P', '_wink')):
            if type(__text) is str:
                _text = attr = __text
            else:
                _text, attr = __text
            vv = NSTextView.alloc().initWithFrame_(NSRect((0, 0), frame.size))
            vv.setDrawsBackground_(NO)
            vv.setEditable_(NO)
            vv.setSelectable_(NO)
            vv.setAlignment_range_(NSCenterTextAlignment, NSMakeRange(0, vv.string().length()))
            vv.textStorage().beginEditing()
            vv.textStorage().mutableString().setString_(_text)
            vv.textStorage().setFont_(NSFont.labelFontOfSize_(42 if _text in ('greetings', 'to') else 36))
            vv.textStorage().setForegroundColor_(NSColor.whiteColor())
            vv.textStorage().endEditing()
            vv.layoutManager().glyphRangeForTextContainer_(vv.textContainer())
            vv.setFrameSize_(vv.layoutManager().usedRectForTextContainer_(vv.textContainer()).size)
            setattr(self, attr, vv)
            vv.setHidden_(True)
            self.addSubview_(vv)

        self.blast_order = (self.greetings,
         self.to,
         self.AAPL,
         self.GOOG,
         self.MSFT,
         self._smile)
        self.greetings.setHidden_(False)
        self.greetings.setFrameOrigin_(((frame.size[0] - self.greetings.frame().size[0]) / 2.0, BASE_HEIGHT - 100))
        self.to.setFrameOrigin_(((frame.size[0] - self.to.frame().size[0]) / 2.0, BASE_HEIGHT - 100 - self.greetings.frame().size[1] - 20))
        offset = (frame.size[0] - (self.AAPL.frame().size[0] + self.GOOG.frame().size[0] + 60)) / 2.0
        self.AAPL_POS = (offset, 220)
        self.GOOG_POS = (WIDTH - self.GOOG.frame().size[0] - offset, 220)
        self.MSFT_POS = ((frame.size[0] - self.MSFT.frame().size[0]) / 2.0, 200 - self.AAPL.frame().size[1] - 80)
        self._wink.setFrameOrigin_(((frame.size[0] - self._wink.frame().size[0]) / 2.0, 200 - self._wink.frame().size[1]))
        self._smile.setFrameOrigin_(((frame.size[0] - self._wink.frame().size[0]) / 2.0, 200 - self._wink.frame().size[1]))
        return self
开发者ID:,项目名称:,代码行数:50,代码来源:

示例6: okCallback

# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import labelFontOfSize_ [as 别名]
        self._callback = None
        self.w.close()

    def okCallback(self, sender):
        self.w.close()
        value = self.w.lineInput.get()
        if value is not None:
            self._callback(value)
        self._callback = None


# -----------------
# Line Number Ruler
# -----------------

rulerFont = NSFont.labelFontOfSize_(NSFont.systemFontSizeForControlSize_(NSMiniControlSize))


class DefconAppKitLineNumberView(NSRulerView):

    def init(self):
        self = super(DefconAppKitLineNumberView, self).init()
        self._existingText = None
        self._existingClientViewWidth = None
        self._lineRects = []
        return self

    def dealloc(self):
        notificationCenter = NSNotificationCenter.defaultCenter()
        notificationCenter.removeObserver_(self)
        super(DefconAppKitLineNumberView, self).dealloc()
开发者ID:typemytype,项目名称:defconAppKit,代码行数:33,代码来源:featureTextEditor.py


注:本文中的AppKit.NSFont.labelFontOfSize_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。