【问题标题】:Dealing with NSRect in python在 python 中处理 NSRect
【发布时间】:2016-08-08 13:04:11
【问题描述】:

我有一个函数:

def getMediaBox(doc, pageNum):
    page = CGPDFDocumentGetPage(doc, pageNum)
    return CGPDFPageGetBoxRect(page, kCGPDFMediaBox)

返回:

<NSRect origin=<NSPoint x=0.0 y=0.0> size=<NSSize width=499.0 height=709.0>>

这是python可以做任何事情的数据类型吗? 括号是什么意思?理想情况下,我想查询和测试尺码。

有趣的是,CoreGraphics 似乎接受嵌套列表,例如 [[0,0],[499,709]] 当它需要一个 NSRect 时。

非常感谢:非常感谢您的帮助。

【问题讨论】:

  • 看来得用实例,比如CGRect的maxX。但是,我尝试过 x = mediaBox.maxX(self) 之类的东西,我得到:NSRect' object has no attribute 'maxX'

标签: python macos core-graphics


【解决方案1】:

您可以使用以下行查询 NSRect 对象:

x = CGRectGetWidth(mediaBox)
y = CGRectGetHeight(mediaBox)

【讨论】:

    猜你喜欢
    • 2016-06-21
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多