當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。