本文整理汇总了Python中widgets.Control.size方法的典型用法代码示例。如果您正苦于以下问题:Python Control.size方法的具体用法?Python Control.size怎么用?Python Control.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类widgets.Control
的用法示例。
在下文中一共展示了Control.size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: size
# 需要导入模块: from widgets import Control [as 别名]
# 或者: from widgets.Control import size [as 别名]
def size(self, dialog):
if dialog is None:
return
Control.size(self, dialog)
if not self.set_document_style:
self.do_set_document_style(dialog)
if self.content is None:
self.content = pyglet.text.layout.IncrementalTextLayout(
self.document,
self.content_width,
self.max_height,
multiline=True, batch=dialog.batch, group=dialog.fg_group)
if self.is_fixed_size or (self.max_height and
self.content.content_height > self.max_height):
self.height = self.max_height
else:
self.height = self.content.content_height
self.content.height = self.height
if self.always_show_scrollbar or \
(self.max_height and self.content.content_height > self.max_height):
if self.scrollbar is None:
self.scrollbar = VScrollbar(self.max_height)
self.scrollbar.size(dialog)
self.scrollbar.set(self.max_height, self.content.content_height)
if self.scrollbar is not None:
self.width = self.content_width + self.scrollbar.width
else:
self.width = self.content_width
示例2: size
# 需要导入模块: from widgets import Control [as 别名]
# 或者: from widgets.Control import size [as 别名]
def size(self, dialog):
"""
Creates slider components.
"""
if dialog is None:
return
Control.size(self, dialog)
if self.is_disabled():
color = dialog.theme['slider']['disabled_color']
else:
color = dialog.theme['slider']['gui_color']
if self.bar is None:
path = self.IMAGE_BAR
self.bar = dialog.theme[path]['image'].generate(
color,
dialog.batch, dialog.bg_group)
self.padding = dialog.theme[path]['padding']
if self.knob is None:
path = self.IMAGE_KNOB
self.knob = dialog.theme[path]['image'].generate(
color,
dialog.batch, dialog.highlight_group)
self.offset = dialog.theme[path]['offset']
if not self.markers and self.steps is not None:
path = self.IMAGE_STEP
for n in xrange(0, self.steps + 1):
self.markers.append(
dialog.theme[path]['image'].generate(
color,
dialog.batch, dialog.fg_group))
self.step_offset = dialog.theme[path]['offset']
width, height = self.bar.get_needed_size(self.min_width, 0)
left, right, top, bottom = self.padding
self.width = width + left + right
self.height = height + top + bottom
示例3: size
# 需要导入模块: from widgets import Control [as 别名]
# 或者: from widgets.Control import size [as 别名]
def size(self, dialog):
"""
Sizes the Checkbox. If necessary, creates the graphic elements.
@param dialog Dialog which contains the Checkbox
"""
if dialog is None:
return
Control.size(self, dialog)
if self.is_checked:
path = ['checkbox', 'checked']
else:
path = ['checkbox', 'unchecked']
if self.is_disabled():
color = dialog.theme[path]['disabled_color']
else:
color = dialog.theme[path]['gui_color']
if self.checkbox is None:
self.checkbox = dialog.theme[path]['image'].generate(
color,
dialog.batch, dialog.bg_group)
if self.highlight is None and self.is_highlight():
self.highlight = dialog.theme[path]['highlight']['image'].generate(
dialog.theme[path]['highlight_color'],
dialog.batch,
dialog.bg_group)
if self.label is None:
self.label = KyttenLabel(self.text,
font_name=dialog.theme[path]['font'],
font_size=dialog.theme[path]['font_size'],
color=color,
batch=dialog.batch, group=dialog.fg_group)
# Treat the height of the label as ascent + descent
font = self.label.document.get_font()
height = font.ascent - font.descent # descent is negative
self.width = self.checkbox.width + self.padding + \
self.label.content_width
self.height = max(self.checkbox.height, height)
示例4: size
# 需要导入模块: from widgets import Control [as 别名]
# 或者: from widgets.Control import size [as 别名]
def size(self, dialog):
"""
Sizes the Button. If necessary, creates the graphic elements.
@param dialog Dialog which contains the Button
"""
if dialog is None:
return
Control.size(self, dialog)
if self.is_pressed:
path = ['button', 'down']
else:
path = ['button', 'up']
if self.is_disabled():
color = dialog.theme[path]['disabled_color']
else:
color = dialog.theme[path]['gui_color']
if self.button is None:
self.button = dialog.theme[path]['image'].generate(
color,
dialog.batch, dialog.bg_group)
if self.highlight is None and self.is_highlight():
self.highlight = dialog.theme[path]['highlight']['image'].\
generate(dialog.theme[path]['highlight_color'],
dialog.batch,
dialog.bg_group)
if self.label is None:
self.label = KyttenLabel(self.text,
font_name=dialog.theme[path]['font'],
font_size=dialog.theme[path]['font_size'],
color=dialog.theme[path]['text_color'],
batch=dialog.batch, group=dialog.fg_group)
# Treat the height of the label as ascent + descent
font = self.label.document.get_font()
height = font.ascent - font.descent # descent is negative
self.width, self.height = self.button.get_needed_size(
self.label.content_width, height)
示例5: size
# 需要导入模块: from widgets import Control [as 别名]
# 或者: from widgets.Control import size [as 别名]
def size(self, dialog):
"""
Creates scrollbar components.
"""
if dialog is None:
return
Control.size(self, dialog)
dialog.set_wheel_hint(self)
if self.left is None:
if self.pos > 0.0:
path = self.IMAGE_LEFT
else:
path = self.IMAGE_LEFTMAX
self.left = dialog.theme[path]['image'].generate(
dialog.theme[path]['gui_color'],
dialog.batch, dialog.fg_group)
# Left button is our basis for minimum dimension
self.width, self.height = self.left.width, self.left.height
if self.space is None:
path = self.IMAGE_SPACE
self.space = dialog.theme[path]['image'].generate(
dialog.theme[path]['gui_color'],
dialog.batch, dialog.fg_group)
if self.bar is None:
path = self.IMAGE_BAR
self.bar = dialog.theme[path]['image'].generate(
dialog.theme[path]['gui_color'],
dialog.batch, dialog.fg_group)
if self.right is None:
if self.pos < 1.0 - self.bar_width:
path = self.IMAGE_RIGHT
else:
path = self.IMAGE_RIGHTMAX
self.right = dialog.theme[path]['image'].generate(
dialog.theme[path]['gui_color'],
dialog.batch, dialog.fg_group)
示例6: size
# 需要导入模块: from widgets import Control [as 别名]
# 或者: from widgets.Control import size [as 别名]
def size(self, dialog):
if dialog is None:
return
Control.size(self, dialog)
if self.is_selected:
path = ['menuoption', 'selection']
else:
path = ['menuoption']
if self.label is None:
if self.is_disabled():
color = dialog.theme[path]['disabled_color']
else:
color = dialog.theme[path]['text_color']
self.label = KyttenLabel(self.text,
color=color,
font_name=dialog.theme[path]['font'],
font_size=dialog.theme[path]['font_size'],
batch=dialog.batch,
group=dialog.fg_group)
font = self.label.document.get_font()
self.width = self.label.content_width
self.height = font.ascent - font.descent
if self.background is None:
if self.is_selected:
self.background = \
dialog.theme[path]['highlight']['image'].generate(
dialog.theme[path]['gui_color'],
dialog.batch,
dialog.bg_group)
if self.highlight is None:
if self.is_highlight():
self.highlight = \
dialog.theme[path]['highlight']['image'].generate(
dialog.theme[path]['highlight_color'],
dialog.batch,
dialog.highlight_group)
示例7: size
# 需要导入模块: from widgets import Control [as 别名]
# 或者: from widgets.Control import size [as 别名]
def size(self, dialog):
if dialog is None:
return
Control.size(self, dialog)
if self.is_disabled():
color = dialog.theme['input']['disabled_color']
else:
color = dialog.theme['input']['text_color']
# We set the style once. We shouldn't have to do so again because
# it's an UnformattedDocument.
if not self.document_style_set:
self.document.set_style(0, len(self.document.text),
dict(color=color,
font_name=dialog.theme['font'],
font_size=dialog.theme['font_size']))
self.document_style_set = True
# Calculate the needed size based on the font size
font = self.document.get_font(0)
height = font.ascent - font.descent
glyphs = font.get_glyphs('A_')
width = max([x.width for x in glyphs])
if self.abs_width == 0:
needed_width = self.length * width + 2 * self.padding
else:
needed_width = self.abs_width
needed_height = height + 2 * self.padding
if self.is_focus():
if self.text_layout is None:
self.text_layout = pyglet.text.layout.IncrementalTextLayout(
self.document, needed_width, needed_height,
multiline=False,
batch=dialog.batch, group=dialog.fg_group)
assert self.caret is None
assert self.label is None
if self.caret is None:
self.caret = pyglet.text.caret.Caret(
self.text_layout,
color=dialog.theme['input']['gui_color'][0:3])
self.caret.visible = True
self.caret.mark = 0
self.caret.position = len(self.document.text)
else:
if self.label is None:
self.label = KyttenInputLabel(self.document.text,
multiline=False,
width=self.width-self.padding*2,
color=color,
batch=dialog.batch,
group=dialog.fg_group)
assert self.text_layout is None and self.caret is None
if self.field is None:
if self.is_disabled():
color = dialog.theme['input']['disabled_color']
else:
color = dialog.theme['input']['gui_color']
self.field = dialog.theme['input']['image'].generate(
color=color,
batch=dialog.batch,
group=dialog.bg_group)
if self.highlight is None and self.is_highlight():
self.set_highlight()
self.width, self.height = self.field.get_needed_size(
needed_width, needed_height)