Changeset d744767 in sasview for src/sas/qtgui/Plotting


Ignore:
Timestamp:
Mar 16, 2018 2:05:42 PM (6 years ago)
Author:
krzywon
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
47bf906
Parents:
477c473 (diff), e4c475b7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' into ESS_GUI_Pr

Location:
src/sas/qtgui/Plotting
Files:
44 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Plotting/AddText.py

    r83eb5208 r53c771e  
    1 from PyQt4 import QtGui 
     1from PyQt5 import QtCore 
     2from PyQt5 import QtGui 
     3from PyQt5 import QtWidgets 
    24 
    35import sas.sasview 
     
    57from sas.qtgui.Plotting.UI.AddTextUI import Ui_AddText 
    68 
    7 class AddText(QtGui.QDialog, Ui_AddText): 
     9class AddText(QtWidgets.QDialog, Ui_AddText): 
    810    """ Simple GUI for a single line text query """ 
    911    def __init__(self, parent=None): 
     
    2931        Pop up the standard Qt Font change dialog 
    3032        """ 
    31         self._font, ok = QtGui.QFontDialog.getFont(parent=self) 
     33        self._font, ok = QtWidgets.QFontDialog.getFont(parent=self) 
    3234        if ok: 
    3335            self.textEdit.setFont(self._font) 
     
    3840        """ 
    3941        # Pick up the chosen color 
    40         self._color = QtGui.QColorDialog.getColor(parent=self) 
     42        self._color = QtWidgets.QColorDialog.getColor(parent=self) 
    4143        # Update the text control 
    4244        palette = QtGui.QPalette() 
  • src/sas/qtgui/Plotting/Arrow3D.py

    • Property mode changed from 100755 to 100644
    rfef38e8 rcee5c78  
    2929        self.base = base 
    3030 
    31         if base != None: 
     31        if base is not None: 
    3232            # To turn the updating off during dragging 
    3333            base.canvas.mpl_connect('button_press_event', self.on_left_down) 
     
    5959            return 
    6060        xs3d, ys3d, zs3d = self._verts3d 
    61         for i in xrange(len(xs3d)): 
     61        for i in range(len(xs3d)): 
    6262            xs, ys, _ = proj3d.proj_transform(xs3d[i], ys3d[i], zs3d[i], renderer.M) 
    6363            self.set_positions((xs[0], ys[0]), (xs[1], ys[1])) 
  • src/sas/qtgui/Plotting/Binder.py

    • Property mode changed from 100755 to 100644
    rdc5ef15 rcee5c78  
    2424        return self.artist is not other.artist 
    2525 
    26     def __nonzero__(self): 
     26    def __bool__(self): 
    2727        return self.artist is not None 
    2828 
     
    6161            ] 
    6262        except: 
    63             print "bypassing scroll_event: wrong matplotlib version" 
     63            print("bypassing scroll_event: wrong matplotlib version") 
    6464            self._connections = [ 
    6565                canvas.mpl_connect('motion_notify_event', self._onMotion), 
     
    121121            for cid in self._connections: self.canvas.mpl_disconnect(cid) 
    122122        except: 
    123             logging.error("Error disconnection canvas: %s" % sys.exc_value) 
     123            logging.error("Error disconnection canvas: %s" % sys.exc_info()[1]) 
    124124        self._connections = [] 
    125125 
     
    185185        # Check that the trigger is valid 
    186186        if trigger not in self._actions: 
    187             raise ValueError, "%s invalid --- valid triggers are %s"\ 
    188                  % (trigger, ", ".join(self.events)) 
     187            raise ValueError("%s invalid --- valid triggers are %s"\ 
     188                 % (trigger, ", ".join(self.events))) 
    189189 
    190190        # Register the trigger callback 
     
    201201        """ 
    202202        if action not in self.events: 
    203             raise ValueError, "Trigger expects " + ", ".join(self.events) 
     203            raise ValueError("Trigger expects " + ", ".join(self.events)) 
    204204 
    205205        # Tag the event with modifiers 
     
    233233        """ 
    234234        # TODO: sort by zorder of axes then by zorder within axes 
    235         self._artists.sort(cmp=lambda x, y: cmp(y.zorder, x.zorder)) 
     235        #self._artists.sort(cmp=lambda x, y: cmp(y.zorder, x.zorder)) 
     236        #self._artists.sort(cmp=lambda x, y: y.zorder.__gt__(x.zorder)) 
    236237        found = Selection() 
    237238        for artist in self._artists: 
  • src/sas/qtgui/Plotting/BoxSum.py

    rcd2cc745 rd6b8a1d  
    22Allows users to modify the box slicer parameters. 
    33""" 
    4 from PyQt4 import QtGui 
    5 from PyQt4 import QtCore 
     4from PyQt5 import QtCore 
     5from PyQt5 import QtGui 
     6from PyQt5 import QtWidgets 
     7 
     8import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    69 
    710# Local UI 
     
    912from sas.qtgui.Plotting.UI.BoxSumUI import Ui_BoxSumUI 
    1013 
    11 class BoxSum(QtGui.QDialog, Ui_BoxSumUI): 
    12     apply_signal = QtCore.pyqtSignal(tuple, str) 
     14class BoxSum(QtWidgets.QDialog, Ui_BoxSumUI): 
    1315    def __init__(self, parent=None, model=None): 
    1416        super(BoxSum, self).__init__() 
     
    1719        assert isinstance(model, QtGui.QStandardItemModel) 
    1820 
    19         self.txtBoxHeight.setValidator(QtGui.QDoubleValidator()) 
    20         self.txtBoxWidth.setValidator(QtGui.QDoubleValidator()) 
    21         self.txtCenterX.setValidator(QtGui.QDoubleValidator()) 
    22         self.txtCenterY.setValidator(QtGui.QDoubleValidator()) 
     21        self.txtBoxHeight.setValidator(GuiUtils.DoubleValidator()) 
     22        self.txtBoxWidth.setValidator(GuiUtils.DoubleValidator()) 
     23        self.txtCenterX.setValidator(GuiUtils.DoubleValidator()) 
     24        self.txtCenterY.setValidator(GuiUtils.DoubleValidator()) 
    2325 
    2426        self.model = model 
    25         self.mapper = QtGui.QDataWidgetMapper() 
     27        self.mapper = QtWidgets.QDataWidgetMapper() 
    2628        self.mapper.setModel(self.model) 
    2729 
     
    3133        self.mapper.addMapping(self.txtCenterX, 2) 
    3234        self.mapper.addMapping(self.txtCenterY, 3) 
    33         self.mapper.addMapping(self.lblAvg, 4, "text") 
    34         self.mapper.addMapping(self.lblAvgErr, 5, "text") 
    35         self.mapper.addMapping(self.lblSum, 6, "text") 
    36         self.mapper.addMapping(self.lblSumErr, 7, "text") 
    37         self.mapper.addMapping(self.lblNumPoints, 8, "text") 
     35        self.mapper.addMapping(self.lblAvg, 4, b"text") 
     36        self.mapper.addMapping(self.lblAvgErr, 5, b"text") 
     37        self.mapper.addMapping(self.lblSum, 6, b"text") 
     38        self.mapper.addMapping(self.lblSumErr, 7, b"text") 
     39        self.mapper.addMapping(self.lblNumPoints, 8, b"text") 
    3840 
    3941        # Populate the widgets with data from the first column 
     
    4244        self.setFixedSize(self.minimumSizeHint()) 
    4345 
     46        # Handle the Apply button click 
     47        self.buttonBox.button(QtWidgets.QDialogButtonBox.Close).clicked.connect(self.onClose) 
     48 
     49    def onClose(self): 
     50        """ 
     51        close the window containing this panel 
     52        """ 
     53        self.close() 
     54 
  • src/sas/qtgui/Plotting/ColorMap.py

    rdc5ef15 rd6b8a1d  
    22Allows users to change the range of the current graph 
    33""" 
    4 from PyQt4 import QtGui 
    5 from PyQt4 import QtCore 
     4from PyQt5 import QtCore 
     5from PyQt5 import QtGui 
     6from PyQt5 import QtWidgets 
    67import sas.qtgui.path_prepare 
    78 
     
    1011import numpy 
    1112 
    12 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
     13from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 
    1314from sas.qtgui.Plotting.PlotterData import Data2D 
    14 from sas.qtgui.Utilities.GuiUtils import formatNumber 
    15 from rangeSlider import RangeSlider 
     15from sas.qtgui.Utilities.GuiUtils import formatNumber, DoubleValidator 
     16from .rangeSlider import RangeSlider 
    1617 
    1718DEFAULT_MAP = 'jet' 
     
    2122from sas.qtgui.Plotting.UI.ColorMapUI import Ui_ColorMapUI 
    2223 
    23 class ColorMap(QtGui.QDialog, Ui_ColorMapUI): 
     24class ColorMap(QtWidgets.QDialog, Ui_ColorMapUI): 
    2425    apply_signal = QtCore.pyqtSignal(tuple, str) 
    2526    def __init__(self, parent=None, cmap=None, vmin=0.0, vmax=100.0, data=None): 
     
    5051 
    5152        # Initialize validators on amplitude textboxes 
    52         validator_min = QtGui.QDoubleValidator(self.txtMinAmplitude) 
     53        validator_min = DoubleValidator(self.txtMinAmplitude) 
    5354        validator_min.setNotation(0) 
    5455        self.txtMinAmplitude.setValidator(validator_min) 
    55         validator_max = QtGui.QDoubleValidator(self.txtMaxAmplitude) 
     56        validator_max = DoubleValidator(self.txtMaxAmplitude) 
    5657        validator_max.setNotation(0) 
    5758        self.txtMaxAmplitude.setValidator(validator_max) 
     
    7172 
    7273        # Handle the Reset button click 
    73         self.buttonBox.button(QtGui.QDialogButtonBox.Reset).clicked.connect(self.onReset) 
     74        self.buttonBox.button(QtWidgets.QDialogButtonBox.Reset).clicked.connect(self.onReset) 
    7475 
    7576        # Handle the Apply button click 
    76         self.buttonBox.button(QtGui.QDialogButtonBox.Apply).clicked.connect(self.onApply) 
     77        self.buttonBox.button(QtWidgets.QDialogButtonBox.Apply).clicked.connect(self.onApply) 
    7778 
    7879        # Handle the amplitude setup 
     
    161162        self.slider.setOrientation(QtCore.Qt.Horizontal) 
    162163 
    163         self.slider_label = QtGui.QLabel() 
     164        self.slider_label = QtWidgets.QLabel() 
    164165        self.slider_label.setText("Drag the sliders to adjust color range.") 
    165166 
     
    192193        self.canvas = FigureCanvas(self.fig) 
    193194 
    194         layout = QtGui.QVBoxLayout() 
     195        layout = QtWidgets.QVBoxLayout() 
    195196        layout.addWidget(self.slider_label) 
    196197        layout.addWidget(self.slider) 
  • src/sas/qtgui/Plotting/ConvertUnits.py

    re7a0b2f rd744767  
    44""" 
    55import re 
    6 import string 
    76 
    87def convertUnit(power, unit): 
     
    1110    """ 
    1211    if power != 0: 
    13         if string.find(unit, "^") != -1:  # if the unit contains a powerer ^ 
     12        if unit.find("^") != -1:  # if the unit contains a powerer ^ 
    1413            toks = re.split("\^", unit) 
    15             if string.find(toks[0], "/") != -1 or \ 
    16                 string.find(toks[0], "-") != -1: 
     14            if toks[0].find("/") != -1 or \ 
     15                toks[0].find("-") != -1: 
    1716                if power == 1: 
    1817                    unit = unit 
     
    2019                    unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    2120            else: 
    22                 if string.find(toks[1], "{") != -1:  # if found a { 
     21                if toks[1].find("{") != -1:  # if found a { 
    2322                    find_power_toks = re.split("{", toks[1]) 
    24                     if string.find(find_power_toks[1], "}") != -1:  # found } 
     23                    if find_power_toks[1].find("}") != -1:  # found } 
    2524                        unit_toks = re.split("}", find_power_toks[1]) 
    26                         if string.find(unit_toks[0], ".") != -1: 
     25                        if unit_toks[0].find(".") != -1: 
    2726                            powerer = float(unit_toks[0]) * power 
    28                         elif string.find(unit_toks[0], "/") != -1: 
     27                        elif unit_toks[0].find("/") != -1: 
    2928                            power_toks = re.split("/", unit_toks[0]) 
    3029                            powerer = power * int(power_toks[0])\ 
     
    4241                            unit = toks[0] + "^{" + str(powerer) + "}" 
    4342                else: 
    44                     raise ValueError, "missing } in unit expression" 
     43                    raise ValueError("missing } in unit expression") 
    4544        else:  # no powerer 
    4645            if  power != 1: 
    4746                unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    4847    else: 
    49         raise ValueError, "empty unit ,enter a powerer different from zero" 
     48        raise ValueError("empty unit ,enter a powerer different from zero") 
    5049    return unit 
    5150 
     
    6867    unit8 = "m/s^{4}"  #         x^2               (m/s^{4})^{2} 
    6968 
    70     print "this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1)) 
    71     print "this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2)) 
    72     print "this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3)) 
    73     print "this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4)) 
    74     print "this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5)) 
    75     print "this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6)) 
    76     print "this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7)) 
    77     print "this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8)) 
    78     print "this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9)) 
     69    print("this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1))) 
     70    print("this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2))) 
     71    print("this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3))) 
     72    print("this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4))) 
     73    print("this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5))) 
     74    print("this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6))) 
     75    print("this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7))) 
     76    print("this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8))) 
     77    print("this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9))) 
    7978 
    8079 
  • src/sas/qtgui/Plotting/DataTransform.py

    re7a0b2f rd744767  
    2424    """ 
    2525    if not x > 0: 
    26         raise ValueError, "Transformation only accepts positive values." 
     26        raise ValueError("Transformation only accepts positive values.") 
    2727    else: 
    2828        return x 
     
    5050    """ 
    5151    if not x >= 0: 
    52         raise ValueError, "square root of a negative value " 
     52        raise ValueError("square root of a negative value ") 
    5353    else: 
    5454        return math.sqrt(x) 
     
    7676    """ 
    7777    if not x >= 0: 
    78         raise ValueError, "double square root of a negative value " 
     78        raise ValueError("double square root of a negative value ") 
    7979    else: 
    8080        return math.sqrt(math.sqrt(x)) 
     
    9090    """ 
    9191    if not x > 0: 
    92         raise ValueError, "Log(x)of a negative value " 
     92        raise ValueError("Log(x)of a negative value ") 
    9393    else: 
    9494        return math.log(x) 
     
    100100        return 1 / x 
    101101    else: 
    102         raise ValueError, "cannot divide by zero" 
     102        raise ValueError("cannot divide by zero") 
    103103 
    104104 
     
    109109        return 1 / math.sqrt(y) 
    110110    else: 
    111         raise ValueError, "transform.toOneOverSqrtX: cannot be computed" 
     111        raise ValueError("transform.toOneOverSqrtX: cannot be computed") 
    112112 
    113113 
     
    118118        return math.log(y * (x ** 2)) 
    119119    else: 
    120         raise ValueError, "transform.toLogYX2: cannot be computed" 
     120        raise ValueError("transform.toLogYX2: cannot be computed") 
    121121 
    122122 
     
    127127        return math.log(math.pow(x, 4) * y) 
    128128    else: 
    129         raise ValueError, "transform.toLogYX4: input error" 
     129        raise ValueError("transform.toLogYX4: input error") 
    130130 
    131131 
     
    149149    """ 
    150150    if not (x * y) > 0: 
    151         raise ValueError, "Log(X*Y)of a negative value " 
     151        raise ValueError("Log(X*Y)of a negative value ") 
    152152    else: 
    153153        return math.log(x * y) 
     
    162162 
    163163    """ 
    164     if dx == None: 
     164    if dx is None: 
    165165        dx = 0 
    166166    return dx 
     
    175175 
    176176    """ 
    177     if dx == None: 
     177    if dx is None: 
    178178        dx = 0 
    179179    return dx 
     
    188188 
    189189    """ 
    190     if  dx != None: 
     190    if  dx is not None: 
    191191        err = 2 * x * dx 
    192192        return math.fabs(err) 
     
    204204    """ 
    205205    if x > 0: 
    206         if dx != None: 
     206        if dx is not None: 
    207207            err = dx / (2 * math.sqrt(x)) 
    208208        else: 
     
    211211    else: 
    212212        msg = "transform.errFromX2: can't compute error of negative x" 
    213         raise ValueError, msg 
     213        raise ValueError(msg) 
    214214 
    215215 
     
    222222 
    223223    """ 
    224     if dx != None: 
     224    if dx is not None: 
    225225        err = 4 * math.pow(x, 3) * dx 
    226226        return math.fabs(err) 
     
    238238    """ 
    239239    if x > 0: 
    240         if dx != None: 
     240        if dx is not None: 
    241241            err = dx / (4 * math.pow(x, 3 / 4)) 
    242242        else: 
     
    245245    else: 
    246246        msg = "transform.errFromX4: can't compute error of negative x" 
    247         raise ValueError, msg 
     247        raise ValueError(msg) 
    248248 
    249249 
     
    256256 
    257257    """ 
    258     if dx == None: 
     258    if dx is None: 
    259259        dx = 0 
    260260 
     
    264264        msg = "Transformation does not accept" 
    265265        msg += " point that are consistent with zero." 
    266         raise ValueError, msg 
     266        raise ValueError(msg) 
    267267    if x != 0: 
    268268        dx = dx / (x * math.log(10)) 
    269269    else: 
    270         raise ValueError, "errToLogX: divide by zero" 
     270        raise ValueError("errToLogX: divide by zero") 
    271271    return dx 
    272272 
     
    280280 
    281281    """ 
    282     if dx == None: 
     282    if dx is None: 
    283283        dx = 0 
    284284 
     
    287287        dx = dx / x 
    288288    else: 
    289         raise ValueError, "errToLogX: divide by zero" 
     289        raise ValueError("errToLogX: divide by zero") 
    290290    return dx 
    291291 
     
    294294    """ 
    295295    """ 
    296     if dx == None: 
    297         dx = 0 
    298     if dy == None: 
     296    if dx is None: 
     297        dx = 0 
     298    if dy is None: 
    299299        dy = 0 
    300300    err = math.sqrt((2 * x * y * dx) ** 2 + ((x ** 2) * dy) ** 2) 
     
    312312        msg = "Transformation does not accept point " 
    313313        msg += " that are consistent with zero." 
    314         raise ValueError, msg 
     314        raise ValueError(msg) 
    315315    if x != 0 and y != 0: 
    316         if dx == None: 
     316        if dx is None: 
    317317            dx = 0 
    318         if dy == None: 
     318        if dy is None: 
    319319            dy = 0 
    320320        err = (dx / x) ** 2 + (dy / y) ** 2 
    321321    else: 
    322         raise ValueError, "cannot compute this error" 
     322        raise ValueError("cannot compute this error") 
    323323 
    324324    return math.sqrt(math.fabs(err)) 
     
    335335        msg = "Transformation does not accept point" 
    336336        msg += " that are consistent with zero." 
    337         raise ValueError, msg 
     337        raise ValueError(msg) 
    338338    if x > 0 and y > 0: 
    339         if dx == None: 
     339        if dx is None: 
    340340            dx = 0 
    341         if dy == None: 
     341        if dy is None: 
    342342            dy = 0 
    343343        err = (2.0 * dx / x) ** 2 + (dy / y) ** 2 
    344344    else: 
    345         raise ValueError, "cannot compute this error" 
     345        raise ValueError("cannot compute this error") 
    346346    return math.sqrt(math.fabs(err)) 
    347347 
     
    353353    """ 
    354354    if x != 0: 
    355         if dx == None: 
     355        if dx is None: 
    356356            dx = 0 
    357357        err = dx / x ** 2 
    358358    else: 
    359         raise ValueError, "Cannot compute this error" 
     359        raise ValueError("Cannot compute this error") 
    360360    return math.fabs(err) 
    361361 
     
    367367    """ 
    368368    if x > 0: 
    369         if dx == None: 
     369        if dx is None: 
    370370            dx = 0 
    371371        err = -1 / 2 * math.pow(x, -3.0 / 2.0) * dx 
    372372    else: 
    373         raise ValueError, "Cannot compute this error" 
     373        raise ValueError("Cannot compute this error") 
    374374    return math.fabs(err) 
    375375 
     
    387387        msg = "Transformation does not accept point " 
    388388        msg += " that are consistent with zero." 
    389         raise ValueError, msg 
    390     if dx == None: 
    391         dx = 0 
    392     if dy == None: 
     389        raise ValueError(msg) 
     390    if dx is None: 
     391        dx = 0 
     392    if dy is None: 
    393393        dy = 0 
    394394    err = math.sqrt((4.0 * dx / x) ** 2 + (dy / y) ** 2) 
     
    406406    # within errors 
    407407 
    408     if dx == None: 
    409         dx = 0 
    410     if dy == None: 
     408    if dx is None: 
     409        dx = 0 
     410    if dy is None: 
    411411        dy = 0 
    412412    err = math.sqrt((dy * pow(x, 4)) ** 2 + (4 * y * dx * math.pow(x, 3)) ** 2) 
  • src/sas/qtgui/Plotting/Fittings.py

    radc49fc rcee5c78  
    2222        self.model = model 
    2323        self.name = name 
    24         if not value == None: 
     24        if value is not None: 
    2525            self.model.setParam(self.name, value) 
    2626 
     
    9797    # Testing implementation 
    9898    # Fit a Line model 
    99     from LineModel import LineModel 
     99    from .LineModel import LineModel 
    100100    line = LineModel() 
    101101    cstA = Parameter(line, 'A', event.cstA) 
     
    104104    chisqr, out, cov = sasfit(line, [cstA, cstB], event.x, y, 0) 
    105105    # print "Output parameters:", out 
    106     print "The right answer is [70.0, 1.0]" 
    107     print chisqr, out, cov 
     106    print("The right answer is [70.0, 1.0]") 
     107    print(chisqr, out, cov) 
    108108 
  • src/sas/qtgui/Plotting/LineModel.py

    re7a0b2f rb3e8629  
    8181        elif x.__class__.__name__ == 'tuple': 
    8282            msg = "Tuples are not allowed as input to BaseComponent models" 
    83             raise ValueError, msg 
     83            raise ValueError(msg) 
    8484        else: 
    8585            return self._line(x) 
     
    103103        elif x.__class__.__name__ == 'tuple': 
    104104            msg = "Tuples are not allowed as input to BaseComponent models" 
    105             raise ValueError, msg 
     105            raise ValueError(msg) 
    106106        else: 
    107107            return self._line(x) 
  • src/sas/qtgui/Plotting/LinearFit.py

    rdc5ef15 re4c475b7  
    44import re 
    55import numpy 
    6 from PyQt4 import QtGui 
    7 from PyQt4 import QtCore 
    8  
    9 from sas.qtgui.Utilities.GuiUtils import formatNumber 
     6from PyQt5 import QtCore 
     7from PyQt5 import QtGui 
     8from PyQt5 import QtWidgets 
     9 
     10from sas.qtgui.Utilities.GuiUtils import formatNumber, DoubleValidator 
    1011 
    1112from sas.qtgui.Plotting import Fittings 
    1213from sas.qtgui.Plotting import DataTransform 
    1314from sas.qtgui.Plotting.LineModel import LineModel 
     15import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    1416 
    1517# Local UI 
     
    1719from sas.qtgui.Plotting.UI.LinearFitUI import Ui_LinearFitUI 
    1820 
    19 class LinearFit(QtGui.QDialog, Ui_LinearFitUI): 
     21class LinearFit(QtWidgets.QDialog, Ui_LinearFitUI): 
     22    updatePlot = QtCore.pyqtSignal(tuple) 
    2023    def __init__(self, parent=None, 
    2124                 data=None, 
     
    4144        self.y_is_log = self.yLabel == "log10(y)" 
    4245 
    43         self.txtFitRangeMin.setValidator(QtGui.QDoubleValidator()) 
    44         self.txtFitRangeMax.setValidator(QtGui.QDoubleValidator()) 
     46        self.txtFitRangeMin.setValidator(DoubleValidator()) 
     47        self.txtFitRangeMax.setValidator(DoubleValidator()) 
    4548 
    4649        # Default values in the line edits 
     
    5457        self.txtRangeMin.setText(str(max_range[0])) 
    5558        self.txtRangeMax.setText(str(max_range[1])) 
    56         self.txtFitRangeMin.setText(str(fit_range[0])) 
    57         self.txtFitRangeMax.setText(str(fit_range[1])) 
     59        # Assure nice display of ranges 
     60        fr_min = GuiUtils.formatNumber(fit_range[0]) 
     61        fr_max = GuiUtils.formatNumber(fit_range[1]) 
     62        self.txtFitRangeMin.setText(str(fr_min)) 
     63        self.txtFitRangeMax.setText(str(fr_max)) 
    5864 
    5965        # cast xLabel into html 
     
    7985        Overwrite default fit range label to correspond to actual unit 
    8086        """ 
    81         assert(isinstance(label, basestring)) 
     87        assert(isinstance(label, str)) 
    8288        self.lblRange.setText(label) 
    8389 
     
    111117        # Set the qmin and qmax in the panel that matches the 
    112118        # transformed min and max 
    113         #value_xmin = X_VAL_DICT[self.xLabel].floatTransform(xmin) 
    114         #value_xmax = X_VAL_DICT[self.xLabel].floatTransform(xmax) 
    115  
    116119        value_xmin = self.floatInvTransform(xmin) 
    117120        value_xmax = self.floatInvTransform(xmax) 
     
    156159        y_model = self.model.run(xmin) 
    157160        tempx.append(xminView) 
    158         tempy.append(numpy.power(10, y_model) if self.y_is_log else y_model) 
     161        tempy.append(numpy.power(10.0, y_model) if self.y_is_log else y_model) 
    159162 
    160163        # load tempy with the maximum transformation 
    161164        y_model = self.model.run(xmax) 
    162165        tempx.append(xmaxView) 
    163         tempy.append(numpy.power(10, y_model) if self.y_is_log else y_model) 
     166        tempy.append(numpy.power(10.0, y_model) if self.y_is_log else y_model) 
    164167 
    165168        # Set the fit parameter display when  FitDialog is opened again 
     
    177180        self.txtChi2.setText(formatNumber(self.Chivalue)) 
    178181 
    179         #self.parent.updatePlot.emit((tempx, tempy)) 
    180         self.parent.emit(QtCore.SIGNAL('updatePlot'), (tempx, tempy)) 
     182        self.updatePlot.emit((tempx, tempy)) 
    181183 
    182184    def origData(self): 
     
    195197                         for i in range(len(x)) if x[i] >= xmin_check] 
    196198            else: 
    197                 tempy = map(numpy.log10, y) 
    198                 tempdy = map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy) 
     199                tempy = list(map(numpy.log10, y)) 
     200                tempdy = list(map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy)) 
    199201        else: 
    200202            tempy = y 
     
    246248            return numpy.sqrt(numpy.sqrt(x)) 
    247249        elif self.xLabel == "log10(x)": 
    248             return numpy.power(10, x) 
     250            return numpy.power(10.0, x) 
    249251        elif self.xLabel == "ln(x)": 
    250252            return numpy.exp(x) 
    251253        elif self.xLabel == "log10(x^(4))": 
    252             return numpy.sqrt(numpy.sqrt(numpy.power(10, x))) 
     254            return numpy.sqrt(numpy.sqrt(numpy.power(10.0, x))) 
    253255        return x 
    254256 
  • src/sas/qtgui/Plotting/MaskEditor.py

    rdc5ef15 r4992ff2  
    1 from PyQt4 import QtGui 
     1from PyQt5 import QtCore 
     2from PyQt5 import QtGui 
     3from PyQt5 import QtWidgets 
    24 
    35from sas.qtgui.Plotting.PlotterData import Data2D 
     
    810from sas.qtgui.Plotting.Plotter2D import Plotter2DWidget 
    911 
    10 class MaskEditor(QtGui.QDialog, Ui_MaskEditorUI): 
     12class MaskEditor(QtWidgets.QDialog, Ui_MaskEditorUI): 
    1113    def __init__(self, parent=None, data=None): 
    1214        super(MaskEditor, self).__init__() 
     
    2325        self.plotter.data = self.data 
    2426 
    25         layout = QtGui.QHBoxLayout() 
     27        layout = QtWidgets.QHBoxLayout() 
    2628        layout.setContentsMargins(0, 0, 0, 0) 
    2729        self.frame.setLayout(layout) 
  • src/sas/qtgui/Plotting/PlotHelper.py

    • Property mode changed from 100644 to 100755
    r83eb5208 rb3e8629  
    3535    Returns a list of IDs for all currently active plots 
    3636    """ 
    37     return this._plots.keys() 
     37    return list(this._plots.keys()) 
    3838 
    3939def plotById(plot_id): 
     
    4848    """ 
    4949    plot_id = None 
    50     for key in this._plots.keys(): 
     50    for key in list(this._plots.keys()): 
    5151        if this._plots[key] == plot: 
    5252            plot_id = key 
  • src/sas/qtgui/Plotting/PlotProperties.py

    rcd2cc745 r53c771e  
    1 from PyQt4 import QtGui 
     1from PyQt5 import QtCore 
     2from PyQt5 import QtGui 
     3from PyQt5 import QtWidgets 
    24 
    35from sas.qtgui.Plotting.PlotUtilities import COLORS, SHAPES 
     
    68from sas.qtgui.Plotting.UI.PlotPropertiesUI import Ui_PlotPropertiesUI 
    79 
    8 class PlotProperties(QtGui.QDialog, Ui_PlotPropertiesUI): 
     10class PlotProperties(QtWidgets.QDialog, Ui_PlotPropertiesUI): 
    911    """ Dialog for modification of single plot properties """ 
    1012    def __init__(self, 
     
    2628 
    2729        # Fill out the color combobox 
    28         self.cbColor.addItems(COLORS.keys()[:-1]) 
     30        self.cbColor.addItems(list(COLORS.keys())[:-1]) 
    2931        # data1d.custom_color can now be a simple integer, 
    3032        # specifying COLORS dict index or a string containing 
     
    3436        else: 
    3537            # Need the Custom entry here. "Custom" is always last. 
    36             self.cbColor.addItems([COLORS.keys()[-1]]) 
    37             self.cbColor.setCurrentIndex(COLORS.keys().index("Custom")) 
     38            self.cbColor.addItems([list(COLORS.keys())[-1]]) 
     39            self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 
    3840 
    3941        # Fill out the marker combobox 
    40         self.cbShape.addItems(SHAPES.keys()) 
     42        self.cbShape.addItems(list(SHAPES.keys())) 
    4143        try: 
    4244            self.cbShape.setCurrentIndex(self._marker) 
     
    7678        """ 
    7779        # Pick up the chosen color 
    78         proposed_color = QtGui.QColorDialog.getColor(parent=self) 
     80        proposed_color = QtWidgets.QColorDialog.getColor(parent=self) 
    7981        # Update the text control 
    8082        if proposed_color.isValid(): 
     
    8385            # Add Custom to the color combo box 
    8486            self.cbColor.addItems(["Custom"]) 
    85             self.cbColor.setCurrentIndex(COLORS.keys().index("Custom")) 
     87            self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 
    8688            # unblock currentIndexChanged 
    8789            self.cbColor.blockSignals(False) 
  • src/sas/qtgui/Plotting/PlotUtilities.py

    r83eb5208 rcee5c78  
    161161    """ 
    162162    # No image matrix given 
    163     if image == None or numpy.ndim(image) != 2 \ 
     163    if image is None or numpy.ndim(image) != 2 \ 
    164164            or numpy.isfinite(image).all() \ 
    165             or weights == None: 
     165            or weights is None: 
    166166        return image 
    167167    # Get bin size in y and x directions 
     
    273273        # Check if it's within the range 
    274274        if 0 <= color <=6: 
    275             color = COLORS.values()[color] 
     275            color = list(COLORS.values())[color] 
    276276    # Check if it's an RGB string 
    277277    elif isinstance(color, str): 
  • src/sas/qtgui/Plotting/Plottables.py

    • Property mode changed from 100755 to 100644
    rbed08e7 rcee5c78  
    239239        selected_color = None 
    240240        selected_plottable = None 
    241         for p in self.plottables.keys(): 
     241        for p in list(self.plottables.keys()): 
    242242            if plottable.id == p.id: 
    243243                selected_plottable = p 
     
    384384 
    385385        """ 
    386         raise NotImplemented, "Not a valid transform" 
     386        raise NotImplemented("Not a valid transform") 
    387387 
    388388    # Related issues 
     
    512512                label_dict[collection[0]] = basename 
    513513            else: 
    514                 for i in xrange(len(collection)): 
     514                for i in range(len(collection)): 
    515515                    label_dict[collection[i]] = "%s %d" % (basename, i) 
    516516        return label_dict 
     
    684684                msg = "Plottable.View: Given x and dx are not" 
    685685                msg += " of the same length" 
    686                 raise ValueError, msg 
     686                raise ValueError(msg) 
    687687            # Check length of y array 
    688688            if not len(y) == len(x): 
    689689                msg = "Plottable.View: Given y " 
    690690                msg += "and x are not of the same length" 
    691                 raise ValueError, msg 
     691                raise ValueError(msg) 
    692692 
    693693            if not dy is None and not len(dy) == 0 and not len(y) == len(dy): 
    694694                msg = "Plottable.View: Given y and dy are not of the same " 
    695695                msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 
    696                 raise ValueError, msg 
     696                raise ValueError(msg) 
    697697            self.x = [] 
    698698            self.y = [] 
     
    729729                msg = "Plottable.View: transformed x " 
    730730                msg += "and y are not of the same length" 
    731                 raise ValueError, msg 
     731                raise ValueError(msg) 
    732732            if has_err_x and not (len(self.x) == len(self.dx)): 
    733733                msg = "Plottable.View: transformed x and dx" 
    734734                msg += " are not of the same length" 
    735                 raise ValueError, msg 
     735                raise ValueError(msg) 
    736736            if has_err_y and not (len(self.y) == len(self.dy)): 
    737737                msg = "Plottable.View: transformed y" 
    738738                msg += " and dy are not of the same length" 
    739                 raise ValueError, msg 
     739                raise ValueError(msg) 
    740740            # Check that negative values are not plot on x and y axis for 
    741741            # log10 transformation 
     
    809809                except: 
    810810                    logging.error("check_data_logX: skipping point x %g", self.x[i]) 
    811                     logging.error(sys.exc_value) 
     811                    logging.error(sys.exc_info()[1]) 
    812812            self.x = tempx 
    813813            self.y = tempy 
     
    839839                except: 
    840840                    logging.error("check_data_logY: skipping point %g", self.y[i]) 
    841                     logging.error(sys.exc_value) 
     841                    logging.error(sys.exc_info()[1]) 
    842842 
    843843            self.x = tempx 
     
    862862        if self.dy is None: 
    863863            self.dy = numpy.zeros(len(self.y)) 
    864         if xmin != None and xmax != None: 
     864        if xmin is not None and xmax is not None: 
    865865            for i in range(len(self.x)): 
    866866                if self.x[i] >= xmin and self.x[i] <= xmax: 
     
    11011101        Plottable.__init__(self) 
    11021102        msg = "Theory1D is no longer supported, please use Data1D and change symbol.\n" 
    1103         raise DeprecationWarning, msg 
     1103        raise DeprecationWarning(msg) 
    11041104 
    11051105class PlottableFit1D(Plottable): 
  • src/sas/qtgui/Plotting/Plotter.py

    rf0bb711 reb1a386  
    1 from PyQt4 import QtGui 
    2 from PyQt4 import QtCore 
     1from PyQt5 import QtCore 
     2from PyQt5 import QtGui 
     3from PyQt5 import QtWidgets 
     4 
    35import functools 
    46import copy 
     
    3941        self.fit_result.name = "Fit" 
    4042 
    41         # Add a slot for receiving update signal from LinearFit 
    42         # NEW style signals 
    43         #self.updatePlot = QtCore.pyqtSignal(tuple) 
    44         # self.updatePlot.connect(self.onFitDisplay) 
    45         # OLD style signals 
    46         QtCore.QObject.connect(self, QtCore.SIGNAL('updatePlot'), self.onFitDisplay) 
    47  
    4843    @property 
    4944    def data(self): 
     
    5449        """ data setter """ 
    5550        self._data = value 
    56         self.xLabel = "%s(%s)"%(value._xaxis, value._xunit) 
    57         self.yLabel = "%s(%s)"%(value._yaxis, value._yunit) 
     51        if value._xunit: 
     52            self.xLabel = "%s(%s)"%(value._xaxis, value._xunit) 
     53        else: 
     54            self.xLabel = "%s"%(value._xaxis) 
     55        if value._yunit: 
     56            self.yLabel = "%s(%s)"%(value._yaxis, value._yunit) 
     57        else: 
     58            self.yLabel = "%s"%(value._yaxis) 
     59 
     60        if value.scale == 'linear' or value.isSesans: 
     61            self.xscale = 'linear' 
     62            self.yscale = 'linear' 
    5863        self.title(title=value.name) 
    5964 
     
    8590            # Try name first 
    8691            try: 
    87                 marker = PlotUtilities.SHAPES[marker] 
     92                marker = dict(PlotUtilities.SHAPES)[marker] 
    8893            except KeyError: 
    89                 marker = PlotUtilities.SHAPES.values()[marker] 
     94                marker = list(PlotUtilities.SHAPES.values())[marker] 
    9095 
    9196        assert marker is not None 
     
    165170 
    166171        # refresh canvas 
    167         self.canvas.draw() 
     172        self.canvas.draw_idle() 
    168173 
    169174    def createContextMenu(self): 
     
    203208        Adds operations on all plotted sets of data to the context menu 
    204209        """ 
    205         for id in self.plot_dict.keys(): 
     210        for id in list(self.plot_dict.keys()): 
    206211            plot = self.plot_dict[id] 
    207212 
     
    269274        Show a dialog allowing axes rescaling 
    270275        """ 
    271         if self.properties.exec_() == QtGui.QDialog.Accepted: 
     276        if self.properties.exec_() == QtWidgets.QDialog.Accepted: 
    272277            self.xLogLabel, self.yLogLabel = self.properties.getValues() 
    273278            self.xyTransform(self.xLogLabel, self.yLogLabel) 
     
    277282        Show a dialog allowing adding custom text to the chart 
    278283        """ 
    279         if self.addText.exec_() == QtGui.QDialog.Accepted: 
    280             # Retrieve the new text, its font and color 
    281             extra_text = self.addText.text() 
    282             extra_font = self.addText.font() 
    283             extra_color = self.addText.color() 
    284  
    285             # Place the text on the screen at (0,0) 
    286             pos_x = self.x_click 
    287             pos_y = self.y_click 
    288  
    289             # Map QFont onto MPL font 
    290             mpl_font = FontProperties() 
    291             mpl_font.set_size(int(extra_font.pointSize())) 
    292             mpl_font.set_family(str(extra_font.family())) 
    293             mpl_font.set_weight(int(extra_font.weight())) 
    294             # MPL style names 
    295             styles = ['normal', 'italic', 'oblique'] 
    296             # QFont::Style maps directly onto the above 
    297             try: 
    298                 mpl_font.set_style(styles[extra_font.style()]) 
    299             except: 
    300                 pass 
    301  
    302             if len(extra_text) > 0: 
    303                 new_text = self.ax.text(str(pos_x), 
    304                                         str(pos_y), 
    305                                         extra_text, 
    306                                         color=extra_color, 
    307                                         fontproperties=mpl_font) 
    308                 # Update the list of annotations 
    309                 self.textList.append(new_text) 
    310                 self.canvas.draw_idle() 
     284        if self.addText.exec_() != QtWidgets.QDialog.Accepted: 
     285            return 
     286 
     287        # Retrieve the new text, its font and color 
     288        extra_text = self.addText.text() 
     289        extra_font = self.addText.font() 
     290        extra_color = self.addText.color() 
     291 
     292        # Place the text on the screen at the click location 
     293        pos_x = self.x_click 
     294        pos_y = self.y_click 
     295 
     296        # Map QFont onto MPL font 
     297        mpl_font = FontProperties() 
     298        mpl_font.set_size(int(extra_font.pointSize())) 
     299        mpl_font.set_family(str(extra_font.family())) 
     300        mpl_font.set_weight(int(extra_font.weight())) 
     301        # MPL style names 
     302        styles = ['normal', 'italic', 'oblique'] 
     303        # QFont::Style maps directly onto the above 
     304        try: 
     305            mpl_font.set_style(styles[extra_font.style()]) 
     306        except: 
     307            pass 
     308 
     309        if len(extra_text) > 0: 
     310            new_text = self.ax.text(pos_x, 
     311                                    pos_y, 
     312                                    extra_text, 
     313                                    color=extra_color, 
     314                                    fontproperties=mpl_font) 
     315 
     316            # Update the list of annotations 
     317            self.textList.append(new_text) 
     318            self.canvas.draw() 
    311319 
    312320    def onRemoveText(self): 
     
    319327        txt = self.textList[num_text - 1] 
    320328        text_remove = txt.get_text() 
    321         txt.remove() 
     329        try: 
     330            txt.remove() 
     331        except ValueError: 
     332            # Text got already deleted somehow 
     333            pass 
    322334        self.textList.remove(txt) 
    323335 
     
    329341        """ 
    330342        # min and max of data 
    331         if self.setRange.exec_() == QtGui.QDialog.Accepted: 
     343        if self.setRange.exec_() == QtWidgets.QDialog.Accepted: 
    332344            x_range = self.setRange.xrange() 
    333345            y_range = self.setRange.yrange() 
     
    363375                    xlabel=self.xLogLabel, 
    364376                    ylabel=self.yLogLabel) 
    365         if fit_dialog.exec_() == QtGui.QDialog.Accepted: 
     377        fit_dialog.updatePlot.connect(self.onFitDisplay) 
     378        if fit_dialog.exec_() == QtWidgets.QDialog.Accepted: 
    366379            return 
    367380 
     
    388401        Deletes the selected plot from the chart 
    389402        """ 
    390         if id not in self.plot_dict.keys(): 
     403        if id not in list(self.plot_dict.keys()): 
    391404            return 
    392405 
     
    440453                                marker_size=marker_size, 
    441454                                legend=legend) 
    442         if plotPropertiesWidget.exec_() == QtGui.QDialog.Accepted: 
     455        if plotPropertiesWidget.exec_() == QtWidgets.QDialog.Accepted: 
    443456            # Update Data1d 
    444457            selected_plot.markersize = plotPropertiesWidget.markersize() 
     
    479492        """ 
    480493        # Transform all the plots on the chart 
    481         for id in self.plot_dict.keys(): 
     494        for id in list(self.plot_dict.keys()): 
    482495            current_plot = self.plot_dict[id] 
    483496            if current_plot.id == "fit": 
     
    614627        """ 
    615628        ax = event.inaxes 
    616         if ax == None: 
     629        if ax is None: 
    617630            return 
    618631        # Event occurred inside a plotting area 
     
    649662        step = event.step 
    650663 
    651         if ax != None: 
     664        if ax is not None: 
    652665            # Event occurred inside a plotting area 
    653666            lo, hi = ax.get_xlim() 
     
    697710 
    698711 
    699 class Plotter(QtGui.QDialog, PlotterWidget): 
     712class Plotter(QtWidgets.QDialog, PlotterWidget): 
    700713    def __init__(self, parent=None, quickplot=False): 
    701714 
    702         QtGui.QDialog.__init__(self) 
     715        QtWidgets.QDialog.__init__(self) 
    703716        PlotterWidget.__init__(self, parent=self, manager=parent, quickplot=quickplot) 
    704717        icon = QtGui.QIcon() 
  • src/sas/qtgui/Plotting/Plotter2D.py

    rf4a1433 rd6b8a1d  
    33import pylab 
    44import functools 
    5  
    6 from PyQt4 import QtGui 
    7 from PyQt4 import QtCore 
     5import logging 
     6 
     7from PyQt5 import QtCore 
     8from PyQt5 import QtGui 
     9from PyQt5 import QtWidgets 
    810 
    911DEFAULT_CMAP = pylab.cm.jet 
     12 
     13#import sys 
     14#print("SYS.PATH = ", sys.path) 
     15import matplotlib as mpl 
     16mpl.use("Qt5Agg") 
     17 
    1018from mpl_toolkits.mplot3d import Axes3D 
    1119 
     
    116124        """ 
    117125        # Toggle the scale 
    118         zmin_temp = self.zmin 
     126        zmin_temp = self.zmin if self.zmin else MIN_Z 
    119127        zmax_temp = self.zmax 
    120128        # self.scale predefined in the baseclass 
     129        # in numpy > 1.12 power(int, -int) raises ValueException 
     130        # "Integers to negative integer powers are not allowed." 
    121131        if self.scale == 'log_{10}': 
    122132            if self.zmin is not None: 
    123                 zmin_temp = numpy.power(10, self.zmin) 
     133                zmin_temp = numpy.power(10.0, self.zmin) 
    124134            if self.zmax is not None: 
    125                 zmax_temp = numpy.power(10, self.zmax) 
     135                zmax_temp = numpy.power(10.0, self.zmax) 
    126136        else: 
    127137            if self.zmin is not None: 
     
    236246        self.slicer_widget.close_signal.connect(slicer_closed) 
    237247        # Add the plot to the workspace 
    238         self.manager.parent.workspace().addWindow(self.slicer_widget) 
     248        self.manager.parent.workspace().addSubWindow(self.slicer_widget) 
    239249 
    240250        self.slicer_widget.show() 
     
    281291        new_plot.id = "Circ avg " + self.data.name 
    282292        new_plot.is_data = True 
    283         variant_plot = QtCore.QVariant(new_plot) 
    284         GuiUtils.updateModelItemWithPlot(self._item, variant_plot, new_plot.id) 
     293        GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
     294 
    285295        self.manager.communicator.plotUpdateSignal.emit([new_plot]) 
    286296 
     
    338348        self.boxwidget = BoxSum(self, model=self.box_sum_model) 
    339349        # Add the plot to the workspace 
    340         self.manager.parent.workspace().addWindow(self.boxwidget) 
     350        self.manager.parent.workspace().addSubWindow(self.boxwidget) 
    341351        self.boxwidget.show() 
    342352 
     
    366376        color_map_dialog.apply_signal.connect(self.onApplyMap) 
    367377 
    368         if color_map_dialog.exec_() == QtGui.QDialog.Accepted: 
     378        if color_map_dialog.exec_() == QtWidgets.QDialog.Accepted: 
    369379            self.onApplyMap(color_map_dialog.norm(), color_map_dialog.cmap()) 
    370380 
     
    504514 
    505515 
    506 class Plotter2D(QtGui.QDialog, Plotter2DWidget): 
     516class Plotter2D(QtWidgets.QDialog, Plotter2DWidget): 
    507517    """ 
    508518    Plotter widget implementation 
    509519    """ 
    510520    def __init__(self, parent=None, quickplot=False, dimension=2): 
    511         QtGui.QDialog.__init__(self) 
     521        QtWidgets.QDialog.__init__(self) 
    512522        Plotter2DWidget.__init__(self, manager=parent, quickplot=quickplot, dimension=dimension) 
    513523        icon = QtGui.QIcon() 
  • src/sas/qtgui/Plotting/PlotterBase.py

    r7d8bebf reb1a386  
    22import numpy 
    33 
    4 from PyQt4 import QtGui 
    5 from PyQt4 import QtCore 
    6  
    7 # TODO: Replace the qt4agg calls below with qt5 equivalent. 
    8 # Requires some code modifications. 
    9 # https://www.boxcontrol.net/embedding-matplotlib-plot-on-pyqt5-gui.html 
    10 # 
    11 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
    12 from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar 
     4from PyQt5 import QtCore 
     5from PyQt5 import QtGui 
     6from PyQt5 import QtWidgets, QtPrintSupport 
     7 
     8from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 
     9from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar 
    1310 
    1411import matplotlib.pyplot as plt 
     
    2522import sas.qtgui.Plotting.PlotUtilities as PlotUtilities 
    2623 
    27 class PlotterBase(QtGui.QWidget): 
     24class PlotterBase(QtWidgets.QWidget): 
    2825    def __init__(self, parent=None, manager=None, quickplot=False): 
    2926        super(PlotterBase, self).__init__(parent) 
     
    3330        self.quickplot = quickplot 
    3431 
     32        #plt.style.use('ggplot') 
     33        #plt.style.use('seaborn-darkgrid') 
     34 
    3535        # a figure instance to plot on 
    3636        self.figure = plt.figure() 
     
    4343 
    4444        # Simple window for data display 
    45         self.txt_widget = QtGui.QTextEdit(None) 
     45        self.txt_widget = QtWidgets.QTextEdit(None) 
    4646 
    4747        # Set the layout and place the canvas widget in it. 
    48         layout = QtGui.QVBoxLayout() 
    49         layout.setMargin(0) 
     48        layout = QtWidgets.QVBoxLayout() 
     49        # FIXME setMargin -> setContentsMargins in qt5 with 4 args 
     50        #layout.setContentsMargins(0) 
    5051        layout.addWidget(self.canvas) 
    5152 
     
    105106        self.canvas.mpl_connect('scroll_event', self.onMplWheel) 
    106107 
    107         self.contextMenu = QtGui.QMenu(self) 
     108        self.contextMenu = QtWidgets.QMenu(self) 
    108109 
    109110        if not quickplot: 
     
    139140    def xLabel(self, xlabel=""): 
    140141        """ x-label setter """ 
    141         self.x_label = r'$%s$'% xlabel 
     142        self.x_label = r'$%s$'% xlabel if xlabel else "" 
    142143 
    143144    @property 
     
    149150    def yLabel(self, ylabel=""): 
    150151        """ y-label setter """ 
    151         self.y_label = r'$%s$'% ylabel 
     152        self.y_label = r'$%s$'% ylabel if ylabel else "" 
    152153 
    153154    @property 
     
    170171    def xscale(self, scale='linear'): 
    171172        """ X-axis scale setter """ 
     173        self.ax.cla() 
    172174        self.ax.set_xscale(scale) 
    173175        self._xscale = scale 
     
    290292        """ 
    291293        # Define the printer 
    292         printer = QtGui.QPrinter() 
     294        printer = QtPrintSupport.QPrinter() 
    293295 
    294296        # Display the print dialog 
    295         dialog = QtGui.QPrintDialog(printer) 
     297        dialog = QtPrintSupport.QPrintDialog(printer) 
    296298        dialog.setModal(True) 
    297299        dialog.setWindowTitle("Print") 
    298         if dialog.exec_() != QtGui.QDialog.Accepted: 
     300        if dialog.exec_() != QtWidgets.QDialog.Accepted: 
    299301            return 
    300302 
    301303        painter = QtGui.QPainter(printer) 
    302304        # Grab the widget screenshot 
    303         pmap = QtGui.QPixmap.grabWidget(self) 
     305        pmap = QtGui.QPixmap(self.size()) 
     306        self.render(pmap) 
    304307        # Create a label with pixmap drawn 
    305         printLabel = QtGui.QLabel() 
     308        printLabel = QtWidgets.QLabel() 
    306309        printLabel.setPixmap(pmap) 
    307310 
     
    314317        Copy MPL widget area to buffer 
    315318        """ 
    316         bmp = QtGui.QApplication.clipboard() 
    317         pixmap = QtGui.QPixmap.grabWidget(self.canvas) 
     319        bmp = QtWidgets.QApplication.clipboard() 
     320        pixmap = QtGui.QPixmap(self.canvas.size()) 
     321        self.canvas.render(pixmap) 
    318322        bmp.setPixmap(pixmap) 
    319323 
     
    333337        titleWidget = WindowTitle(self, new_title=current_title) 
    334338        result = titleWidget.exec_() 
    335         if result != QtGui.QDialog.Accepted: 
     339        if result != QtWidgets.QDialog.Accepted: 
    336340            return 
    337341 
     
    371375        # Move the slider all the way up, if present 
    372376        vertical_scroll_bar = self.txt_widget.verticalScrollBar() 
    373         vertical_scroll_bar.triggerAction(QtGui.QScrollBar.SliderToMinimum) 
     377        vertical_scroll_bar.triggerAction(QtWidgets.QScrollBar.SliderToMinimum) 
    374378 
    375379    def onSavePoints(self, plot_data): 
  • src/sas/qtgui/Plotting/PlotterData.py

    • Property mode changed from 100755 to 100644
    rfef38e8 rcee5c78  
    5454        self.yaxis(data1d._yaxis, data1d._yunit) 
    5555        self.title = data1d.title 
     56        self.isSesans = data1d.isSesans 
    5657         
    5758    def __str__(self): 
     
    7172        result.clone_without_data(length=len(self.x), clone=self) 
    7273        result.copy_from_datainfo(data1d=self) 
    73         if self.dxw == None: 
     74        if self.dxw is None: 
    7475            result.dxw = None 
    7576        else: 
    7677            result.dxw = numpy.zeros(len(self.x)) 
    77         if self.dxl == None: 
     78        if self.dxl is None: 
    7879            result.dxl = None 
    7980        else: 
     
    118119        tot_length = len(self.x) + len(other.x) 
    119120        result = self.clone_without_data(length=tot_length, clone=result) 
    120         if self.dy == None or other.dy is None: 
     121        if self.dy is None or other.dy is None: 
    121122            result.dy = None 
    122123        else: 
    123124            result.dy = numpy.zeros(tot_length) 
    124         if self.dx == None or other.dx is None: 
     125        if self.dx is None or other.dx is None: 
    125126            result.dx = None 
    126127        else: 
    127128            result.dx = numpy.zeros(tot_length) 
    128         if self.dxw == None or other.dxw is None: 
     129        if self.dxw is None or other.dxw is None: 
    129130            result.dxw = None 
    130131        else: 
    131132            result.dxw = numpy.zeros(tot_length) 
    132         if self.dxl == None or other.dxl is None: 
     133        if self.dxl is None or other.dxl is None: 
    133134            result.dxl = None 
    134135        else: 
     
    141142        result.y = numpy.append(self.y, other.y) 
    142143        result.y = result.y[ind] 
    143         if result.dy != None: 
     144        if result.dy is not None: 
    144145            result.dy = numpy.append(self.dy, other.dy) 
    145146            result.dy = result.dy[ind] 
     
    238239        result.ymin = self.ymin 
    239240        result.ymax = self.ymax 
    240         if self.dqx_data == None or self.dqy_data == None: 
     241        if self.dqx_data is None or self.dqy_data is None: 
    241242            result.dqx_data = None 
    242243            result.dqy_data = None 
     
    301302        result.ymin = self.ymin 
    302303        result.ymax = self.ymax 
    303         if self.dqx_data == None or self.dqy_data == None or \ 
    304                 other.dqx_data == None or other.dqy_data == None : 
     304        if self.dqx_data is None or self.dqy_data is None or \ 
     305                other.dqx_data is None or other.dqy_data is None : 
    305306            result.dqx_data = None 
    306307            result.dqy_data = None 
  • src/sas/qtgui/Plotting/ScaleProperties.py

    rcd2cc745 r4992ff2  
    1 from PyQt4 import QtGui 
     1from PyQt5 import QtCore 
     2from PyQt5 import QtGui 
     3from PyQt5 import QtWidgets 
    24 
    35import sas.sasview 
     
    2022    view_values[5]: [0, 4], # Kratky 
    2123} 
    22 class ScaleProperties(QtGui.QDialog, Ui_scalePropertiesUI): 
     24class ScaleProperties(QtWidgets.QDialog, Ui_scalePropertiesUI): 
    2325    def __init__(self, parent=None, init_scale_x='x', init_scale_y='y'): 
    2426        super(ScaleProperties, self).__init__(parent) 
  • src/sas/qtgui/Plotting/SetGraphRange.py

    rcd2cc745 rd6b8a1d  
    22Allows users to change the range of the current graph 
    33""" 
    4 from PyQt4 import QtGui 
     4from PyQt5 import QtCore 
     5from PyQt5 import QtGui 
     6from PyQt5 import QtWidgets 
     7 
     8import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    59 
    610# Local UI 
     
    812from sas.qtgui.Plotting.UI.SetGraphRangeUI import Ui_setGraphRangeUI 
    913 
    10 class SetGraphRange(QtGui.QDialog, Ui_setGraphRangeUI): 
     14class SetGraphRange(QtWidgets.QDialog, Ui_setGraphRangeUI): 
    1115    def __init__(self, parent=None, x_range=(0.0, 0.0), y_range=(0.0, 0.0)): 
    1216        super(SetGraphRange, self).__init__() 
     
    1620        assert(isinstance(y_range, tuple)) 
    1721 
    18         self.txtXmin.setValidator(QtGui.QDoubleValidator()) 
    19         self.txtXmax.setValidator(QtGui.QDoubleValidator()) 
    20         self.txtYmin.setValidator(QtGui.QDoubleValidator()) 
    21         self.txtYmax.setValidator(QtGui.QDoubleValidator()) 
     22        self.txtXmin.setValidator(GuiUtils.DoubleValidator()) 
     23        self.txtXmax.setValidator(GuiUtils.DoubleValidator()) 
     24        self.txtYmin.setValidator(GuiUtils.DoubleValidator()) 
     25        self.txtYmax.setValidator(GuiUtils.DoubleValidator()) 
    2226 
    2327        self.txtXmin.setText(str(x_range[0])) 
  • src/sas/qtgui/Plotting/SlicerModel.py

    r83eb5208 rd6b8a1d  
    1 from PyQt4 import QtGui 
    2 from PyQt4 import QtCore 
     1from PyQt5 import QtGui 
     2from PyQt5 import QtCore 
    33 
    44import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     
    1919        self._model.removeRows( 0, self._model.rowCount() ) 
    2020        # Crete/overwrite model items 
    21         for parameter in parameters.keys(): 
     21        for parameter in list(parameters.keys()): 
    2222            item1 = QtGui.QStandardItem(parameter) 
    2323            item2 = QtGui.QStandardItem(GuiUtils.formatNumber(parameters[parameter])) 
    2424            self._model.appendRow([item1, item2]) 
    25         self._model.setHeaderData(0, QtCore.Qt.Horizontal, QtCore.QVariant("Parameter")) 
    26         self._model.setHeaderData(1, QtCore.Qt.Horizontal, QtCore.QVariant("Value")) 
     25        self._model.setHeaderData(0, QtCore.Qt.Horizontal, "Parameter") 
     26        self._model.setHeaderData(1, QtCore.Qt.Horizontal, "Value") 
    2727 
    2828    def setParamsFromModel(self, item): 
  • src/sas/qtgui/Plotting/SlicerParameters.py

    rcd2cc745 re90988c  
    44import numpy 
    55import functools 
    6 from PyQt4 import QtGui 
    7 from PyQt4 import QtCore 
    8 from PyQt4 import QtWebKit 
     6from PyQt5 import QtCore 
     7from PyQt5 import QtGui 
     8from PyQt5 import QtWidgets 
     9 
     10import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    911 
    1012# Local UI 
     
    1214from sas.qtgui.Plotting.UI.SlicerParametersUI import Ui_SlicerParametersUI 
    1315 
    14 class SlicerParameters(QtGui.QDialog, Ui_SlicerParametersUI): 
     16class SlicerParameters(QtWidgets.QDialog, Ui_SlicerParametersUI): 
    1517    """ 
    1618    Interaction between the QTableView and the underlying model, 
     
    4446 
    4547        # Display Help on clicking the button 
    46         self.buttonBox.button(QtGui.QDialogButtonBox.Help).clicked.connect(self.onHelp) 
     48        self.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect(self.onHelp) 
    4749 
    4850        # Close doesn't trigger closeEvent automatically, so force it 
    49         self.buttonBox.button(QtGui.QDialogButtonBox.Close).clicked.connect(functools.partial(self.closeEvent, None)) 
     51        self.buttonBox.button(QtWidgets.QDialogButtonBox.Close).clicked.connect(functools.partial(self.closeEvent, None)) 
    5052 
    5153        # Disable row number display 
    5254        self.lstParams.verticalHeader().setVisible(False) 
    5355        self.lstParams.setAlternatingRowColors(True) 
    54         self.lstParams.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding) 
     56        self.lstParams.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding) 
    5557 
    5658        # Header properties for nicer display 
    5759        header = self.lstParams.horizontalHeader() 
    58         header.setResizeMode(QtGui.QHeaderView.Stretch) 
     60        header.setSectionResizeMode(QtWidgets.QHeaderView.Stretch) 
    5961        header.setStretchLastSection(True) 
    6062 
     
    8486        Display generic data averaging help 
    8587        """ 
    86         location = "docs/sphinx-docs/build/html" + \ 
    87             "/user/sasgui/guiframe/graph_help.html#d-data-averaging" 
    88         self.helpView = QtWebKit.QWebView() 
    89         self.helpView.load(QtCore.QUrl(location)) 
    90         self.helpView.show() 
     88        location = "/user/sasgui/guiframe/graph_help.html#d-data-averaging" 
     89        self.parent.showHelp(location) 
    9190 
    9291 
    93 class ProxyModel(QtGui.QIdentityProxyModel): 
     92class ProxyModel(QtCore.QIdentityProxyModel): 
    9493    """ 
    9594    Trivial proxy model with custom column edit flag 
     
    117116        return flags 
    118117 
    119 class PositiveDoubleEditor(QtGui.QLineEdit): 
     118class PositiveDoubleEditor(QtWidgets.QLineEdit): 
    120119    # a signal to tell the delegate when we have finished editing 
    121120    editingFinished = QtCore.Signal() 
     
    125124            super(PositiveDoubleEditor, self).__init__(parent) 
    126125            self.setAutoFillBackground(True) 
    127             validator = QtGui.QDoubleValidator() 
     126            validator = GuiUtils.DoubleValidator() 
    128127            # Don't use the scientific notation, cause 'e'. 
    129             validator.setNotation(QtGui.QDoubleValidator.StandardNotation) 
     128            validator.setNotation(GuiUtils.DoubleValidator.StandardNotation) 
    130129 
    131130            self.setValidator(validator) 
     
    136135 
    137136 
    138 class EditDelegate(QtGui.QStyledItemDelegate): 
     137class EditDelegate(QtWidgets.QStyledItemDelegate): 
    139138    refocus_signal = QtCore.pyqtSignal(int, int) 
    140139    def __init__(self, parent=None, validate_method=None): 
     
    155154                return self.editor 
    156155        else: 
    157                 return QtGui.QStyledItemDelegate.createEditor(self, parent, option, index) 
     156                return QtWidgets.QStyledItemDelegate.createEditor(self, parent, option, index) 
    158157 
    159158    def setModelData(self, editor, model, index): 
  • src/sas/qtgui/Plotting/Slicers/AnnulusSlicer.py

    • Property mode changed from 100755 to 100644
    rdc5ef15 r4992ff2  
    11import numpy 
    2 from PyQt4 import QtGui 
    3 from PyQt4 import QtCore 
    42 
    53import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    6 from BaseInteractor import BaseInteractor 
     4from .BaseInteractor import BaseInteractor 
    75from sas.qtgui.Plotting.PlotterData import Data1D 
    86from sas.qtgui.Utilities.GuiUtils import formatNumber 
     
    145143        new_plot.xtransform = "x" 
    146144        new_plot.ytransform = "y" 
    147         variant_plot = QtCore.QVariant(new_plot) 
    148         GuiUtils.updateModelItemWithPlot(self._item, variant_plot, new_plot.id) 
     145        GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
    149146        self.base.manager.communicator.plotUpdateSignal.emit([new_plot]) 
    150147 
  • src/sas/qtgui/Plotting/Slicers/Arc.py

    re7a0b2f rd744767  
    44import math 
    55 
    6 from BaseInteractor import BaseInteractor 
     6from .BaseInteractor import BaseInteractor 
    77 
    88class ArcInteractor(BaseInteractor): 
     
    7070        x = [] 
    7171        y = [] 
    72         if theta1 != None: 
     72        if theta1 is not None: 
    7373            self.theta1 = theta1 
    74         if theta2 != None: 
     74        if theta2 is not None: 
    7575            self.theta2 = theta2 
    7676        while self.theta2 < self.theta1: 
     
    8080        npts = int((self.theta2 - self.theta1) / (math.pi / 120)) 
    8181 
    82         if r == None: 
     82        if r is None: 
    8383            self.radius = math.sqrt(math.pow(self._mouse_x, 2) + \ 
    8484                                     math.pow(self._mouse_y, 2)) 
  • src/sas/qtgui/Plotting/Slicers/AzimutSlicer.py

    rdc5ef15 rb3e8629  
    55# 
    66import math 
    7 from BaseInteractor import BaseInteractor 
     7from .BaseInteractor import BaseInteractor 
    88 
    99class SectorInteractor(BaseInteractor): 
     
    2626 
    2727        # Inner circle 
    28         from Arc import ArcInteractor 
     28        from .Arc import ArcInteractor 
    2929        self.inner_circle = ArcInteractor(self, self.base.subplot, 
    3030                                          zorder=zorder, 
  • src/sas/qtgui/Plotting/Slicers/BoxSlicer.py

    • Property mode changed from 100755 to 100644
    rdc5ef15 r4992ff2  
    11import numpy 
    2 from PyQt4 import QtGui 
    3 from PyQt4 import QtCore 
    4  
    5 from BaseInteractor import BaseInteractor 
     2 
     3from .BaseInteractor import BaseInteractor 
    64from sas.qtgui.Plotting.PlotterData import Data1D 
    75import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     
    136134            if new_slab is None: 
    137135                msg = "post data:cannot average , averager is empty" 
    138                 raise ValueError, msg 
     136                raise ValueError(msg) 
    139137            self.averager = new_slab 
    140138        if self.direction == "X": 
     
    152150        else: 
    153151            msg = "post data:no Box Average direction was supplied" 
    154             raise ValueError, msg 
     152            raise ValueError(msg) 
    155153        # # Average data2D given Qx or Qy 
    156154        box = self.averager(x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, 
     
    190188        new_plot.id = (self.averager.__name__) + self.base.data.name 
    191189        new_plot.is_data = True 
    192         variant_plot = QtCore.QVariant(new_plot) 
    193         GuiUtils.updateModelItemWithPlot(self._item, variant_plot, new_plot.id) 
     190        GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
    194191 
    195192        if self.update_model: 
  • src/sas/qtgui/Plotting/Slicers/BoxSum.py

    • Property mode changed from 100755 to 100644
    rdc5ef15 rfbfc488  
    44""" 
    55import numpy 
    6 from PyQt4 import QtGui 
    7 from PyQt4 import QtCore 
    8 from sas.qtgui.Utilities.GuiUtils import formatNumber 
    9  
    10 from BaseInteractor import BaseInteractor 
     6from PyQt5 import QtGui 
     7 
     8from sas.qtgui.Utilities.GuiUtils import formatNumber, toDouble 
     9 
     10from .BaseInteractor import BaseInteractor 
    1111from sas.sascalc.dataloader.manipulations import Boxavg 
    1212from sas.sascalc.dataloader.manipulations import Boxsum 
     
    110110        parameters = self.getParams() 
    111111        # Crete/overwrite model items 
    112         self._model.setData(self._model.index(0, 0), 
    113                     QtCore.QVariant(formatNumber(parameters['Height']))) 
    114         self._model.setData(self._model.index(0, 1), 
    115                     QtCore.QVariant(formatNumber(parameters['Width']))) 
    116         self._model.setData(self._model.index(0, 2), 
    117                     QtCore.QVariant(formatNumber(parameters['center_x']))) 
    118         self._model.setData(self._model.index(0, 3), 
    119                     QtCore.QVariant(formatNumber(parameters['center_y']))) 
     112        self._model.setData(self._model.index(0, 0), formatNumber(parameters['Height'])) 
     113        self._model.setData(self._model.index(0, 1), formatNumber(parameters['Width'])) 
     114        self._model.setData(self._model.index(0, 2), formatNumber(parameters['center_x'])) 
     115        self._model.setData(self._model.index(0, 3), formatNumber(parameters['center_y'])) 
    120116 
    121117        self.setReadOnlyParametersFromModel() 
     
    130126        """ 
    131127        parameters = self.getParams() 
    132         self._model.setData(self._model.index(0, 4), 
    133                     QtCore.QVariant(formatNumber(parameters['avg']))) 
    134         self._model.setData(self._model.index(0, 5), 
    135                     QtCore.QVariant(formatNumber(parameters['avg_error']))) 
    136         self._model.setData(self._model.index(0, 6), 
    137                     QtCore.QVariant(formatNumber(parameters['sum']))) 
    138         self._model.setData(self._model.index(0, 7), 
    139                     QtCore.QVariant(formatNumber(parameters['sum_error']))) 
    140         self._model.setData(self._model.index(0, 8), 
    141                     QtCore.QVariant(formatNumber(parameters['num_points']))) 
     128        self._model.setData(self._model.index(0, 4), formatNumber(parameters['avg'])) 
     129        self._model.setData(self._model.index(0, 5), formatNumber(parameters['avg_error'])) 
     130        self._model.setData(self._model.index(0, 6), formatNumber(parameters['sum'])) 
     131        self._model.setData(self._model.index(0, 7), formatNumber(parameters['sum_error'])) 
     132        self._model.setData(self._model.index(0, 8), formatNumber(parameters['num_points'])) 
    142133 
    143134    def setParamsFromModel(self): 
     
    146137        """ 
    147138        params = {} 
    148         params["Height"] = float(self.model().item(0, 0).text()) 
    149         params["Width"] = float(self.model().item(0, 1).text()) 
    150         params["center_x"] = float(self.model().item(0, 2).text()) 
    151         params["center_y"] = float(self.model().item(0, 3).text()) 
     139        params["Height"] = toDouble(self.model().item(0, 0).text()) 
     140        params["Width"] = toDouble(self.model().item(0, 1).text()) 
     141        params["center_x"] = toDouble(self.model().item(0, 2).text()) 
     142        params["center_y"] = toDouble(self.model().item(0, 3).text()) 
    152143        self.update_model = False 
    153144        self.setParams(params) 
     
    362353        Draw the new roughness on the graph. 
    363354        """ 
    364         if center_x != None: 
     355        if center_x is not None: 
    365356            self.x = center_x 
    366         if center_y != None: 
     357        if center_y is not None: 
    367358            self.y = center_y 
    368359        self.center_marker.set(xdata=[self.x], ydata=[self.y]) 
  • src/sas/qtgui/Plotting/Slicers/SectorSlicer.py

    • Property mode changed from 100755 to 100644
    rdc5ef15 rd6b8a1d  
    33""" 
    44import numpy 
    5 from PyQt4 import QtGui 
    6 from PyQt4 import QtCore 
    7  
    8 from BaseInteractor import BaseInteractor 
     5import logging 
     6 
     7from .BaseInteractor import BaseInteractor 
    98from sas.qtgui.Plotting.PlotterData import Data1D 
    109import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     
    125124        data = self.base.data 
    126125        # If we have no data, just return 
    127         if data == None: 
     126        if data is None: 
    128127            return 
    129128        # Averaging 
     
    132131        phimin = -self.left_line.phi + self.main_line.theta 
    133132        phimax = self.left_line.phi + self.main_line.theta 
    134         if nbins == None: 
     133        if nbins is None: 
    135134            nbins = 20 
    136135        sect = SectorQ(r_min=0.0, r_max=radius, 
     
    168167        new_plot.id = "SectorQ" + self.base.data.name 
    169168        new_plot.is_data = True 
    170         variant_plot = QtCore.QVariant(new_plot) 
    171         GuiUtils.updateModelItemWithPlot(self._item, variant_plot, new_plot.id) 
     169        GuiUtils.updateModelItemWithPlot(self._item, new_plot, new_plot.id) 
     170 
    172171        self.base.manager.communicator.plotUpdateSignal.emit([new_plot]) 
    173172 
     
    230229            msg = "Phi left and phi right are different" 
    231230            msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 
    232             raise ValueError, msg 
     231            raise ValueError(msg) 
    233232        params["Phi [deg]"] = self.main_line.theta * 180 / numpy.pi 
    234233        params["Delta_Phi [deg]"] = numpy.fabs(self.left_line.phi * 180 / numpy.pi) 
     
    349348        self.left_moving = left 
    350349        theta3 = 0 
    351         if phi != None: 
     350        if phi is not None: 
    352351            self.phi = phi 
    353         if delta == None: 
     352        if delta is None: 
    354353            delta = 0 
    355354        if  right: 
     
    361360            self.theta = mline.theta + self.phi 
    362361 
    363         if mline != None: 
     362        if mline is not None: 
    364363            if delta != 0: 
    365364                self.theta2 = mline + delta 
     
    509508        """ 
    510509 
    511         if theta != None: 
     510        if theta is not None: 
    512511            self.theta = theta 
    513512        x1 = self.radius * numpy.cos(self.theta) 
  • src/sas/qtgui/Plotting/UnitTesting/AddTextTest.py

    r464cd07 r53c771e  
    11import sys 
    22import unittest 
    3 from mock import MagicMock 
     3from unittest.mock import MagicMock 
    44 
    5 from PyQt4 import QtGui 
     5from PyQt5 import QtGui, QtWidgets 
    66 
    77# set up import paths 
     
    1111from sas.qtgui.Plotting.AddText import AddText 
    1212 
    13 if not QtGui.QApplication.instance(): 
    14     app = QtGui.QApplication(sys.argv) 
     13if not QtWidgets.QApplication.instance(): 
     14    app = QtWidgets.QApplication(sys.argv) 
    1515 
    1616class AddTextTest(unittest.TestCase): 
     
    2727    def testDefaults(self): 
    2828        '''Test the GUI in its default state''' 
    29         self.assertIsInstance(self.widget, QtGui.QDialog) 
     29        self.assertIsInstance(self.widget, QtWidgets.QDialog) 
    3030        self.assertIsInstance(self.widget._font, QtGui.QFont) 
    3131        self.assertEqual(self.widget._color, "black") 
     
    3434        '''Test the QFontDialog output''' 
    3535        font_1 = QtGui.QFont("Helvetica", 15) 
    36         QtGui.QFontDialog.getFont = MagicMock(return_value=(font_1, True)) 
     36        QtWidgets.QFontDialog.getFont = MagicMock(return_value=(font_1, True)) 
    3737        # Call the method 
    3838        self.widget.onFontChange(None) 
     
    4242        # See that rejecting the dialog doesn't modify the font 
    4343        font_2 = QtGui.QFont("Arial", 9) 
    44         QtGui.QFontDialog.getFont = MagicMock(return_value=(font_2, False)) 
     44        QtWidgets.QFontDialog.getFont = MagicMock(return_value=(font_2, False)) 
    4545        # Call the method 
    4646        self.widget.onFontChange(None) 
     
    5151        ''' Test the QColorDialog output''' 
    5252        new_color = QtGui.QColor("red") 
    53         QtGui.QColorDialog.getColor = MagicMock(return_value=new_color) 
     53        QtWidgets.QColorDialog.getColor = MagicMock(return_value=new_color) 
    5454        # Call the method 
    5555        self.widget.onColorChange(None) 
  • src/sas/qtgui/Plotting/UnitTesting/BoxSumTest.py

    r464cd07 r53c771e  
    11import sys 
    22import unittest 
    3 from mock import MagicMock 
     3from unittest.mock import MagicMock 
    44 
    5 from PyQt4 import QtGui 
    6 from PyQt4 import QtCore 
     5from PyQt5 import QtGui,QtWidgets 
     6from PyQt5 import QtCore 
    77 
    88# set up import paths 
     
    1212from sas.qtgui.Plotting.BoxSum import BoxSum 
    1313 
    14 if not QtGui.QApplication.instance(): 
    15     app = QtGui.QApplication(sys.argv) 
     14if not QtWidgets.QApplication.instance(): 
     15    app = QtWidgets.QApplication(sys.argv) 
    1616 
    1717class BoxSumTest(unittest.TestCase): 
     
    2323        parameters = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0] 
    2424        for index, parameter in enumerate(parameters): 
    25             model.setData(model.index(0, index), 
    26                     QtCore.QVariant(parameter)) 
     25            model.setData(model.index(0, index),parameter) 
    2726        self.widget = BoxSum(None, model=model) 
    2827 
     
    3433    def testDefaults(self): 
    3534        '''Test the GUI in its default state''' 
    36         self.assertIsInstance(self.widget.mapper.mappedWidgetAt(0), QtGui.QLineEdit) 
    37         self.assertIsInstance(self.widget.mapper.mappedWidgetAt(1), QtGui.QLineEdit) 
    38         self.assertIsInstance(self.widget.mapper.mappedWidgetAt(2), QtGui.QLineEdit) 
    39         self.assertIsInstance(self.widget.mapper.mappedWidgetAt(3), QtGui.QLineEdit) 
    40         self.assertIsInstance(self.widget.mapper.mappedWidgetAt(4), QtGui.QLabel) 
    41         self.assertIsInstance(self.widget.mapper.mappedWidgetAt(5), QtGui.QLabel) 
    42         self.assertIsInstance(self.widget.mapper.mappedWidgetAt(6), QtGui.QLabel) 
    43         self.assertIsInstance(self.widget.mapper.mappedWidgetAt(7), QtGui.QLabel) 
    44         self.assertIsInstance(self.widget.mapper.mappedWidgetAt(8), QtGui.QLabel) 
     35        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(0), QtWidgets.QLineEdit) 
     36        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(1), QtWidgets.QLineEdit) 
     37        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(2), QtWidgets.QLineEdit) 
     38        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(3), QtWidgets.QLineEdit) 
     39        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(4), QtWidgets.QLabel) 
     40        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(5), QtWidgets.QLabel) 
     41        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(6), QtWidgets.QLabel) 
     42        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(7), QtWidgets.QLabel) 
     43        self.assertIsInstance(self.widget.mapper.mappedWidgetAt(8), QtWidgets.QLabel) 
    4544         
    4645         
  • src/sas/qtgui/Plotting/UnitTesting/ColorMapTest.py

    r464cd07 r53c771e  
    33import numpy 
    44 
    5 from PyQt4 import QtGui 
    6 from mock import MagicMock 
     5from PyQt5 import QtGui, QtWidgets 
     6from unittest.mock import MagicMock 
    77import matplotlib as mpl 
    88 
     
    1818from sas.qtgui.Plotting.ColorMap import ColorMap 
    1919 
    20 if not QtGui.QApplication.instance(): 
    21     app = QtGui.QApplication(sys.argv) 
     20if not QtWidgets.QApplication.instance(): 
     21    app = QtWidgets.QApplication(sys.argv) 
    2222 
    2323class ColorMapTest(unittest.TestCase): 
     
    4848    def testDefaults(self): 
    4949        '''Test the GUI in its default state''' 
    50         self.assertIsInstance(self.widget, QtGui.QDialog) 
     50        self.assertIsInstance(self.widget, QtWidgets.QDialog) 
    5151 
    5252        self.assertEqual(self.widget._cmap_orig, "jet") 
    53         self.assertEqual(len(self.widget.all_maps), 144) 
    54         self.assertEqual(len(self.widget.maps), 72) 
    55         self.assertEqual(len(self.widget.rmaps), 72) 
     53        self.assertEqual(len(self.widget.all_maps), 160) 
     54        self.assertEqual(len(self.widget.maps), 80) 
     55        self.assertEqual(len(self.widget.rmaps), 80) 
    5656 
    5757        self.assertEqual(self.widget.lblWidth.text(), "0") 
     
    6060        self.assertEqual(self.widget.lblStopRadius.text(), "-1") 
    6161        self.assertFalse(self.widget.chkReverse.isChecked()) 
    62         self.assertEqual(self.widget.cbColorMap.count(), 72) 
    63         self.assertEqual(self.widget.cbColorMap.currentIndex(), 60) 
     62        self.assertEqual(self.widget.cbColorMap.count(), 80) 
     63        self.assertEqual(self.widget.cbColorMap.currentIndex(), 64) 
    6464 
    6565        # validators 
     
    7070        self.assertEqual(self.widget.txtMinAmplitude.text(), "0") 
    7171        self.assertEqual(self.widget.txtMaxAmplitude.text(), "100") 
    72         self.assertIsInstance(self.widget.slider, QtGui.QSlider) 
     72        self.assertIsInstance(self.widget.slider, QtWidgets.QSlider) 
    7373 
    7474    def testOnReset(self): 
     
    111111 
    112112        # Check the combobox 
    113         self.assertEqual(self.widget.cbColorMap.currentIndex(), 55) 
     113        self.assertEqual(self.widget.cbColorMap.currentIndex(), 59) 
    114114        self.assertFalse(self.widget.chkReverse.isChecked()) 
    115115 
     
    118118        self.widget.initMapCombobox() 
    119119        # Check the combobox 
    120         self.assertEqual(self.widget.cbColorMap.currentIndex(), 56) 
     120        self.assertEqual(self.widget.cbColorMap.currentIndex(), 60) 
    121121        self.assertTrue(self.widget.chkReverse.isChecked()) 
    122122 
  • src/sas/qtgui/Plotting/UnitTesting/LinearFitTest.py

    r464cd07 r53c771e  
    33import numpy 
    44 
    5 from PyQt4 import QtGui 
    6 from mock import MagicMock 
     5from PyQt5 import QtGui, QtWidgets 
     6from unittest.mock import MagicMock 
     7 
     8from UnitTesting.TestUtils import QtSignalSpy 
    79 
    810# set up import paths 
     
    1517from sas.qtgui.Plotting.LinearFit import LinearFit 
    1618 
    17 if not QtGui.QApplication.instance(): 
    18     app = QtGui.QApplication(sys.argv) 
     19if not QtWidgets.QApplication.instance(): 
     20    app = QtWidgets.QApplication(sys.argv) 
    1921 
    2022class LinearFitTest(unittest.TestCase): 
     
    3638    def testDefaults(self): 
    3739        '''Test the GUI in its default state''' 
    38         self.assertIsInstance(self.widget, QtGui.QDialog) 
     40        self.assertIsInstance(self.widget, QtWidgets.QDialog) 
    3941        self.assertEqual(self.widget.windowTitle(), "Linear Fit") 
    4042        self.assertEqual(self.widget.txtA.text(), "1") 
     
    4850        '''Test the fitting wrapper ''' 
    4951        # Catch the update signal 
    50         self.widget.parent.emit = MagicMock() 
     52        #self.widget.updatePlot.emit = MagicMock() 
     53        #self.widget.updatePlot.emit = MagicMock() 
     54        spy_update = QtSignalSpy(self.widget, self.widget.updatePlot) 
    5155 
    5256        # Set some initial values 
     
    5761        # Run the fitting 
    5862        self.widget.fit(None) 
    59         return_values = self.widget.parent.emit.call_args[0][1] 
     63 
     64        # Expected one spy instance 
     65        self.assertEqual(spy_update.count(), 1) 
     66 
     67        return_values = spy_update.called()[0]['args'][0] 
    6068        # Compare 
    61         self.assertItemsEqual(return_values[0], [1.0, 3.0]) 
     69        self.assertCountEqual(return_values[0], [1.0, 3.0]) 
    6270        self.assertAlmostEqual(return_values[1][0], 10.004054329, 6) 
    6371        self.assertAlmostEqual(return_values[1][1], 12.030439848, 6) 
     
    6674        self.widget.x_is_log = True 
    6775        self.widget.fit(None) 
    68         return_values = self.widget.parent.emit.call_args[0][1] 
     76        self.assertEqual(spy_update.count(), 2) 
     77        return_values = spy_update.called()[1]['args'][0] 
    6978        # Compare 
    70         self.assertItemsEqual(return_values[0], [1.0, 3.0]) 
     79        self.assertCountEqual(return_values[0], [1.0, 3.0]) 
    7180        self.assertAlmostEqual(return_values[1][0], 9.987732937, 6) 
    7281        self.assertAlmostEqual(return_values[1][1], 11.84365082, 6) 
     
    8190        x, y, dy = self.widget.origData() 
    8291 
    83         self.assertItemsEqual(x, orig_x) 
     92        self.assertCountEqual(x, orig_x) 
    8493        self.assertEqual(y[0], orig_y[0]) 
    8594        self.assertAlmostEqual(y[1], orig_y[1], 8) 
     
    98107        x, y, dy = self.widget.origData() 
    99108 
    100         self.assertItemsEqual(x, orig_x) 
    101         self.assertItemsEqual(y, orig_y) 
    102         self.assertItemsEqual(dy, orig_dy) 
     109        self.assertCountEqual(x, orig_x) 
     110        self.assertCountEqual(y, orig_y) 
     111        self.assertCountEqual(dy, orig_dy) 
    103112 
    104113        # x, log(y) 
     
    111120        x, y, dy = self.widget.origData() 
    112121 
    113         self.assertItemsEqual(x, orig_x) 
     122        self.assertCountEqual(x, orig_x) 
    114123        self.assertEqual(y[0], orig_y[0]) 
    115124        self.assertAlmostEqual(y[1], orig_y[1], 8) 
  • src/sas/qtgui/Plotting/UnitTesting/PlotPropertiesTest.py

    r464cd07 r53c771e  
    11import sys 
    22import unittest 
    3 from mock import MagicMock 
     3from unittest.mock import MagicMock 
    44 
    5 from PyQt4 import QtGui 
     5from PyQt5 import QtGui, QtWidgets 
    66 
    77# set up import paths 
     
    1111from sas.qtgui.Plotting.PlotProperties import PlotProperties 
    1212 
    13 if not QtGui.QApplication.instance(): 
    14     app = QtGui.QApplication(sys.argv) 
     13if not QtWidgets.QApplication.instance(): 
     14    app = QtWidgets.QApplication(sys.argv) 
    1515 
    1616class PlotPropertiesTest(unittest.TestCase): 
     
    3232    def testDefaults(self): 
    3333        '''Test the GUI in its default state''' 
    34         self.assertIsInstance(self.widget, QtGui.QDialog) 
     34        self.assertIsInstance(self.widget, QtWidgets.QDialog) 
    3535        self.assertEqual(self.widget.windowTitle(), "Modify Plot Properties") 
    3636 
     
    5656        '''Test the response to color change event''' 
    5757        # Accept the new color 
    58         QtGui.QColorDialog.getColor = MagicMock(return_value=QtGui.QColor(255, 0, 255)) 
     58        QtWidgets.QColorDialog.getColor = MagicMock(return_value=QtGui.QColor(255, 0, 255)) 
    5959 
    6060        self.widget.onColorChange() 
     
    7272        # Cancel the dialog now 
    7373        bad_color = QtGui.QColor() # constructs an invalid color 
    74         QtGui.QColorDialog.getColor = MagicMock(return_value=bad_color) 
     74        QtWidgets.QColorDialog.getColor = MagicMock(return_value=bad_color) 
    7575        self.widget.onColorChange() 
    7676 
  • src/sas/qtgui/Plotting/UnitTesting/Plotter2DTest.py

    rb2a5042 r53c771e  
    44import platform 
    55 
    6 from PyQt4 import QtGui 
    7 from PyQt4 import QtCore 
    8 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
    9 from mock import MagicMock 
     6from PyQt5 import QtGui, QtWidgets, QtPrintSupport 
     7from PyQt5 import QtCore 
     8from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 
     9from unittest.mock import MagicMock 
    1010from mpl_toolkits.mplot3d import Axes3D 
    1111 
     
    2020import sas.qtgui.Plotting.Plotter2D as Plotter2D 
    2121 
    22 if not QtGui.QApplication.instance(): 
    23     app = QtGui.QApplication(sys.argv) 
     22if not QtWidgets.QApplication.instance(): 
     23    app = QtWidgets.QApplication(sys.argv) 
    2424 
    2525class Plotter2DTest(unittest.TestCase): 
     
    5353    def tearDown(self): 
    5454        '''destroy''' 
     55        self.plotter.figure.clf() 
    5556        self.plotter = None 
    5657 
     
    7374 
    7475        self.assertTrue(FigureCanvas.draw_idle.called) 
     76        self.plotter.figure.clf() 
    7577 
    7678    def testCalculateDepth(self): 
     
    9496        self.plotter.show() 
    9597 
    96         QtGui.QDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Accepted) 
     98        QtWidgets.QDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Accepted) 
    9799 
    98100        # Just this one plot 
     
    100102 
    101103        # Check that exec_ got called 
    102         self.assertTrue(QtGui.QDialog.exec_.called) 
     104        self.assertTrue(QtWidgets.QDialog.exec_.called) 
    103105 
    104106        self.assertEqual(self.plotter.cmap, "jet") 
    105107        self.assertAlmostEqual(self.plotter.vmin, 0.1, 6) 
    106108        self.assertAlmostEqual(self.plotter.vmax, 1e+20, 6) 
     109        self.plotter.figure.clf() 
    107110 
    108111    def testOnToggleScale(self): 
     
    115118 
    116119        self.assertTrue(FigureCanvas.draw_idle.called) 
     120        self.plotter.figure.clf() 
    117121 
    118122    def testOnBoxSum(self): 
     
    135139        self.assertTrue(self.plotter.boxwidget.isVisible()) 
    136140        self.assertIsInstance(self.plotter.boxwidget.model, QtGui.QStandardItemModel) 
     141        self.plotter.figure.clf() 
    137142 
    138143    def testContextMenuQuickPlot(self): 
     
    151156        # Trigger Print Image and make sure the method is called 
    152157        self.assertEqual(actions[1].text(), "Print Image") 
    153         QtGui.QPrintDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Rejected) 
     158        QtPrintSupport.QPrintDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Rejected) 
    154159        actions[1].trigger() 
    155         self.assertTrue(QtGui.QPrintDialog.exec_.called) 
     160        self.assertTrue(QtPrintSupport.QPrintDialog.exec_.called) 
    156161 
    157162        # Trigger Copy to Clipboard and make sure the method is called 
     
    176181        def done(): 
    177182            self.clipboard_called = True 
    178         QtCore.QObject.connect(QtGui.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
     183        QtCore.QObject.connect(QtWidgets.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
    179184        actions[2].trigger() 
    180         QtGui.qApp.processEvents() 
     185        QtWidgets.qApp.processEvents() 
    181186        # Make sure clipboard got updated. 
    182187        self.assertTrue(self.clipboard_called) 
     188        self.plotter.figure.clf() 
    183189 
    184190    def testShowNoPlot(self): 
     
    200206        self.assertFalse(FigureCanvas.draw_idle.called) 
    201207        self.assertFalse(FigureCanvas.draw.called) 
     208        self.plotter.figure.clf() 
    202209 
    203210    def testShow3DPlot(self): 
     
    220227        self.assertTrue(Axes3D.plot_surface.called) 
    221228        self.assertTrue(FigureCanvas.draw.called) 
     229        self.plotter.figure.clf() 
    222230 
    223231    def testShow2DPlot(self): 
     
    238246                              zmax=None) 
    239247        self.assertTrue(FigureCanvas.draw_idle.called) 
     248        self.plotter.figure.clf() 
    240249 
    241250 
  • src/sas/qtgui/Plotting/UnitTesting/PlotterBaseTest.py

    rb2a5042 rdd150ef  
    22import unittest 
    33import platform 
    4 from mock import patch, MagicMock 
     4from unittest.mock import MagicMock 
    55 
    6 from PyQt4 import QtGui 
     6from PyQt5 import QtGui, QtWidgets, QtPrintSupport 
    77import matplotlib.pyplot as plt 
    8 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
    9 from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar 
     8from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 
     9from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar 
    1010 
    1111####### TEMP 
     
    2121import sas.qtgui.Plotting.PlotterBase as PlotterBase 
    2222 
    23 if not QtGui.QApplication.instance(): 
    24     app = QtGui.QApplication(sys.argv) 
     23if not QtWidgets.QApplication.instance(): 
     24    app = QtWidgets.QApplication(sys.argv) 
    2525 
    2626class PlotterBaseTest(unittest.TestCase): 
     
    4545    def testDefaults(self): 
    4646        """ default method variables values """ 
    47         self.assertIsInstance(self.plotter, QtGui.QWidget) 
     47        self.assertIsInstance(self.plotter, QtWidgets.QWidget) 
    4848        self.assertIsInstance(self.plotter.canvas, FigureCanvas) 
    4949        self.assertIsInstance(self.plotter.toolbar, NavigationToolbar) 
     
    9494        ''' test the workspace print ''' 
    9595        QtGui.QPainter.end = MagicMock() 
    96         QtGui.QLabel.render = MagicMock() 
     96        QtWidgets.QLabel.render = MagicMock() 
    9797 
    9898        # First, let's cancel printing 
    99         QtGui.QPrintDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Rejected) 
     99        QtPrintSupport.QPrintDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Rejected) 
    100100        self.plotter.onImagePrint() 
    101101        self.assertFalse(QtGui.QPainter.end.called) 
    102         self.assertFalse(QtGui.QLabel.render.called) 
     102        self.assertFalse(QtWidgets.QLabel.render.called) 
    103103 
    104104        # Let's print now 
    105         QtGui.QPrintDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Accepted) 
     105        QtPrintSupport.QPrintDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Accepted) 
    106106        self.plotter.onImagePrint() 
    107107        self.assertTrue(QtGui.QPainter.end.called) 
    108         self.assertTrue(QtGui.QLabel.render.called) 
     108        self.assertTrue(QtWidgets.QLabel.render.called) 
    109109 
    110110    def testOnClipboardCopy(self): 
     
    141141        # Trigger Print Image and make sure the method is called 
    142142        self.assertEqual(actions[1].text(), "Print Image") 
    143         QtGui.QPrintDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Rejected) 
     143        QtPrintSupport.QPrintDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Rejected) 
    144144        actions[1].trigger() 
    145         self.assertTrue(QtGui.QPrintDialog.exec_.called) 
     145        self.assertTrue(QtPrintSupport.QPrintDialog.exec_.called) 
    146146 
    147147        # Trigger Copy to Clipboard and make sure the method is called 
     
    154154        def done(): 
    155155            self.clipboard_called = True 
    156         QtCore.QObject.connect(QtGui.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
     156        QtCore.QObject.connect(QtWidgets.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
    157157        actions[2].trigger() 
    158         QtGui.qApp.processEvents() 
     158        QtWidgets.qApp.processEvents() 
    159159        # Make sure clipboard got updated. 
    160160        self.assertTrue(self.clipboard_called) 
     
    163163        """ Test changing the plot title""" 
    164164        # Mock the modal dialog's response 
    165         QtGui.QDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Accepted) 
     165        QtWidgets.QDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Accepted) 
    166166        self.plotter.show() 
    167167        # Assure the original title is none 
  • src/sas/qtgui/Plotting/UnitTesting/PlotterTest.py

    rb2a5042 r63319b0  
    33import platform 
    44 
    5 from PyQt4 import QtGui 
    6 from PyQt4 import QtCore 
    7 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 
    8 from mock import MagicMock 
    9 from mock import patch 
     5from PyQt5 import QtGui, QtWidgets, QtPrintSupport 
     6from PyQt5 import QtCore 
     7from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 
     8from unittest.mock import MagicMock 
     9from unittest.mock import patch 
    1010 
    1111####### TEMP 
     
    2121import sas.qtgui.Plotting.Plotter as Plotter 
    2222 
    23 if not QtGui.QApplication.instance(): 
    24     app = QtGui.QApplication(sys.argv) 
     23if not QtWidgets.QApplication.instance(): 
     24    app = QtWidgets.QApplication(sys.argv) 
    2525 
    2626 
     
    5050        self.assertEqual(self.plotter.data, self.data) 
    5151        self.assertEqual(self.plotter._title, self.data.name) 
    52         self.assertEqual(self.plotter.xLabel, "$()$") 
    53         self.assertEqual(self.plotter.yLabel, "$()$") 
     52        self.assertEqual(self.plotter.xLabel, "") 
     53        self.assertEqual(self.plotter.yLabel, "") 
    5454 
    5555    def testPlotWithErrors(self): 
     
    5757        self.plotter.data = self.data 
    5858        self.plotter.show() 
    59         FigureCanvas.draw = MagicMock() 
     59        FigureCanvas.draw_idle = MagicMock() 
    6060 
    6161        self.plotter.plot(hide_error=False) 
    6262 
    6363        self.assertEqual(self.plotter.ax.get_xscale(), 'log') 
    64         self.assertTrue(FigureCanvas.draw.called) 
     64        self.assertTrue(FigureCanvas.draw_idle.called) 
     65 
     66        self.plotter.figure.clf() 
    6567 
    6668    def testPlotWithoutErrors(self): 
     
    6870        self.plotter.data = self.data 
    6971        self.plotter.show() 
    70         FigureCanvas.draw = MagicMock() 
     72        FigureCanvas.draw_idle = MagicMock() 
    7173 
    7274        self.plotter.plot(hide_error=True) 
    7375 
    7476        self.assertEqual(self.plotter.ax.get_yscale(), 'log') 
    75         self.assertTrue(FigureCanvas.draw.called) 
     77        self.assertTrue(FigureCanvas.draw_idle.called) 
     78        self.plotter.figure.clf() 
     79 
     80    def testPlotWithSesans(self): 
     81        """ Ensure that Sesans data is plotted in linear cooredinates""" 
     82        data = Data1D(x=[1.0, 2.0, 3.0], 
     83                      y=[10.0, 11.0, 12.0], 
     84                      dx=[0.1, 0.2, 0.3], 
     85                      dy=[0.1, 0.2, 0.3]) 
     86        data.title = "Sesans data" 
     87        data.name = "Test Sesans" 
     88        data.isSesans = True 
     89        data.id = 2 
     90 
     91        self.plotter.data = data 
     92        self.plotter.show() 
     93        FigureCanvas.draw_idle = MagicMock() 
     94 
     95        self.plotter.plot(hide_error=True) 
     96 
     97        self.assertEqual(self.plotter.ax.get_xscale(), 'linear') 
     98        self.assertEqual(self.plotter.ax.get_yscale(), 'linear') 
     99        self.assertTrue(FigureCanvas.draw_idle.called) 
    76100 
    77101    def testCreateContextMenuQuick(self): 
     
    89113        # Trigger Print Image and make sure the method is called 
    90114        self.assertEqual(actions[1].text(), "Print Image") 
    91         QtGui.QPrintDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Rejected) 
     115        QtPrintSupport.QPrintDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Rejected) 
    92116        actions[1].trigger() 
    93         self.assertTrue(QtGui.QPrintDialog.exec_.called) 
     117        self.assertTrue(QtPrintSupport.QPrintDialog.exec_.called) 
    94118 
    95119        # Trigger Copy to Clipboard and make sure the method is called 
     
    104128        # Trigger Change Scale and make sure the method is called 
    105129        self.assertEqual(actions[6].text(), "Change Scale") 
    106         self.plotter.properties.exec_ = MagicMock(return_value=QtGui.QDialog.Rejected) 
     130        self.plotter.properties.exec_ = MagicMock(return_value=QtWidgets.QDialog.Rejected) 
    107131        actions[6].trigger() 
    108132        self.assertTrue(self.plotter.properties.exec_.called) 
     
    114138        def done(): 
    115139            self.clipboard_called = True 
    116         QtCore.QObject.connect(QtGui.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
     140        QtCore.QObject.connect(QtWidgets.qApp.clipboard(), QtCore.SIGNAL("dataChanged()"), done) 
    117141        actions[2].trigger() 
    118         QtGui.qApp.processEvents() 
     142        QtWidgets.qApp.processEvents() 
    119143        # Make sure clipboard got updated. 
    120144        self.assertTrue(self.clipboard_called) 
     
    136160        self.assertEqual(len(self.plotter.plot_dict), 1) 
    137161        self.assertEqual(len(self.plotter.ax.collections), 1) 
     162        self.plotter.figure.clf() 
    138163 
    139164    def testAddText(self): 
     
    153178        self.plotter.addText.color = MagicMock(return_value = test_color) 
    154179        # Return OK from the dialog 
    155         self.plotter.addText.exec_ = MagicMock(return_value = QtGui.QDialog.Accepted) 
     180        self.plotter.addText.exec_ = MagicMock(return_value = QtWidgets.QDialog.Accepted) 
    156181        # Add text to graph 
    157182        self.plotter.onAddText() 
     
    163188        self.assertEqual(self.plotter.textList[0].get_fontproperties().get_family()[0], 'Arial') 
    164189        self.assertEqual(self.plotter.textList[0].get_fontproperties().get_size(), 16) 
     190        self.plotter.figure.clf() 
    165191 
    166192    def testOnRemoveText(self): 
     
    172198        self.plotter.addText.textEdit.setText(test_text) 
    173199        # Return OK from the dialog 
    174         self.plotter.addText.exec_ = MagicMock(return_value = QtGui.QDialog.Accepted) 
     200        self.plotter.addText.exec_ = MagicMock(return_value = QtWidgets.QDialog.Accepted) 
    175201        # Add text to graph 
     202        self.plotter.x_click = 1.0 
     203        self.plotter.y_click = 5.0 
    176204        self.plotter.onAddText() 
    177205        self.plotter.show() 
     
    188216        self.plotter.onRemoveText() 
    189217        self.assertEqual(self.plotter.textList, []) 
     218        self.plotter.figure.clf() 
    190219 
    191220    def testOnSetGraphRange(self): 
     
    195224        self.plotter.plot(self.data) 
    196225        self.plotter.show() 
    197         self.plotter.setRange.exec_ = MagicMock(return_value = QtGui.QDialog.Accepted) 
     226        self.plotter.setRange.exec_ = MagicMock(return_value = QtWidgets.QDialog.Accepted) 
    198227        self.plotter.setRange.xrange = MagicMock(return_value = new_x) 
    199228        self.plotter.setRange.yrange = MagicMock(return_value = new_y) 
     
    204233        self.assertEqual(self.plotter.ax.get_xlim(), new_x) 
    205234        self.assertEqual(self.plotter.ax.get_ylim(), new_y) 
     235        self.plotter.figure.clf() 
    206236 
    207237    def testOnResetGraphRange(self): 
     
    215245 
    216246        # mock setRange methods 
    217         self.plotter.setRange.exec_ = MagicMock(return_value = QtGui.QDialog.Accepted) 
     247        self.plotter.setRange.exec_ = MagicMock(return_value = QtWidgets.QDialog.Accepted) 
    218248        self.plotter.setRange.xrange = MagicMock(return_value = new_x) 
    219249        self.plotter.setRange.yrange = MagicMock(return_value = new_y) 
     
    228258        self.assertNotEqual(self.plotter.ax.get_xlim(), new_x) 
    229259        self.assertNotEqual(self.plotter.ax.get_ylim(), new_y) 
     260        self.plotter.figure.clf() 
    230261 
    231262    def testOnLinearFit(self): 
     
    233264        self.plotter.plot(self.data) 
    234265        self.plotter.show() 
    235         QtGui.QDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Accepted) 
     266        QtWidgets.QDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Accepted) 
    236267 
    237268        # Just this one plot 
    238         self.assertEqual(len(self.plotter.plot_dict.keys()), 1) 
     269        self.assertEqual(len(list(self.plotter.plot_dict.keys())), 1) 
    239270        self.plotter.onLinearFit(1) 
    240271 
    241272        # Check that exec_ got called 
    242         self.assertTrue(QtGui.QDialog.exec_.called) 
     273        self.assertTrue(QtWidgets.QDialog.exec_.called) 
     274        self.plotter.figure.clf() 
    243275 
    244276    def testOnRemovePlot(self): 
     
    260292 
    261293        # Assure we have two sets 
    262         self.assertEqual(len(self.plotter.plot_dict.keys()), 2) 
     294        self.assertEqual(len(list(self.plotter.plot_dict.keys())), 2) 
    263295 
    264296        # Delete one set 
    265297        self.plotter.onRemovePlot(2) 
    266298        # Assure we have two sets 
    267         self.assertEqual(len(self.plotter.plot_dict.keys()), 1) 
     299        self.assertEqual(len(list(self.plotter.plot_dict.keys())), 1) 
    268300 
    269301        self.plotter.manager = MagicMock() 
     
    272304        self.plotter.onRemovePlot(1) 
    273305        # Assure we have no plots 
    274         self.assertEqual(len(self.plotter.plot_dict.keys()), 0) 
     306        self.assertEqual(len(list(self.plotter.plot_dict.keys())), 0) 
    275307        # Assure the plotter window is closed 
    276308        self.assertFalse(self.plotter.isVisible()) 
    277  
     309        self.plotter.figure.clf() 
    278310 
    279311    def testRemovePlot(self): 
     
    306338        # The hide_error flag should also remain 
    307339        self.assertTrue(self.plotter.plot_dict[2].hide_error) 
     340        self.plotter.figure.clf() 
    308341 
    309342    def testOnToggleHideError(self): 
     
    336369        # The hide_error flag should toggle 
    337370        self.assertEqual(self.plotter.plot_dict[2].hide_error, not error_status) 
     371        self.plotter.figure.clf() 
    338372 
    339373    def testOnFitDisplay(self): 
     
    352386        self.plotter.plot.assert_called_with(data=self.plotter.fit_result, 
    353387                                             hide_error=True, marker='-') 
     388        self.plotter.figure.clf() 
    354389 
    355390    def testReplacePlot(self): 
     
    361396        xl = self.plotter.ax.xaxis.label.get_text() 
    362397        yl = self.plotter.ax.yaxis.label.get_text() 
    363         self.assertEqual(xl, "$()$") 
    364         self.assertEqual(yl, "$()$") 
     398        self.assertEqual(xl, "") 
     399        self.assertEqual(yl, "") 
    365400 
    366401        # Prepare new data 
     
    389424        # The hide_error flag should be as set 
    390425        self.assertEqual(self.plotter.plot_dict[2].hide_error, error_status) 
     426        self.plotter.figure.clf() 
    391427 
    392428    def notestOnModifyPlot(self): 
     
    408444        with patch('sas.qtgui.Plotting.PlotProperties.PlotProperties') as mock: 
    409445            instance = mock.return_value 
    410             QtGui.QDialog.exec_ = MagicMock(return_value=QtGui.QDialog.Accepted) 
     446            QtWidgets.QDialog.exec_ = MagicMock(return_value=QtWidgets.QDialog.Accepted) 
    411447            instance.symbol.return_value = 7 
    412448 
    413449            self.plotter.onModifyPlot(2) 
     450        self.plotter.figure.clf() 
    414451 
    415452 
  • src/sas/qtgui/Plotting/UnitTesting/ScalePropertiesTest.py

    r464cd07 r53c771e  
    22import unittest 
    33 
    4 from PyQt4 import QtGui 
     4from PyQt5 import QtGui, QtWidgets 
    55 
    66# set up import paths 
     
    1010from sas.qtgui.Plotting.ScaleProperties import ScaleProperties 
    1111 
    12 if not QtGui.QApplication.instance(): 
    13     app = QtGui.QApplication(sys.argv) 
     12if not QtWidgets.QApplication.instance(): 
     13    app = QtWidgets.QApplication(sys.argv) 
    1414 
    1515class ScalePropertiesTest(unittest.TestCase): 
     
    2727    def testDefaults(self): 
    2828        '''Test the GUI in its default state''' 
    29         self.assertIsInstance(self.widget, QtGui.QDialog) 
     29        self.assertIsInstance(self.widget, QtWidgets.QDialog) 
    3030        self.assertEqual(self.widget.windowTitle(), "Scale Properties") 
    3131        self.assertEqual(self.widget.cbX.count(), 6) 
  • src/sas/qtgui/Plotting/UnitTesting/SetGraphRangeTest.py

    r464cd07 r53c771e  
    22import unittest 
    33 
    4 from PyQt4 import QtGui 
     4from PyQt5 import QtGui, QtWidgets 
    55 
    66# set up import paths 
     
    1010from sas.qtgui.Plotting.SetGraphRange import SetGraphRange 
    1111 
    12 if not QtGui.QApplication.instance(): 
    13     app = QtGui.QApplication(sys.argv) 
     12if not QtWidgets.QApplication.instance(): 
     13    app = QtWidgets.QApplication(sys.argv) 
    1414 
    1515class SetGraphRangeTest(unittest.TestCase): 
     
    2727    def testDefaults(self): 
    2828        '''Test the GUI in its default state''' 
    29         self.assertIsInstance(self.widget, QtGui.QDialog) 
     29        self.assertIsInstance(self.widget, QtWidgets.QDialog) 
    3030        self.assertEqual(self.widget.windowTitle(), "Set Graph Range") 
    31         self.assertIsInstance(self.widget.txtXmin, QtGui.QLineEdit) 
     31        self.assertIsInstance(self.widget.txtXmin, QtWidgets.QLineEdit) 
    3232        self.assertIsInstance(self.widget.txtXmin.validator(), QtGui.QDoubleValidator) 
    3333         
  • src/sas/qtgui/Plotting/UnitTesting/SlicerModelTest.py

    r464cd07 r53c771e  
    11import sys 
    22import unittest 
    3 from mock import MagicMock 
     3from unittest.mock import MagicMock 
    44 
    5 from PyQt4 import QtGui 
    6 from PyQt4 import QtCore 
     5from PyQt5 import QtGui, QtWidgets 
     6from PyQt5 import QtCore 
    77 
    88# set up import paths 
     
    1212from sas.qtgui.Plotting.SlicerModel import SlicerModel 
    1313 
    14 if not QtGui.QApplication.instance(): 
    15     app = QtGui.QApplication(sys.argv) 
     14if not QtWidgets.QApplication.instance(): 
     15    app = QtWidgets.QApplication(sys.argv) 
    1616 
    1717class SlicerModelTest(unittest.TestCase): 
  • src/sas/qtgui/Plotting/UnitTesting/SlicerParametersTest.py

    r464cd07 r725d9c06  
    11import sys 
    22import unittest 
    3 from mock import MagicMock 
     3import webbrowser 
     4from unittest.mock import MagicMock 
    45 
    5 from PyQt4 import QtGui 
    6 from PyQt4 import QtCore 
    7 from PyQt4 import QtTest 
    8 from PyQt4 import QtWebKit 
    9  
    10 from mock import MagicMock 
     6from PyQt5 import QtGui, QtWidgets 
     7from PyQt5 import QtCore 
     8from PyQt5 import QtTest 
    119 
    1210# set up import paths 
     
    1816from sas.qtgui.Plotting.SlicerParameters import SlicerParameters 
    1917 
    20 if not QtGui.QApplication.instance(): 
    21     app = QtGui.QApplication(sys.argv) 
     18if not QtWidgets.QApplication.instance(): 
     19    app = QtWidgets.QApplication(sys.argv) 
    2220 
    2321class SlicerParametersTest(unittest.TestCase): 
     
    3937        '''Test the GUI in its default state''' 
    4038        #self.widget.mapper 
    41         self.assertIsInstance(self.widget.proxy, QtGui.QIdentityProxyModel) 
    42         self.assertIsInstance(self.widget.lstParams.itemDelegate(), QtGui.QStyledItemDelegate) 
     39        self.assertIsInstance(self.widget.proxy, QtCore.QIdentityProxyModel) 
     40        self.assertIsInstance(self.widget.lstParams.itemDelegate(), QtWidgets.QStyledItemDelegate) 
    4341        self.assertTrue(self.widget.lstParams.model().columnReadOnly(0)) 
    4442        self.assertFalse(self.widget.lstParams.model().columnReadOnly(1)) 
     
    6462        spy_close = QtSignalSpy(self.widget, self.widget.close_signal) 
    6563        # Click on the "Close" button 
    66         QtTest.QTest.mouseClick(self.widget.buttonBox.button(QtGui.QDialogButtonBox.Close), QtCore.Qt.LeftButton) 
     64        QtTest.QTest.mouseClick(self.widget.buttonBox.button(QtWidgets.QDialogButtonBox.Close), QtCore.Qt.LeftButton) 
    6765        # Check the signal 
    6866        self.assertEqual(spy_close.count(), 1) 
     
    7068        self.assertFalse(self.widget.isVisible()) 
    7169 
    72     def testOnHelp(self): 
     70    def notestOnHelp(self): 
    7371        ''' Assure clicking on help returns QtWeb view on requested page''' 
    7472        self.widget.show() 
    7573 
    76         #Mock the QWebView method 
    77         QtWebKit.QWebView.show = MagicMock() 
    78         QtWebKit.QWebView.load = MagicMock() 
     74        #Mock the webbrowser.open method 
     75        webbrowser.open = MagicMock() 
    7976 
    8077        # Invoke the action 
     
    8279 
    8380        # Check if show() got called 
    84         self.assertTrue(QtWebKit.QWebView.show.called) 
     81        self.assertTrue(webbrowser.open.called) 
    8582 
    8683        # Assure the filename is correct 
    87         self.assertIn("graph_help.html", QtWebKit.QWebView.load.call_args[0][0].toString()) 
     84        self.assertIn("graph_help.html", webbrowser.open.call_args[0][0]) 
    8885         
    8986    def testSetModel(self): 
  • src/sas/qtgui/Plotting/UnitTesting/WindowTitleTest.py

    r464cd07 r53c771e  
    22import unittest 
    33 
    4 from PyQt4 import QtGui 
     4from PyQt5 import QtGui, QtWidgets 
    55 
    66# set up import paths 
     
    1010from sas.qtgui.Plotting.WindowTitle import WindowTitle 
    1111 
    12 if not QtGui.QApplication.instance(): 
    13     app = QtGui.QApplication(sys.argv) 
     12if not QtWidgets.QApplication.instance(): 
     13    app = QtWidgets.QApplication(sys.argv) 
    1414 
    1515class WindowTitleTest(unittest.TestCase): 
     
    2727        '''Test the GUI in its default state''' 
    2828        self.widget.show() 
    29         self.assertIsInstance(self.widget, QtGui.QDialog) 
     29        self.assertIsInstance(self.widget, QtWidgets.QDialog) 
    3030        self.assertEqual(self.widget.windowTitle(), "Modify Window Title") 
    3131         
     
    3333        '''Modify the title''' 
    3434        self.widget.show() 
    35         QtGui.qApp.processEvents() 
     35        QtWidgets.qApp.processEvents() 
    3636        # make sure we have the pre-set title 
    3737        self.assertEqual(self.widget.txtTitle.text(), "some title") 
     
    3939        self.widget.txtTitle.clear() 
    4040        self.widget.txtTitle.setText("5 elephants") 
    41         QtGui.qApp.processEvents() 
     41        QtWidgets.qApp.processEvents() 
    4242        # Retrieve value 
    4343        new_title = self.widget.title() 
  • src/sas/qtgui/Plotting/WindowTitle.py

    r83eb5208 r4992ff2  
    33from "Graph_n" to any ASCII text. 
    44""" 
    5 from PyQt4 import QtGui 
     5from PyQt5 import QtWidgets 
    66 
    77from sas.qtgui.Plotting.UI.WindowTitleUI import Ui_WindowTitle 
    88 
    9 class WindowTitle(QtGui.QDialog, Ui_WindowTitle): 
     9class WindowTitle(QtWidgets.QDialog, Ui_WindowTitle): 
    1010    """ Simple GUI for a single line text query """ 
    1111    def __init__(self, parent=None, new_title=""): 
  • src/sas/qtgui/Plotting/rangeSlider.py

    • Property mode changed from 100755 to 100644
    r83eb5208 r7969b9c  
    2323""" 
    2424 
    25 from PyQt4 import QtGui, QtCore 
    26  
    27 class RangeSlider(QtGui.QSlider): 
     25from PyQt5 import QtCore 
     26from PyQt5 import QtGui 
     27from PyQt5 import QtWidgets 
     28 
     29class RangeSlider(QtWidgets.QSlider): 
    2830    """ A slider for ranges. 
    2931     
     
    4648        self._high = self.maximum() 
    4749         
    48         self.pressed_control = QtGui.QStyle.SC_None 
    49         self.hover_control = QtGui.QStyle.SC_None 
     50        self.pressed_control = QtWidgets.QStyle.SC_None 
     51        self.hover_control = QtWidgets.QStyle.SC_None 
    5052        self.click_offset = 0 
    5153         
     
    8789 
    8890        painter = QtGui.QPainter(self) 
    89         style = QtGui.QApplication.style()  
     91        style = QtWidgets.QApplication.style() 
    9092 
    9193        for i, value in enumerate([self._low, self._high]): 
    92             opt = QtGui.QStyleOptionSlider() 
     94            opt = QtWidgets.QStyleOptionSlider() 
    9395            self.initStyleOption(opt) 
    9496 
     
    107109                slider_max = gr.bottom() - handle_length + 1 
    108110 
    109             opt.subControls = QtGui.QStyle.SC_SliderGroove | QtGui.QStyle.SC_SliderHandle 
     111            opt.subControls = QtWidgets.QStyle.SC_SliderGroove | QtWidgets.QStyle.SC_SliderHandle 
    110112 
    111113            # draw the first slider with inverted appearance, then the second  
     
    131133                # do not highlight the second part when has focus to avoid  
    132134                # drawing of partially overlapped semi-transparent backgrounds 
    133                 opt.state &= ~QtGui.QStyle.State_HasFocus 
     135                opt.state &= ~QtWidgets.QStyle.State_HasFocus 
    134136 
    135137                opt.sliderValue = 0 
     
    157159 
    158160            if self.tickPosition() != self.NoTicks: 
    159                 opt.subControls |= QtGui.QStyle.SC_SliderTickmarks 
     161                opt.subControls |= QtWidgets.QStyle.SC_SliderTickmarks 
    160162 
    161163            if self.pressed_control: 
    162164                opt.activeSubControls = self.pressed_control 
    163                 opt.state |= QtGui.QStyle.State_Sunken 
     165                opt.state |= QtWidgets.QStyle.State_Sunken 
    164166            else: 
    165167                opt.activeSubControls = self.hover_control 
    166168 
    167             style.drawComplexControl(QtGui.QStyle.CC_Slider, opt, painter, self) 
     169            style.drawComplexControl(QtWidgets.QStyle.CC_Slider, opt, painter, self) 
    168170             
    169171         
     
    171173        event.accept() 
    172174         
    173         style = QtGui.QApplication.style() 
     175        style = QtWidgets.QApplication.style() 
    174176        button = event.button() 
    175177         
     
    181183                 
    182184        if button: 
    183             opt = QtGui.QStyleOptionSlider() 
     185            opt = QtWidgets.QStyleOptionSlider() 
    184186            self.initStyleOption(opt) 
    185187 
     
    206208 
    207209            if self.active_slider == 0: 
    208                 self.pressed_control = QtGui.QStyle.SC_SliderHandle 
     210                self.pressed_control = QtWidgets.QStyle.SC_SliderHandle 
    209211                self.click_offset = self.__pixelPosToRangeValue(self.__pick(event.pos())) 
    210212                self.triggerAction(self.SliderMove) 
     
    215217 
    216218    def mouseReleaseEvent(self, event): 
    217         if self.pressed_control != QtGui.QStyle.SC_SliderHandle: 
     219        if self.pressed_control != QtWidgets.QStyle.SC_SliderHandle: 
    218220            event.ignore() 
    219221            return 
    220222 
    221223        self.setSliderDown(False) 
    222         return QtGui.QSlider.mouseReleaseEvent(self, event) 
     224        return QtWidgets.QSlider.mouseReleaseEvent(self, event) 
    223225                                 
    224226    def mouseMoveEvent(self, event): 
    225         if self.pressed_control != QtGui.QStyle.SC_SliderHandle: 
     227        if self.pressed_control != QtWidgets.QStyle.SC_SliderHandle: 
    226228            event.ignore() 
    227229            return 
     
    229231        event.accept() 
    230232        new_pos = self.__pixelPosToRangeValue(self.__pick(event.pos())) 
    231         opt = QtGui.QStyleOptionSlider() 
     233        opt = QtWidgets.QStyleOptionSlider() 
    232234        self.initStyleOption(opt) 
    233235 
     
    262264            self.setHighValue( new_pos ) 
    263265 
    264         if self.hasTracking(): 
    265             self.emit(QtCore.SIGNAL('sliderMoved(int)'), new_pos) 
    266  
    267266             
    268267    def __pick(self, pt): 
     
    274273            
    275274    def __pixelPosToRangeValue(self, pos): 
    276         opt = QtGui.QStyleOptionSlider() 
     275        opt = QtWidgets.QStyleOptionSlider() 
    277276        self.initStyleOption(opt) 
    278         style = QtGui.QApplication.style() 
     277        style = QtWidgets.QApplication.style() 
    279278         
    280279        gr = style.subControlRect(style.CC_Slider, opt, style.SC_SliderGroove, self) 
Note: See TracChangeset for help on using the changeset viewer.