def view_images(self, img_list, img_type=None): ''' Launches image viewer (depending on backend) ''' viewer = self.parent.gparams.advanced.image_viewer if viewer == 'cxi.view' and 'pickle' not in img_type: wx.MessageBox('cxi.view only accepts image pickles', 'Warning', wx.OK | wx.ICON_EXCLAMATION) else: if len(img_list) > 10: view_warning = dlg.ViewerWarning(self, len(img_list)) if view_warning.ShowModal() == wx.ID_OK: # parse 'other' entry img_no_string = str(view_warning.no_images).split(',') filenames = [] for n in img_no_string: if '-' in n: img_limits = n.split('-') start = int(min(img_limits)) end = int(max(img_limits)) if start <= len(img_list) and end <= len(img_list): filenames.extend(img_list[start:end]) else: if int(n) <= len(img_list): filenames.append(img_list[int(n)]) file_string = ' '.join(filenames) else: return view_warning.Close() elif viewer == 'distl.image_viewer' and len(img_list) > 1: wx.MessageBox('distl.image_viewer can show only one image', 'Warning', wx.OK | wx.ICON_EXCLAMATION) file_string = img_list[0] else: file_string = ' '.join(img_list) viewer = thr.ImageViewerThread(self, viewer=viewer, file_string=file_string, img_type=img_type) viewer.start()
def view_image(self): viewer = thr.ImageViewerThread(self, file_string=self.img_filename) viewer.start()