From 4b62067b87efc6515081436c9ab65fd759b7b97f Mon Sep 17 00:00:00 2001 From: Eric Jeschke Date: Wed, 21 Feb 2024 16:12:28 -1000 Subject: [PATCH] Fix for Ginga upstream deprecation - the move_to(x, y) call on a canvas object has been redefined in terms of move_to_pt((x, y)) since Ginga v2.6.5. move_to() has issued a DeprecationWarning since v4.0.0 - this fixes the plugins to use move_to_pt(). It is compatible with Ginga back to v2.6.5 --- stginga/plugins/BackgroundSub.py | 8 ++++---- stginga/plugins/BadPixCorr.py | 10 +++++----- stginga/plugins/DQInspect.py | 8 ++++---- stginga/plugins/SNRCalc.py | 16 ++++++++-------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/stginga/plugins/BackgroundSub.py b/stginga/plugins/BackgroundSub.py index 5ef8c51..dfb30a8 100644 --- a/stginga/plugins/BackgroundSub.py +++ b/stginga/plugins/BackgroundSub.py @@ -306,7 +306,7 @@ def update(self, canvas, event, data_x, data_y, viewer): self.xcen = data_x self.ycen = data_y - bg_obj.move_to(data_x, data_y) + bg_obj.move_to_pt((data_x, data_y)) tag = canvas.add(bg_obj) self.draw_cb(canvas, tag) return True @@ -325,7 +325,7 @@ def drag(self, canvas, event, data_x, data_y, viewer): if bg_obj.kind not in ('compound', 'annulus', 'rectangle'): return True - bg_obj.move_to(data_x, data_y) + bg_obj.move_to_pt((data_x, data_y)) if obj.kind == 'compound': try: @@ -522,7 +522,7 @@ def set_xcen(self): y = c_obj.y else: y = c_obj.get_center_pt()[1] - c_obj.move_to(self.xcen, y) + c_obj.move_to_pt((self.xcen, y)) self.fitsimage.redraw(whence=3) return self.redo() @@ -552,7 +552,7 @@ def set_ycen(self): y2 = self.ycen + 0.5 * self.boxheight # Reposition background region - bg_obj.move_to(x, self.ycen) + bg_obj.move_to_pt((x, self.ycen)) # Reposition label to match obj.objects[1].y = y2 + self._text_label_offset diff --git a/stginga/plugins/BadPixCorr.py b/stginga/plugins/BadPixCorr.py index 0778df4..c4ac486 100644 --- a/stginga/plugins/BadPixCorr.py +++ b/stginga/plugins/BadPixCorr.py @@ -303,7 +303,7 @@ def update(self, canvas, event, data_x, data_y, viewer): self.xcen = data_x self.ycen = data_y - bpx_obj.move_to(data_x, data_y) + bpx_obj.move_to_pt((data_x, data_y)) tag = canvas.add(bpx_obj) self.draw_cb(canvas, tag) return True @@ -322,7 +322,7 @@ def drag(self, canvas, event, data_x, data_y, viewer): if bpx_obj.kind not in ('circle', 'point'): return True - bpx_obj.move_to(data_x, data_y) + bpx_obj.move_to_pt((data_x, data_y)) if obj.kind == 'compound': try: @@ -349,7 +349,7 @@ def draw_cb(self, canvas, tag): # Round to nearest pixel x, y = round(obj.x), round(obj.y) - obj.move_to(x, y) + obj.move_to_pt((x, y)) # Change bad pix region appearance obj.color = self.bpixcorrcolor @@ -607,7 +607,7 @@ def set_xcen(self): y = c_obj.y else: y = c_obj.get_center_pt()[1] - c_obj.move_to(self.xcen, y) + c_obj.move_to_pt((self.xcen, y)) self.fitsimage.redraw(whence=3) return self.redo() @@ -638,7 +638,7 @@ def set_ycen(self): if n_obj == 3: # Also reposition annulus ann_obj = obj.objects[1] - ann_obj.move_to(ann_obj.x, self.ycen) + ann_obj.move_to_pt((ann_obj.x, self.ycen)) c_obj.y = (self.ycen + ann_obj.radius + ann_obj.width + self._text_label_offset) elif bpx_obj.kind == 'circle': # circle without annulus diff --git a/stginga/plugins/DQInspect.py b/stginga/plugins/DQInspect.py index 8e8e327..282b151 100644 --- a/stginga/plugins/DQInspect.py +++ b/stginga/plugins/DQInspect.py @@ -533,7 +533,7 @@ def update(self, canvas, event, data_x, data_y, viewer): self.xcen = data_x self.ycen = data_y - pix_obj.move_to(data_x, data_y) + pix_obj.move_to_pt((data_x, data_y)) tag = canvas.add(pix_obj) self.draw_cb(canvas, tag) return True @@ -555,7 +555,7 @@ def drag(self, canvas, event, data_x, data_y, viewer): if pix_obj.kind != 'point': return True - pix_obj.move_to(data_x, data_y) + pix_obj.move_to_pt((data_x, data_y)) if obj.kind == 'compound': try: @@ -582,7 +582,7 @@ def draw_cb(self, canvas, tag): # Round to nearest pixel x, y = round(obj.x), round(obj.y) - obj.move_to(x, y) + obj.move_to_pt((x, y)) # Change bad pix region appearance obj.radius = self._point_radius @@ -627,7 +627,7 @@ def set_xcen(self): # Reposition all elements to match for c_obj in obj.objects: if c_obj.kind != 'image': - c_obj.move_to(self.xcen, c_obj.y) + c_obj.move_to_pt((self.xcen, c_obj.y)) self.fitsimage.redraw(whence=3) return self.redo() diff --git a/stginga/plugins/SNRCalc.py b/stginga/plugins/SNRCalc.py index 7a2a946..c68897c 100644 --- a/stginga/plugins/SNRCalc.py +++ b/stginga/plugins/SNRCalc.py @@ -514,7 +514,7 @@ def update(self, canvas, event, data_x, data_y, viewer): self.xcen = data_x self.ycen = data_y - sig_obj.move_to(data_x, data_y) + sig_obj.move_to_pt((data_x, data_y)) tag = canvas.add(sig_obj) self.draw_cb(canvas, tag) return True @@ -533,7 +533,7 @@ def drag(self, canvas, event, data_x, data_y, viewer): if sig_obj.kind not in ('circle', 'polygon', 'rectangle'): return True - sig_obj.move_to(data_x, data_y) + sig_obj.move_to_pt((data_x, data_y)) if obj.kind == 'compound': try: @@ -691,12 +691,12 @@ def align_centers(self): self.w.bg_y.set_text(str(self.bgycen)) # Reposition annulus - obj.objects[1].move_to(self.bgxcen, self.bgycen) + obj.objects[1].move_to_pt((self.bgxcen, self.bgycen)) # Reposition label yt = (self.bgycen + self.bgradius + self.annulus_width + self._text_label_offset) - obj.objects[2].move_to(self.bgxcen, yt) + obj.objects[2].move_to_pt((self.bgxcen, yt)) self.fitsimage.redraw(whence=3) return self.redo() @@ -723,7 +723,7 @@ def set_xcen(self): else: # polygon, rectangle y = sig_obj.get_center_pt()[1] - sig_obj.move_to(self.xcen, y) + sig_obj.move_to_pt((self.xcen, y)) self.fitsimage.redraw(whence=3) return self.redo() @@ -750,7 +750,7 @@ def set_ycen(self): else: # polygon, rectangle x = sig_obj.get_center_pt()[0] - sig_obj.move_to(x, self.ycen) + sig_obj.move_to_pt((x, self.ycen)) self.fitsimage.redraw(whence=3) return self.redo() @@ -852,7 +852,7 @@ def set_bgxcen(self): # Reposition annulus and label for i in (1, 2): cobj = obj.objects[i] - cobj.move_to(self.bgxcen, cobj.y) + cobj.move_to_pt((self.bgxcen, cobj.y)) self.fitsimage.redraw(whence=3) return self.redo() @@ -874,7 +874,7 @@ def set_bgycen(self): # Reposition annulus ann_obj = obj.objects[1] - ann_obj.move_to(ann_obj.x, self.bgycen) + ann_obj.move_to_pt((ann_obj.x, self.bgycen)) # Reposition label obj.objects[2].y = (ann_obj.y + ann_obj.radius + ann_obj.width +