Hello everyone, below is a little code - what it actually does is quite self-explanatory. (When clicking with left - draw a red circle. When the right button is pressed switch to a different mode. Now green squares are drawn and so on.)
My question now is: Is there a way to avoid using global variables but also avoid an object-oriented programming? In other words: Is it possible to pass e.g. a dictionary containing some information to the function called by the event? The reason for not wanting the object-oriented way is: We want to teach something to students who never programmed before. And to them it would be pretty hard if we start everything object-oriented! Thanks for your suggestions, Martin ######################################## from pylab import * def two_parts(event): global program_part if event.button == 3: program_part = program_part%2 + 1 print " Changed to part to ", program_part if program_part == 1 and event.button == 1: plot([event.xdata], [event.ydata], marker = 'o', mfc = 'r') if program_part == 2 and event.button == 1: plot([event.xdata], [event.ydata], marker = 's', mfc = 'g') draw() figure(1) ax = subplot(111, autoscale_on=False) ax.set_xlim([0,1]) ax.set_ylim([0,1]) program_part = 1 print " Actual program part is ", program_part connect('button_press_event', two_parts) show() ######################################## ------------------------------------------------------------------------- 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