Changeset 5584dee in sasview


Ignore:
Timestamp:
Nov 7, 2018 9:16:56 AM (5 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
ebf86f1
Parents:
1942f63
Message:

Minor stylistical changes to ImageViewer?.py after pylint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Utilities/ImageViewer.py

    r1942f63 r5584dee  
    22Image viewer widget. 
    33""" 
    4 from PyQt5 import QtCore 
    5 from PyQt5 import QtGui 
    6 from PyQt5 import QtWidgets 
    74 
    85import os 
     
    107import numpy as np 
    118import matplotlib 
    12 matplotlib.interactive(False) 
    139import matplotlib.image as mpimg 
     10 
     11from PyQt5 import QtWidgets 
    1412 
    1513from sas.sascalc.dataloader.manipulations import reader2D_converter 
     
    2321from sas.qtgui.Utilities.UI.ImageViewerUI import Ui_ImageViewerUI 
    2422from sas.qtgui.Utilities.UI.ImageViewerOptionsUI import Ui_ImageViewerOptionsUI 
     23matplotlib.interactive(False) 
    2524 
    2625class ImageViewer(QtWidgets.QMainWindow, Ui_ImageViewerUI): 
     
    3433        self.setupUi(self) 
    3534 
    36         # add plotter to the frame 
     35        # Other globals 
    3736        self.plotter = None 
    3837        self.hbox = None 
     38        self.filename = None 
     39        self.is_png = False 
     40        self.image = None 
    3941 
    4042        # disable menu items on empty canvas 
    4143        self.disableMenus() 
    4244 
    43         # set up signal callbacks 
    44         self.addCallbacks() 
    45  
    4645        # set up menu item triggers 
    4746        self.addTriggers() 
    48  
    49     def addCallbacks(self): 
    50         pass 
    5147 
    5248    def disableMenus(self): 
     
    121117        """ 
    122118        if self.plotter is not None: 
    123            self.plotter.onClipboardCopy() 
     119            self.plotter.onClipboardCopy() 
    124120 
    125121    def actionConvertToData(self): 
     
    135131        try: 
    136132            self.convertImage(image, xmin, xmax, ymin, ymax, zscale) 
    137         except: 
    138             err_msg = "Error occurred while converting Image to Data." 
     133        except Exception as ex: 
     134            err_msg = "Error occurred while converting Image to Data: " + str(ex) 
    139135            logging.error(err_msg) 
    140  
    141         pass 
    142136 
    143137    def actionHowTo(self): 
     
    174168            # Any other formats (tiff, jpeg, etc) are passed 
    175169            # to PIL which seems to have a problem in version 
    176             # 1.1.7 that causes a close error which shows up in  
     170            # 1.1.7 that causes a close error which shows up in 
    177171            # the log file.  This does not seem to have any adverse 
    178172            # effects.  PDB   --- September 17, 2017. 
     
    184178            origin = None 
    185179            if self.is_png: 
    186                 origin='lower' 
     180                origin = 'lower' 
    187181            self.plotter.imageShow(flipped_image, origin=origin) 
    188182            if not self.is_png: 
     
    191185            ax.set_ylabel('y [pixel]') 
    192186            self.plotter.figure.subplots_adjust(left=0.15, bottom=0.1, 
    193                                         right=0.95, top=0.95) 
     187                                                right=0.95, top=0.95) 
    194188            title = 'Picture: ' + self.filename 
    195189            self.setWindowTitle(title) 
     
    197191        except IOError as ex: 
    198192            err_msg = "Failed to load '%s'.\n" % self.filename 
    199             logging.error(err_msg) 
     193            logging.error(err_msg+str(ex)) 
    200194            return 
    201195        except Exception as ex: 
    202196            err_msg = "Failed to show '%s'.\n" % self.filename 
    203             logging.error(err_msg) 
     197            logging.error(err_msg+str(ex)) 
    204198            return 
    205199 
     
    239233        output.ymin = ymin 
    240234        output.ymax = ymax 
    241         output.xaxis('\\rm{Q_{x}}', '\AA^{-1}') 
    242         output.yaxis('\\rm{Q_{y}}', '\AA^{-1}') 
     235        output.xaxis('\\rm{Q_{x}}', r'\AA^{-1}') 
     236        output.yaxis('\\rm{Q_{y}}', r'\AA^{-1}') 
    243237        # Store loading process information 
    244238        output.meta_data['loader'] = self.filename.split('.')[-1] + "Reader" 
     
    269263            grey = np.rollaxis(rgb, axis=0) 
    270264        else: 
    271             red, green, blue = np.rollaxis(rgb[..., :3], axis= -1) 
     265            red, green, blue = np.rollaxis(rgb[..., :3], axis=-1) 
    272266            grey = 0.299 * red + 0.587 * green + 0.114 * blue 
    273267        max_i = rgb.max() 
    274         factor = 255.0 / max_i 
     268        factor = 255.0/max_i 
    275269        grey *= factor 
    276270        return np.array(grey) 
     
    332326 
    333327        return (xmin, xmax, ymin, ymax, zscale) 
    334  
Note: See TracChangeset for help on using the changeset viewer.