本文整理汇总了Python中singleton_store.Screen.px_to_text_with_unit方法的典型用法代码示例。如果您正苦于以下问题:Python Screen.px_to_text_with_unit方法的具体用法?Python Screen.px_to_text_with_unit怎么用?Python Screen.px_to_text_with_unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类singleton_store.Screen
的用法示例。
在下文中一共展示了Screen.px_to_text_with_unit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_package
# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_text_with_unit [as 别名]
def get_package( self, doc):
"""returns a DOM element describing the object in CDML,
doc is the parent document which is used for element creation
(the returned element is not inserted into the document)"""
pack = doc.createElement( 'circle')
x1, y1, x2, y2 = Screen.px_to_text_with_unit( self.paper.screen_to_real_coords( self.coords))
dom_extensions.setAttributes( pack, (('x1', x1),
('y1', y1),
('x2', x2),
('y2', y2),
('area_color', self.area_color),
('line_color', self.line_color),
('width', str( self.line_width))))
return pack
示例2: get_package
# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_text_with_unit [as 别名]
def get_package( self, doc):
"""returns a DOM element describing the object in CDML,
doc is the parent document which is used for element creation
(the returned element is not inserted into the document)"""
pls = doc.createElement('plus')
pls.setAttribute( 'id', self.id)
x, y = Screen.px_to_text_with_unit( (self.x, self.y))
dom_extensions.elementUnder( pls, 'point', (('x', x),
('y', y)))
pls.setAttribute('font_size', str( self.font_size))
if self.line_color != '#000':
pls.setAttribute( 'color', self.line_color)
if self.area_color != '#ffffff':
pls.setAttribute( 'background-color', self.area_color)
return pls
示例3: construct_dom_tree
# 需要导入模块: from singleton_store import Screen [as 别名]
# 或者: from singleton_store.Screen import px_to_text_with_unit [as 别名]
def construct_dom_tree( self, top_levels):
"""constructs the SVG dom from all top_levels"""
# the constants
border_size = self.paper.get_paper_property( 'crop_margin')
# converter
px_to_cm_txt = lambda x: Screen.px_to_text_with_unit( x, unit="cm", round_to=5)
px_to_mm_txt = lambda x: Screen.px_to_text_with_unit( x, unit="mm", round_to=5)
# the code
self._id = 0
doc = self.document
self.top = dom_extensions.elementUnder( doc, "svg", attributes=(("xmlns", "http://www.w3.org/2000/svg"),
("version", "1.0")))
if self.full_size:
sx = self.paper.get_paper_property( 'size_x')
sy = self.paper.get_paper_property( 'size_y')
dom_extensions.setAttributes( self.top, (("width", '%fmm' % sx),
("height", '%fmm' % sy),
('viewBox', '0 0 %d %d' % (Screen.mm_to_px(sx), Screen.mm_to_px(sy)))))
else:
items = list( self.paper.find_all())
items.remove( self.paper.background)
x1, y1, x2, y2 = self.paper.list_bbox( items)
w = px_to_mm_txt( x2 -x1 +2*border_size)
h = px_to_mm_txt( y2 -y1 +2*border_size)
bx2, by2 = x2-x1+2*border_size, y2-y1+2*border_size
dom_extensions.setAttributes( self.top, (("width", w),
("height", h),
("viewBox",'0 0 %d %d' % ( bx2, by2))))
self.group = dom_extensions.elementUnder( self.top, 'g',
(('font-size', '12pt'),
('font-family', 'Helvetica'),
('stroke-linecap', 'round')))
if not self.full_size:
self.group.setAttribute( 'transform', 'translate(%d,%d)' % (-x1+border_size, -y1+border_size))
# sort the top_levels according to paper.stack
cs = []
for c in self.paper.stack:
if c in top_levels:
cs.append( c)
for o in cs:
if o.object_type == 'molecule':
for b in o.bonds:
self.add_bond( b)
for a in o.atoms:
self.add_atom( a)
elif o.object_type == 'arrow':
self.add_arrow( o)
elif o.object_type == 'text':
self.add_text( o)
elif o.object_type == 'plus':
self.add_plus( o)
elif o.object_type in data.vector_graphics_types:
if o.object_type == 'rect':
self.add_rect( o)
elif o.object_type == 'oval':
self.add_oval( o)
elif o.object_type == 'polygon':
self.add_polygon( o)
elif o.object_type == 'polyline':
self.add_polyline( o)