本文整理匯總了Python中rect.Rect.height方法的典型用法代碼示例。如果您正苦於以下問題:Python Rect.height方法的具體用法?Python Rect.height怎麽用?Python Rect.height使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rect.Rect
的用法示例。
在下文中一共展示了Rect.height方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TextItem
# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import height [as 別名]
class TextItem(DocItem):
"""Prints some form of text"""
def __init__(self, text = '', style = 'body'):
DocItem.__init__(self)
self.text = text
self.style = style
def writePDF(self, pdf = None):
"""Write itself to a FPDF object.
Args:
pdf (FPDF): the FPDF object to write to.
"""
return self.getText()
def resizePDF(self, pdf, x = 0, y = 0):
"""Resize internal Rect according to current settings of pdf"""
width = pdf.get_string_width( self.getText() )
height = pdf.font_size_pt / pdf.k
self.rect = Rect( x, y, x + width, y + height )
def cellPDF(self, pdf, r = None):
if r:
x_shift = r.x0()
y_shift = r.y0()
else:
x_shift = 0.0
y_shift = 0.0
pdf.set_y( self.rect.y0() - y_shift )
pdf.set_x( self.rect.x0() - x_shift )
pdf.cell( self.rect.width(), self.rect.height(), self.getText() )
def refit(self):
"""Doesn't need to do anything as cellPDF uses self.rect to output the content"""
pass
示例2: MathColumn
# 需要導入模塊: from rect import Rect [as 別名]
# 或者: from rect.Rect import height [as 別名]
class MathColumn(MultiItem):
"""Container for inline maths"""
def __init__(self, *items):
MultiItem.__init__(self)
self.style = ('math-var',1)
for item in items:
self.appendItem(item)
def resizePDF(self, pdf, x = 0, y = 0):
self.rect = Rect(x,y,x,y)
for item in self.items:
self.setFontPDF(pdf, item)
item.resizePDF(pdf,x,y)
item.rect.translate(0,self.rect.height())
self.rect.unite(item.rect)
self.refit()