本文整理汇总了Python中kytten.widgets.Control类的典型用法代码示例。如果您正苦于以下问题:Python Control类的具体用法?Python Control怎么用?Python Control使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Control类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_gain_highlight
def on_gain_highlight(self):
Control.on_gain_highlight(self)
self.size(self.saved_dialog) # to set up the highlight
if self.highlight is not None:
self.highlight.update(self.x-self.menu.padding/2,
self.y,
self.width+self.menu.padding,
self.height)
示例2: layout
def layout(self, x, y):
Control.layout(self, x, y)
if self.swatch is not None:
width, height = self.swatch.get_needed_size(self.content_width, self.content_height)
self.swatch.update(self.x, self.y, width, height)
if self.vlist is not None:
self.vlist.vertices = self._get_vlist_vertices()
if self.swatch_label is not None:
self.swatch_label.layout(x + self.swatch.width + 4, y + (self.height - self.swatch_label.height) / 2)
示例3: __init__
def __init__(self, width, height, disabled=False):
"""
Blocks occupy a fixed width and height.
@param width Width
@param height Height
"""
Control.__init__(self, width=width, height=height, disabled=disabled)
self.color = None
self.vertex_list = None
self.is_dragging = False
示例4: delete
def delete(self):
Control.delete(self)
if self.texture_vlist is not None:
self.texture_vlist.delete()
self.texture_vlist = None
if self.resizer_vlist is not None:
self.resizer_vlist.delete()
self.resizer_vlist = None
if self.limits_vlist is not None:
self.limits_vlist.delete()
self.limits_vlist = None
self.texture_group = None
示例5: layout
def layout(self, x, y):
"""Places the vertex list at the new location.
@param x X coordinate of our lower left corner
@param y Y coordinate of our lower left corner
"""
Control.layout(self, x, y)
if not self.is_disabled():
num_points, self.vertex_list.vertices = self._get_vertices()
self.vertex_list.colors = self.color * num_points
else:
self.is_dragging = False
示例6: delete
def delete(self):
Control.delete(self)
if self.swatch_label is not None:
self.swatch_label.delete()
self.swatch_label = None
if self.swatch is not None:
self.swatch.delete()
self.swatch = None # deleted as part of layout
if self.vlist is not None:
self.vlist.delete()
self.vlist = None
self._delete_select_dialog()
示例7: __init__
def __init__(self, id, image, scale_size=None, anchor=ANCHOR_CENTER,
palette=None, disabled=False, padding=0):
Control.__init__(self, disabled=disabled)
self.id = id
self.image = image
self.scale_size = scale_size
self.anchor = anchor
self.palette = palette
self.sprite = None
self.background = None
self.highlight = None
self.is_selected = False
self.padding = padding
示例8: __init__
def __init__(self, texture, x=0, y=0, width=0, height=0, scale=1,
on_resize=None):
Control.__init__(self)
self.texture = texture
self.on_resize = on_resize
self.texture_group = None
self.texture_vlist = None
self.resizer_vlist = None
self.limits_vlist = None
self.region = [x, y, width, height]
self.limits = None
self.scale = scale
self.color = self.IMAGE_REGION_COLOR
self.is_dragging = False
self.corner = None
示例9: size
def size(self, dialog, scale):
"""Constructs a vertex list to draw a crossed square.
@param dialog The Dialog within which we are contained
"""
if dialog is None:
return
Control.size(self, dialog, scale)
if self.vertex_list is None and not self.is_disabled():
self.color = dialog.theme['gui_color']
num_points, vertices = self._get_vertices()
self.vertex_list = dialog.batch.add(num_points, gl.GL_LINES,
dialog.fg_group,
('v2i', vertices),
('c4B', self.color * num_points))
示例10: size
def size(self, dialog):
Control.size(self, dialog)
self.width = 2 * (self.RADIUS + self.BORDER)
self.height = self.width
if self.circle_vlist is None:
self.circle_vlist = dialog.batch.add(
4 * self.NUM_SEGMENTS,
gl.GL_QUADS,
dialog.fg_group,
("v2f", self._get_circle_vlist_vertices()),
("c4B", [255, 255, 255, 255] * (4 * self.NUM_SEGMENTS)),
)
if self.inner_circle_vlist is None:
self.inner_circle_vlist = dialog.batch.add(
3 * self.NUM_SEGMENTS,
gl.GL_TRIANGLES,
dialog.fg_group,
("v2f", self._get_inner_circle_vlist_vertices()),
("c4B", self.color * (3 * self.NUM_SEGMENTS)),
)
if self.inner_circle_bg_vlist is None:
self.inner_circle_bg_vlist = dialog.batch.add(
3 * self.NUM_SEGMENTS,
gl.GL_TRIANGLES,
dialog.bg_group,
("v2f", self._get_inner_circle_vlist_vertices()),
("c4B", self._get_inner_circle_bg_vlist_colors()),
)
if self.colors_vlist is None:
self.colors_vlist = dialog.batch.add(
4 * self.NUM_SEGMENTS,
gl.GL_QUADS,
dialog.fg_group,
("v2f", self._get_colors_vlist_vertices()),
("c3B", self._get_colors_vlist_colors()),
)
if self.triangle_vlist is None:
self.triangle_vlist = dialog.batch.add(
6,
gl.GL_TRIANGLES,
dialog.highlight_group,
("v2f", self._get_triangle_vlist_vertices()),
("c3B", self._get_triangle_vlist_colors()),
)
if self.crosshair is None:
self.crosshair = dialog.theme[self.path]["image"].generate(
[255, 255, 255, 255], dialog.batch, dialog.highlight_group
)
示例11: _get_controls
def _get_controls(self):
_, _, width, height = self.region
if width < 20 or height < 20:
return [(self, self.x - 8, self.x + self.width + 8,
self.y + self.height + 8, self.y - 8)]
else:
return Control._get_controls(self)
示例12: __init__
def __init__(self, color, width=16, height=16, id=None, on_select=None):
Control.__init__(self, id=id)
self.color = color
self.content_width = width
self.content_height = height
self.swatch_label = None
self.swatch = None
self.vlist = None
self.on_select = on_select
self.select_dialog = None
self.wheel = None
self.red_input = None
self.green_input = None
self.blue_input = None
self.slider = None
self.accept_button = None
self.cancel_button = None
示例13: size
def size(self, dialog):
Control.size(self, dialog)
self.width = self.texture.width * self.scale
self.height = self.texture.height * self.scale
if self.texture_vlist is None:
self.texture_group = pyglet.graphics.TextureGroup(
self.texture, dialog.fg_group)
self.texture_vlist = dialog.batch.add(4, gl.GL_QUADS,
self.texture_group,
('v2i', self._get_texture_vertices()),
('c4B', (255, 255, 255, 255) * 4),
('t3f', self.texture.tex_coords))
if self.resizer_vlist is None:
self.resizer_vlist = dialog.batch.add(40, gl.GL_LINES,
dialog.highlight_group,
('v2i', self._get_resizer_vertices()),
('c4B', self.color * 40))
if self.limits_vlist is None:
self.limits_vlist = dialog.batch.add(8, gl.GL_LINES,
dialog.highlight_group,
('v2i', self._get_limits_vertices()),
('c4B', (192, 192, 192, 255) * 8))
示例14: size
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.sprite is None:
if self.is_disabled():
opacity = 50
color = dialog.theme[path]['disabled_color']
else:
opacity = 255
color = dialog.theme[path]['text_color']
self.sprite = pyglet.sprite.Sprite(
self.image, batch=dialog.batch, group=dialog.fg_group)#, y=y, x=x, batch=self.tiles_batch)
self.sprite.opacity = opacity
if self.scale_size is not None:
self.sprite.scale = self.scale_size / float(self.sprite.width)
self.width = self.sprite.width + self.padding * 2
self.height = self.sprite.height + self.padding * 2
#~ 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_selected:
self.highlight = \
dialog.theme[path]['palette']['image'].generate(
dialog.theme[path]['input']['gui_color'],
dialog.batch,
dialog.highlight_group)
示例15: __init__
def __init__(self, color, id=None, on_select=None):
Control.__init__(self, id=id)
self.alpha = color[3]
self.tip_color = [0, 0, 0]
self.on_select = on_select
self.circle_vlist = None
self.inner_circle_vlist = None
self.inner_circle_bg_vlist = None
self.colors_vlist = None
self.triangle_vlist = None
self.crosshair = None
self.tri_angle = 0.0
self.point = (0, 0)
self.is_turning = False
self.is_dragging = False
self.center_x = 0
self.center_y = 0
self.pointer_i = 1.0
self.pointer_j = 0.0
self.vector_i = [0, 1]
self.vector_j = [1, 0]
self.point_a = [0, 0]
self.set_color(color)