本文整理汇总了Python中widget.Widget._allocate方法的典型用法代码示例。如果您正苦于以下问题:Python Widget._allocate方法的具体用法?Python Widget._allocate怎么用?Python Widget._allocate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类widget.Widget
的用法示例。
在下文中一共展示了Widget._allocate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _allocate
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import _allocate [as 别名]
def _allocate(self, width, height):
Widget._allocate(self, width, height)
if self._deleted:
return
label = self._label
style = self._style
p = style.padding
halign = style.halign
valign = style.valign
content_width = self.width-p[2]-p[3]
content_height = self.height-p[0]-p[1]
label.x = int(self.x+p[2]+(content_width-label.content_width)*halign)
label.y = int(self.y-p[0]-(content_height-label.content_height)*valign)
示例2: _allocate
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import _allocate [as 别名]
def _allocate(self, width, height):
''' Set size allocation.
**Parameters**
`width` : int
Width in pixels
`height` : int
Height in pixels
'''
if self._deleted:
return
Widget._allocate(self, width, height)
text = self._text
style = self._style
padding = style.padding
content_width = self.width-padding[2]-padding[3]
content_height = self.height-padding[0]-padding[1]
label = self._label
layout = self._layout
if label:
# Ellipsize text if necessary
# Dear Glydget, I do not want you to fuck up my content strings. Sincerely, Steve.
if label.content_width > content_width and False:
n,m = 1, len(text)
while (m-n) > 1:
i = (n+m)//2
if i < (len(text)-1):
label.text = text[:i]+u'…'
else:
label.text = text
if label.content_width < content_width:
n = i
else:
m = i
if n < (len(text)-2):
label.text = text[:n]+u'…'
else:
label.text = text
label.x = int(self.x+padding[2])
label.y = int(self.y-padding[0])
elif layout:
layout.width = content_width
layout.height = self._minimum_size[1]
layout.x = int(self.x+padding[2])
layout.y = int(self.y-padding[0])
示例3: _allocate
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import _allocate [as 别名]
def _allocate(self, width, height):
''' Set size allocation.
**Parameters**
`width` : int
Width in pixels
`height` : int
Height in pixels
'''
Widget._allocate(self, width, height)
if self._deleted:
return
label = self._label
style = self._style
p = style.padding
halign = style.halign
valign = style.valign
content_width = self.width-p[2]-p[3]
content_height = self.height-p[0]-p[1]
label.x = int(self.x+p[2]+(content_width-label.content_width)*halign)
label.y = int(self.y-p[0]-(content_height-label.content_height)*valign)
示例4: _allocate
# 需要导入模块: from widget import Widget [as 别名]
# 或者: from widget.Widget import _allocate [as 别名]
def _allocate(self, width, height):
if self._deleted:
return
Widget._allocate(self, width, height)
text = self._text
style = self._style
padding = style.padding
content_width = self.width - padding[2] - padding[3]
content_height = self.height - padding[0] - padding[1]
label = self._label
layout = self._layout
if label:
# Ellipsize text if necessary
if label.content_width > content_width:
n, m = 1, len(text)
while (m - n) > 1:
i = (n + m) // 2
if i < (len(text) - 1):
label.text = text[:i] + u"…"
else:
label.text = text
if label.content_width < content_width:
n = i
else:
m = i
if n < (len(text) - 2):
label.text = text[:n] + u"…"
else:
label.text = text
label.x = int(self.x + padding[2])
label.y = int(self.y - padding[0])
elif layout:
layout.width = content_width
layout.height = self._minimum_size[1]
layout.x = int(self.x + padding[2])
layout.y = int(self.y - padding[0])