So I found out about Python variables just being pointers so I guess the 
problem lies in the line:

copyROI = self._ROI   #make copy of user-draggable ROI

However copy.copy or copy.deepcopy throws a bunch of errors that I don't 
quiet understand (I guess an instance of a class cannot be copied with all 
the arguments being real copies as well).

So I resorted to generating new ROIs from the ground up which I tried to 
circumvent in the first place. Now new problems arise...Here's a code 
snippet:

if self.ROI_comboBox.currentText()=="Rectangle":
 copyROI = pg.RectROI([self._ROIXPos, self._ROIYPos], [self._ROISizeX, self.
_ROISizeY], 
           pen=pg.mkPen(color=self._ROIList_PenItems[index],width=1),
removable=True)
elif self.ROI_comboBox.currentText()=="Circle":  
 copyROI = pg.CircleROI([self._ROIXPos, self._ROIYPos], [self._ROISizeX,
 self._ROISizeY],pen=pg.mkPen(color=self._ROIList_PenItems[index],width=1),
removable=True)
       
       
        copyROI.setZValue(100)  # make sure ROI is drawn above image
        copyROI.translatable = False
        handle = copyROI.getHandles()
!!!!!!  copyROI.removeHandle(handle[0])     #this line throws an error that 
NoneType doesn't have a method removeItem
        handle[0].disconnectROI(copyROI)
        print("Get handles: ",copyROI.getHandles())
        print("Handle[0]: ",handle[0])
        print("type(copyROI): ",type(copyROI))
        self._P1.addItem(copyROI)  


So basically I create a ROI of type determined by a user selection widget 
(rectangle or circle). I can see the automatically created handle object 
(when creating a rect ROI) just fine. However when I try to remove it to 
effectively disable scaling it throws an error that an object of NoneType 
doesn't have a method of removeItem. It's strange because in the snippet I 
posted in the first post the method .removeHandle(0) works fine on the 
auto-created handle of a rect ROI object. Whats causing this?

I got a dirty workaround now which you can see in the above snippet namely 
I disconnect the handle from the ROI of interest. It thus becomes disabled 
and scaling becomes impossible. Just what I wanted however the handle is 
still visible which I would like to avoid.

Any help is greatly appreciated, Chris


-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/36bab520-582d-44c6-99fb-a0d80c06b24b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to