本文整理匯總了Python中widgets.Widget.add_action方法的典型用法代碼示例。如果您正苦於以下問題:Python Widget.add_action方法的具體用法?Python Widget.add_action怎麽用?Python Widget.add_action使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類widgets.Widget
的用法示例。
在下文中一共展示了Widget.add_action方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ask_tricks
# 需要導入模塊: from widgets import Widget [as 別名]
# 或者: from widgets.Widget import add_action [as 別名]
def ask_tricks(self, n):
"""
Ask the user for the number of tricks.
:param n: the maximum number of tricks
"""
# Create the container with the fade in effect.
container = Widget((self.screen.get_width()/2-200, 100), (400, self.screen.get_height()-120), 40)
container.opacity = 0
container.add_action(actions.FadeInAction(0.5))
self._ask_tricks_widget = container
self._background_widget.add_widget(container)
# Create the question text.
text_w = special_widgets.warning_widget((0, 0), (400, 60), "How many tricks do you make?", self._font,
close_on_click=False)
text_w.visible = True
container.add_widget(text_w)
# Create the numbers.
class ChooseHandler(object):
def __init__(self, view, nn):
self._view = view
self._n = nn
def __call__(self, x, y):
self._view._handle_say_tricks(self._n)
for i in xrange(n+1):
size = (50, 50)
pos = ((i % 6) * (size[0]+20), 80 + (i/6) * (size[1] + 20))
w = special_widgets.warning_widget(pos, size, str(i), self._font, close_on_click=False)
w.visible = True
w.handle_clicked = ChooseHandler(self, i)
container.add_widget(w)