On 30/03/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Not sure what region[:] is supposed to achieve. You are creating a copy > with the same name, so you are over-riding the original variable. >
That doesn't seem to be the case - it returns the right thing on the first call - i.e. region got changed, but on subsequent calls the figure is displayed and the function returns array([0,0,0,0]). I thought taking the slice just gave access to the internals of region ... How does one assign a new value to a variable in a containing scope? Richard > > Hi there > > I have a function where I want to display an image, get the user to > zoom in on a region of interest, and then return the axes limits. > > But the problem is, I can only use it once, the second time it gets > called in a script the figure doesn't appear. I know this is to do > with show() not being supposed to be used multiple times, but I don't > know what I should be doing instead ... any tips? (I'm still new to > python btw) > > Also, if there's a better (more pythonic way) to do what I'm doing, I > would appreciate your input. I'm not sure if what I'm doing with the > region variable is dodgy or not. > > Currently, I'm doing this: > > from pylab import * > > def getroi(im): > imshow(im) > title('Zoom in to region of interest, then press a key') > region = array([0, 0, 0, 0]) # Placeholder values > > def keypressed(event): > region[:] = [round(i) for i in gca().axis()] > close(gcf()) > > # Connect keypressed to event handler > connect('key_press_event', keypressed) > > show() > return region > > > > thanks, > > Richard ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users