本文整理汇总了Python中forms.Form.run方法的典型用法代码示例。如果您正苦于以下问题:Python Form.run方法的具体用法?Python Form.run怎么用?Python Form.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.Form
的用法示例。
在下文中一共展示了Form.run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: disproveAccusation
# 需要导入模块: from forms import Form [as 别名]
# 或者: from forms.Form import run [as 别名]
#.........这里部分代码省略.........
tracker = []
character_menu = Select(border_width=2, top=50)
character_list = card_deck.get_cardlist("character")
char_found = False
for character_name in character_list:
if card_names_to_limit and len(card_names_to_limit) > 1 and character_name in card_names_to_limit:
character_menu.add_option(character_name,character_name)
tracker.append(character_name)
char_found = True
elif card_names_to_limit and len(card_names_to_limit) == 1:
character_menu.add_option(character_name,character_name)
tracker.append(character_name)
char_found = True
elif not card_names_to_limit:
character_menu.add_option(character_name,character_name)
tracker.append(character_name)
char_found = True
if char_found:
accusation_form.add_object('title_character', Text('Select Character:', label_style=['bold']))
accusation_form.add_object('character', character_menu)
else:
accusation_form.add_object('title_character', Text('Select Character:', label_style=['bold']))
accusation_form.add_object('title_character_1', Text('Sorry, no Character cards', label_style=['bold']))
accusation_form.add_object('title_character_2', Text('in your deck to select', label_style=['bold']))
#if disproving: accusation_form.add_object('weapon_title', Text('with a', label_style=['bold']))
weapon_list = card_deck.get_cardlist("weapon")
weapon_menu = Select(border_width=2, top=50)
weapon_found = False
for weapon_name in weapon_list:
if card_names_to_limit and len(card_names_to_limit) > 1 and weapon_name in card_names_to_limit:
weapon_menu.add_option(weapon_name,weapon_name)
tracker.append(weapon_name)
weapon_found = True
elif card_names_to_limit and len(card_names_to_limit) == 1:
weapon_menu.add_option(weapon_name,weapon_name)
tracker.append(weapon_name)
weapon_found = True
elif not card_names_to_limit:
weapon_menu.add_option(weapon_name,weapon_name)
tracker.append(weapon_name)
weapon_found = True
if weapon_found:
accusation_form.add_object('title_weapon', Text('Select Weapon:', label_style=['bold']))
accusation_form.add_object('weapon', weapon_menu)
else:
accusation_form.add_object('title_weapon', Text('Select Weapon:', label_style=['bold']))
accusation_form.add_object('title_weapon_1', Text('Sorry, no Weapon cards', label_style=['bold']))
accusation_form.add_object('title_weapon_2', Text('in your deck to select', label_style=['bold']))
#if disproving: accusation_form.add_object('room_title', Text('in the', label_style=['bold']))
room_list = card_deck.get_cardlist("room")
room_menu = Select(border_width=2, top=50)
room_found = False
for room_name in room_list:
if card_names_to_limit and room_name in card_names_to_limit:
room_menu.add_option(room_name,room_name)
tracker.append(room_name)
room_found = True
elif not card_names_to_limit:
room_menu.add_option(room_name,room_name)
tracker.append(room_name)
room_found = True
if room_found:
accusation_form.add_object('title_room', Text('Select Room:', label_style=['bold']))
accusation_form.add_object('room', room_menu)
else:
accusation_form.add_object('title_room', Text('Select Room:', label_style=['bold']))
accusation_form.add_object('title_room_1', Text('Sorry, no Room cards', label_style=['bold']))
accusation_form.add_object('title_room_2', Text('in your deck to select', label_style=['bold']))
if disproving:
accusation_form.add_object('submit', Button('Disprove', accusation_form.submit, ()))
accusation_form.add_object('skip', Button('Skip', accusation_form.skip, ()))
else:
if message_type == "New Suggestion":
accusation_form.add_object('submit', Button('Make Suggestion', accusation_form.submit, ()))
else:
accusation_form.add_object('submit', Button('Make Final Accusation', accusation_form.submit, ()))
accusation_form.add_object('skip', Button('Skip', accusation_form.skip, ()))
accusation_form.add_object('Clear', Button('Clear', accusation_form.clear, ()))
form_input = accusation_form.run(screen)
if accusation_form._skip:
return {}
elif disproving and len(form_input) == 0:
return None
elif not disproving and len(form_input) != 3:
return None
return form_input