当前位置: 首页>>代码示例>>Python>>正文


Python Form.add_object方法代码示例

本文整理汇总了Python中forms.Form.add_object方法的典型用法代码示例。如果您正苦于以下问题:Python Form.add_object方法的具体用法?Python Form.add_object怎么用?Python Form.add_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在forms.Form的用法示例。


在下文中一共展示了Form.add_object方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: disproveAccusation

# 需要导入模块: from forms import Form [as 别名]
# 或者: from forms.Form import add_object [as 别名]
 def disproveAccusation(self,message_type,accusation_lines,card_names_to_limit=None):
     card_deck = CardDeck()
     
     accusation_form = Form(False)
     disproving = False
     if len(accusation_lines) > 0:
         disproving = True
         accusation_form.add_object('new_title', Text('Current Suggestion:', label_style=['bold','underline']))
         for k in xrange(len(accusation_lines)):
             accusation_message, accusation_pos,accusation_message_str = accusation_lines[k]
             accusation_form.add_object('accusation_{0}'.format(k), Text('{0}'.format(accusation_message_str), label_style=['bold']))
         accusation_form.add_object('spacer', Text('', label_style=['bold','underline']))
         accusation_form.add_object('disprove_title_{0}'.format(k), Text('Select card(s) to disprove:', label_style=['bold','underline']))
     else:
         
         if message_type == "New Suggestion":
             accusation_form.add_object('suggestion_title', Text('Select card(s) for suggestion:', label_style=['bold','underline']))
         else:
             accusation_form.add_object('suggestion_title', Text('Select card(s) for accusation:', label_style=['bold','underline']))
     
     screen = self.getScreen(message_type,disproving)
     
     
     
     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']))
#.........这里部分代码省略.........
开发者ID:rmills2,项目名称:Coral,代码行数:103,代码来源:Message.py


注:本文中的forms.Form.add_object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。