def _remove_output(self): model, it = self.outputs_treeview.get_selection().get_selected() if it: if UIUtils.show_confirm_dialog( 'Are you sure you want to delete this output?'): model.remove(it) else: UIUtils.show_message_dialog('Please select a row.', gtk.MessageType.WARNING)
def check_input(self, db): batch_num = self.batch_spin.get_value_as_int() participant_num = self.part_spin.get_value_as_int() if self._check_if_used(db, batch_num, participant_num): response = UIUtils.show_confirm_dialog('Participant %d has recorded responses for Batch %d.\nContinuing will overwrite the existing data for this participant (in this batch).\nDo you want continue?' % (participant_num, batch_num)) if response: db.delete( 'ratings', where_cond = 'clip_id in (select id from clips where Batch_Num = ?) and Participant_Num = ?', params = [batch_num, participant_num] ) self._start_testing(db, batch_num, participant_num) else: self._start_testing(db, batch_num, participant_num)
def _delete_config(self, treeview): model, it = treeview.get_selection().get_selected() if it: if UIUtils.show_confirm_dialog( 'Are you sure you want to delete this configuration?'): config = model.get(it, 4)[0] model.remove(it) if config.db_id != None: db = BLLDatabase() config.db_delete(db) db.close() else: UIUtils.show_no_sel_dialog()
def delete_check(self, treeview): model, sel_paths = treeview.get_selection().get_selected_rows() if sel_paths: if UIUtils.show_confirm_dialog( 'Are you sure you want to delete this row?'): it = model.get_iter(sel_paths[0]) check2_id = model.get_value(it, 0) db = BLLDatabase() #this is a little awkward, but it works for now... check2 = Check2.db_select(db, ids=[check2_id])[0] if check2.db_delete(db) > 0: model.remove(it) else: UIUtils.show_message_dialog( 'An error has prevented this row from being deleted. Please check the log files for details.', gtk.MESSAGE_ERROR) db.close() else: UIUtils.show_no_sel_dialog()
def _confirm_delete(self, treeview): (model, it) = treeview.get_selection().get_selected() db_id = model.get_value(it, 0) if it else None if db_id != None: response = UIUtils.show_confirm_dialog( 'Are you sure you want to delete the selected check?') if response: db = BLLDatabase() rows_deleted = Check.db_select(db, [db_id])[0].db_delete(db) db.close() if rows_deleted > 0: model.remove(it) else: UIUtils.show_message_dialog( 'An error occurred and the check could not be deleted.' ) else: UIUtils.show_no_sel_dialog()
def _check_completion(self): msgs = [] complete = True if self.controls.scale.get_fill_level() != 300: msgs.append('- The segment has not been fully played.') start_iter = self.controls.trans_entry.get_buffer().get_start_iter() end_iter = self.controls.trans_entry.get_buffer().get_end_iter() if not self.controls.trans_entry.get_buffer().get_text( start_iter, end_iter).strip(): msgs.append('- The transcription box is empty.') if not self.controls.child_voc_spinner.get_value_as_int(): msgs.append('- No child vocs have been recorded.') if msgs: dialog_text = 'The following issues have been detected:\n' dialog_text += '\n'.join(msgs) dialog_text += '\n\nProceed anyway?' complete = UIUtils.show_confirm_dialog(dialog_text) return complete
def _validate_cur_test(self): #validate w_context form w_context_valid = ( self.w_form.type_combo.get_active() != 0 and int(self.w_form.syllables_spinner.get_adjustment().get_value()) > 0 and BackendUtils.is_float(self.w_form.user_start_entry.get_text()) and BackendUtils.is_float(self.w_form.user_end_entry.get_text())) #print 'w_context_valid: %s' % str(w_context_valid) wo_context_valid = (not self.wo_context_checkbox.get_active() or int( self.wo_form.syllables_spinner.get_adjustment().get_value()) > 0) #print 'wo_context_valid: %s' % str(wo_context_valid) is_valid = w_context_valid and wo_context_valid if is_valid: #make sure user-boundaries have been updated #note: they are guarenteed to contain floats at this point because of the w_context_valid condition user_start = float(self.w_form.user_start_entry.get_text()) user_end = float(self.w_form.user_end_entry.get_text()) cur_test = self.check.tests[self.check.test_index] is_valid = (cur_test.seg.start != user_start or cur_test.seg.end != user_end) if not is_valid: is_valid = UIUtils.show_confirm_dialog( 'Segment boundaries have not been adjusted. Continue anyway?' ) else: UIUtils.show_message_dialog( 'Please ensure that all of the inputs have a correct value.') return is_valid
def run(self): csv_path = self.csv_entry.get_text() wav_path = self.wav_entry.get_text() blocks_per_activity = self.blocks_spinner.get_value_as_int() activities = [] if self.acts_treeview and self.acts_treeview.get_selection(): model, sel_paths = self.acts_treeview.get_selection( ).get_selected_rows() for path in sel_paths: it = model.get_iter(path) activities.append(model.get_value(it, 0)) environments = [] if self.envs_treeview and self.envs_treeview.get_selection(): model, sel_paths = self.envs_treeview.get_selection( ).get_selected_rows() for path in sel_paths: it = model.get_iter(path) environments.append(model.get_value(it, 0)) is_valid = csv_path and wav_path and blocks_per_activity and len( activities) and len(environments) if is_valid: check2 = Check2( csv_path, wav_path, activities, environments, blocks_per_activity, ) sel_test2s = None enough_blocks, counts_str = self.parser.have_enough_blocks( check2, False) if enough_blocks: print counts_str sel_test2s = self.parser.pick_rows( check2, lambda filename: UIUtils.open_file( 'Please locate %s' % (filename), filters=[UIUtils.WAV_FILE_FILTER], save_last_location=True, cur_location=wav_path), False) else: enough_blocks, counts_str = self.parser.have_enough_blocks( check2, True) if enough_blocks: print counts_str if UIUtils.show_confirm_dialog( 'There are not enough unused rows left for some activities (see command window for row counts). If you proceed, the same row will be selected twice. Ok to continue?' ): sel_test2s = self.parser.pick_rows( check2, lambda filename: UIUtils.open_file( 'Please locate %s' % (filename), filters=[UIUtils.WAV_FILE_FILTER], save_last_location=True, cur_location=wav_path), True) else: print counts_str UIUtils.show_message_dialog( 'The input file does not contain enough blocks of the specified types. Please refer to the command window for a printout of the activity counts.' ) if sel_test2s: progress_dialog = ProgressDialog(title='Setting up...', phases=['']) progress_dialog.show() db = BLLDatabase() check2.db_insert(db) check2.test2s = sel_test2s for i in range(len(check2.test2s)): test2 = check2.test2s[i] test2.check2_id = check2.db_id test2.db_insert(db) progress_dialog.set_fraction( float(i + 1) / float(len(check2.test2s))) db.close() progress_dialog.ensure_finish() TestWindow(check2) if self.parser: self.parser.close() self.window.destroy() else: UIUtils.show_empty_form_dialog()