def _on_review_list_item_selected(self, event): # Gets the selected row's details rs = self.random_sampler rs.selected_doc_id = self.GetFocusedItem() if rs.selected_doc_id < 0: return responsive = self.GetItem(rs.selected_doc_id, 2) #privileged = self.GetItem(rs.selected_doc_id, 3) # Handles the document tags check boxes if responsive.Text == 'Yes': rs._rbx_responsive.SetStringSelection('Valid') elif responsive.Text == 'No': rs._rbx_responsive.SetStringSelection('Invalid') elif responsive.Text == '': rs._rbx_responsive.SetStringSelection('Further Review Required') ''' if privileged.Text == 'Yes': rs._rbx_privileged.SetStringSelection('Yes') elif privileged.Text == 'No': rs._rbx_privileged.SetStringSelection('No') elif privileged.Text == '': rs._rbx_privileged.SetStringSelection('Unknown') ''' # Shows the tags panel rs._panel_doc_tags.Show() rs._panel_doc_tags.GetParent().GetSizer().Layout() #Show the preview print_message = '' is_message_opened = False try: src_file_path = rs.sampled_files[rs.selected_doc_id] file_path = get_destination_file_path(rs.dir_path,rs._tempdir, src_file_path, rs.output_dir_path) _, fileExtension = os.path.splitext(file_path) if fileExtension=="" or fileExtension==".txt": with open(file_path,'r') as content: print_message+=content.read() is_message_opened = True except Exception as anyException: is_message_opned = False; if is_message_opened: rs._tc_preview.SetValue(str(print_message)) else: rs._tc_preview.SetValue('Preview is not available for this document.')
def _on_review_list_item_activated(self, event): ''' Handles the list control row double click event ''' # Gets the selected row's details rs = self.random_sampler rs.selected_doc_id = self.GetFocusedItem() if rs.selected_doc_id < 0: return responsive = self.GetItem(rs.selected_doc_id, 2) #privileged = self.GetItem(rs.selected_doc_id, 3) src_file_path = rs.sampled_files[rs.selected_doc_id] dest_file_path = get_destination_file_path(rs.dir_path,rs._tempdir, src_file_path, rs.output_dir_path) #print rs._tempdir+"\n" _, file_name = os.path.split(src_file_path) responsive_status = rs._rbx_responsive.GetStringSelection() privileged_status = rs._rbx_privileged.GetStringSelection() if os.path.exists(dest_file_path): try: # Open a file webbrowser.open(dest_file_path) self.make_tag_popup(file_name,responsive_status, privileged_status) except Exception as anyException: pass print anyException #rs._show_error_message("Open File Error!", "The file could not be opened with the default application.") else: rs._show_error_message("Open File Error!", "The file does not exist!")