本文整理汇总了Python中frame.Frame.toggle方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.toggle方法的具体用法?Python Frame.toggle怎么用?Python Frame.toggle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frame.Frame
的用法示例。
在下文中一共展示了Frame.toggle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Dialogue
# 需要导入模块: from frame import Frame [as 别名]
# 或者: from frame.Frame import toggle [as 别名]
class Dialogue(object):
def __init__(self, title, message, buttons={}):
frame_title = "dialogue_{0}".format(title)
self.frame = Frame(frame_title, x, y, width, height, z)
self.frame.title = title
self.buttons = buttons
self.frame.closeable = True
background = pygame.surface.Surface((width, height))
background.blit(gradients.vertical((width, height),
colors.OPAQUE_GRAY,
colors.OPAQUE_BLACK), (0, 0))
self.frame.background = background
textbox = self.frame.background.subsurface(pygame.Rect(50, 40,
text_width,
text_height))
button_rect = pygame.Rect(25, 60 + text_height, button_width, 25)
button_area = self.frame.background.subsurface(button_rect)
textrect(message, ui.typography["title"], text_width, colors.WHITE,
surface=textbox)
created_buttons = []
for button_create in buttons:
created_buttons.append(Button(button_create[0], button_create[1]))
total = len(created_buttons)
padding = (button_width - (total * button.width)) / (total + 1)
button_index = 0
for btn in created_buttons:
btn_offset = button_area.get_abs_offset()
btn_rect = pygame.Rect((padding * (button_index + 1)) +
(button.width * button_index), 0,
button.width, button.height)
button_area.blit(btn.image, (btn_rect.x, btn_rect.y))
btn_rect.x += btn_offset[0] + x
btn_rect.y += btn_offset[1] + y
game.addClickableFrame(btn_rect, self.frame, btn.action, 2)
button_index += 1
@property
def title():
return self.frame.title
@title.setter
def title(self, value):
self.frame.title = value
@property
def display(self):
return self.frame.display
@display.setter
def property(self, value):
self.frame.display = value
def toggle(self):
self.frame.toggle()