def open_adding_new_cn_character_window(master, callback):
    new_character = CharacterModel.create_new_cn_character()
    popup = CharacterWindow(
        master, new_character, lambda:
        (CharacterModel.insert_character_into_db(new_character),
         callback(new_character)))
    master.wait_window(popup)
예제 #2
0
    def _update_new_character_with_its_id(self, character):
        DBAccessor.execute('update Character{0} where FullName={1}'.format(
            convert_data_to_update_command(['ID'], [character.c_id]),
            convert_datum_to_command(character.full_name)))
        CharacterModel.update_character_into_db(character)

        self.updated_count += 1
예제 #3
0
def delete_character_with_conforming(master, character, callback):
    if tkMessageBox.askyesno(
        "Deleting",
        "Are you sure you want to delete character 「{0}」?".format(character.nickname.encode("utf-8")),
        parent=master,
    ):
        CharacterModel.delete_character_from_db(character)
        callback()
예제 #4
0
def delete_character_with_conforming(master, character, callback):
    if tkMessageBox.askyesno(
            'Deleting',
            'Are you sure you want to delete character 「{0}」?'.format(
                character.nickname.encode('utf-8')),
            parent=master):
        CharacterModel.delete_character_from_db(character)
        callback()
    def _update_new_character_with_its_id(self, character):
        DBAccessor.execute(
            "update Character{0} where FullName={1}".format(
                convert_data_to_update_command(["ID"], [character.c_id]), convert_datum_to_command(character.full_name)
            )
        )
        CharacterModel.update_character_into_db(character)

        self.updated_count += 1
 def test_select_character_by_specific_column_with_nickname(self):
     # 正確的 Nickname
     assert CharacterModel.select_character_by_specific_column(
         'Nickname', u'聖女') is not None
     # 故意丟錯的 Nickname
     self.assertRaises(ValueError,
                       CharacterModel.select_character_by_specific_column,
                       'Nickname', u'救世の聖女リリス')
 def test_select_character_by_specific_column_with_id(self):
     # 正確的 ID
     assert CharacterModel.select_character_by_specific_column(
         'ID', 5002) is not None
     # 故意丟錯的 ID
     self.assertRaises(ValueError,
                       CharacterModel.select_character_by_specific_column,
                       'ID', 333)
def open_updating_character_window(master,
                                   character,
                                   callback=lambda: None,
                                   **kwargs):
    popup = CharacterWindow(
        master, character, lambda:
        (CharacterModel.update_character_into_db(character), callback()),
        **kwargs)
    master.wait_window(popup)
예제 #9
0
 def _init_record(self, record):
     if isinstance(record, FriendRecord):
         self.record = record
         self.used_names.set(record.used_names)
         self.character_selector.set(
             CharacterModel.select_character_by_specific_column(
                 'Nickname', record.current_character
             ) if record.current_character != '' else None)
         self.character_level_var.set(record.current_character_level)
         self.rank_var.set(record.current_rank)
     else:
         raise TypeError('In FriendRecordWindow, arg: \"record\"')
예제 #10
0
 def _init_record(self, record):
     if isinstance(record, FriendRecord):
         self.record = record
         self.used_names.set(record.used_names)
         self.character_selector.set(
             CharacterModel.select_character_by_specific_column("Nickname", record.current_character)
             if record.current_character != ""
             else None
         )
         self.character_level_var.set(record.current_character_level)
         self.rank_var.set(record.current_rank)
     else:
         raise TypeError('In FriendRecordWindow, arg: "record"')
예제 #11
0
    def __init__(self, master, **kwargs):
        MainFrameWithTable.__init__(self, master, **kwargs)
        self.model = CharacterModel.CharacterFrameModel()
        self.set_table_place(34, 38)
        self.table_model = TableModelAdvance()
        self.table_model.set_columns(Character.TABLE_VIEW_COLUMNS,
                                     main_column='Nickname')
        self.table_view.setModel(self.table_model)

        self._init_upper_frame()
        self._init_left_frame()

        self.model.update_data()
        self.update_table()
예제 #12
0
 def _insert_new_character(self, character):
     CharacterModel.insert_character_into_db(character)
     self.inserted_count += 1
예제 #13
0
def open_updating_character_window(master, character, callback=lambda: None, **kwargs):
    popup = CharacterWindow(master, character, lambda: (CharacterModel.update_character_into_db(character), callback()),
                            **kwargs)
    master.wait_window(popup)
예제 #14
0
def open_adding_new_cn_character_window(master, callback):
    new_character = CharacterModel.create_new_cn_character()
    popup = CharacterWindow(master, new_character, lambda: (
        CharacterModel.insert_character_into_db(new_character), callback(new_character)))
    master.wait_window(popup)
예제 #15
0
 def _insert_new_character(self, character):
     CharacterModel.insert_character_into_db(character)
     self.inserted_count += 1
예제 #16
0
 def update_records(self):
     self.records = CharacterModel.select_character_info_for_character_selector()
 def test_select_character_by_specific_column_with_nickname(self):
     # 正確的 Nickname
     assert CharacterModel.select_character_by_specific_column('Nickname', u'聖女') is not None
     # 故意丟錯的 Nickname
     self.assertRaises(ValueError, CharacterModel.select_character_by_specific_column, 'Nickname', u'救世の聖女リリス')
예제 #18
0
 def submitting(self):
     if self.character_selector.get() != '':
         self.callback(CharacterModel.select_character_by_specific_column('Nickname', self.character_selector.get()))
         self.destroy()
     else:
         tkMessageBox.showwarning("Character haven't selected", '\"Character\" 未選\n', parent=self)
 def test_select_character_by_specific_column_with_id(self):
     # 正確的 ID
     assert CharacterModel.select_character_by_specific_column('ID', 5002) is not None
     # 故意丟錯的 ID
     self.assertRaises(ValueError, CharacterModel.select_character_by_specific_column, 'ID', 333)