From: <jd...@us...> - 2008-06-05 14:18:43
|
Revision: 5395 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5395&view=rev Author: jdh2358 Date: 2008-06-05 07:18:31 -0700 (Thu, 05 Jun 2008) Log Message: ----------- some fixes for classic toolbar Modified Paths: -------------- trunk/matplotlib/examples/user_interfaces/embedding_in_gtk2.py trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py trunk/matplotlib/lib/matplotlib/ticker.py Modified: trunk/matplotlib/examples/user_interfaces/embedding_in_gtk2.py =================================================================== --- trunk/matplotlib/examples/user_interfaces/embedding_in_gtk2.py 2008-06-05 13:45:27 UTC (rev 5394) +++ trunk/matplotlib/examples/user_interfaces/embedding_in_gtk2.py 2008-06-05 14:18:31 UTC (rev 5395) @@ -14,8 +14,8 @@ #from matplotlib.backends.backend_gtkcairo import FigureCanvasGTKCairo as FigureCanvas # or NavigationToolbar for classic -from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar -#from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar +#from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar +from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar win = gtk.Window() Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-06-05 13:45:27 UTC (rev 5394) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008-06-05 14:18:31 UTC (rev 5395) @@ -353,12 +353,12 @@ # for self.window(for pixmap) and has a side effect of altering # figure width,height (via configure-event?) gtk.DrawingArea.realize(self) - + width, height = self.get_width_height() pixmap = gdk.Pixmap (self.window, width, height) self._renderer.set_pixmap (pixmap) self._render_figure(pixmap, width, height) - + # jpg colors don't match the display very well, png colors match # better pixbuf = gdk.Pixbuf(gdk.COLORSPACE_RGB, 0, 8, width, height) @@ -382,18 +382,18 @@ raise ValueError("Saving to a Python file-like object is only supported by PyGTK >= 2.8") else: raise ValueError("filename must be a path or a file-like object") - + def get_default_filetype(self): return 'png' def flush_events(self): - gtk.gdk.threads_enter() + gtk.gdk.threads_enter() while gtk.events_pending(): gtk.main_iteration(True) gtk.gdk.flush() gtk.gdk.threads_leave() - - + + class FigureManagerGTK(FigureManagerBase): """ Public attributes @@ -410,7 +410,7 @@ self.window = gtk.Window() self.window.set_title("Figure %d" % num) - + self.vbox = gtk.VBox() self.window.add(self.vbox) self.vbox.show() @@ -462,7 +462,7 @@ def show(self): # show the figure window self.window.show() - + def full_screen_toggle (self): self._full_screen_flag = not self._full_screen_flag if self._full_screen_flag: @@ -742,8 +742,8 @@ self.fileselect = FileChooserDialog( title='Save the figure', parent=self.win, - formats=self.canvas.get_supported_filetypes(), - default_type=self.canvas.get_default_filetype()) + filetypes=self.canvas.get_supported_filetypes(), + default_filetype=self.canvas.get_default_filetype()) else: self._create_toolitems_2_2() self.update = self._update_2_2 @@ -912,53 +912,32 @@ self._ind = ind self._active = [ self._axes[i] for i in self._ind ] - def panx(self, button, arg): - """arg is either user callback data or a scroll event - """ - try: - if arg.direction == gdk.SCROLL_UP: direction=1 - else: direction=-1 - except AttributeError: - direction = arg + def panx(self, button, direction): + 'panx in direction' for a in self._active: - a.panx(direction) + a.xaxis.pan(direction) self.canvas.draw() return True - def pany(self, button, arg): - try: - if arg.direction == gdk.SCROLL_UP: direction=1 - else: direction=-1 - except AttributeError: - direction = arg - + def pany(self, button, direction): + 'pany in direction' for a in self._active: - a.pany(direction) + a.yaxis.pan(direction) self.canvas.draw() return True - def zoomx(self, button, arg): - try: - if arg.direction == gdk.SCROLL_UP: direction=1 - else: direction=-1 - except AttributeError: - direction = arg - + def zoomx(self, button, direction): + 'zoomx in direction' for a in self._active: - a.zoomx(direction) + a.xaxis.zoom(direction) self.canvas.draw() return True - def zoomy(self, button, arg): - try: - if arg.direction == gdk.SCROLL_UP: direction=1 - else: direction=-1 - except AttributeError: - direction = arg - + def zoomy(self, button, direction): + 'zoomy in direction' for a in self._active: - a.zoomy(direction) + a.yaxis.zoom(direction) self.canvas.draw() return True @@ -1043,7 +1022,7 @@ break filename = self.get_filename() break - + self.hide() return filename, self.ext else: @@ -1075,8 +1054,8 @@ if ext.startswith('.'): ext = ext[1:] return filename, ext - + class DialogLineprops: """ A GUI dialog for controlling lineprops Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008-06-05 13:45:27 UTC (rev 5394) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008-06-05 14:18:31 UTC (rev 5395) @@ -487,46 +487,26 @@ self._ind = ind self._active = [ self._axes[i] for i in self._ind ] - def panx(self, arg): - try: arg.direction - except AttributeError: direction = arg - else: - if arg.direction == Tk.SCROLL_UP: direction=1 - else: direction=-1 + def panx(self, direction): for a in self._active: - a.panx(direction) + a.xaxis.pan(direction) self.canvas.draw() - def pany(self, arg): - try: arg.direction - except AttributeError: direction = arg - else: - if arg.direction == Tk.SCROLL_UP: direction=1 - else: direction=-1 + def pany(self, direction): for a in self._active: - a.pany(direction) + a.yaxis.pan(direction) self.canvas.draw() - def zoomx(self, arg): - try: arg.direction - except AttributeError: direction = arg - else: - if arg.direction == Tk.SCROLL_UP: direction=1 - else: direction=-1 + def zoomx(self, direction): for a in self._active: - a.zoomx(direction) + a.xaxis.zoom(direction) self.canvas.draw() - def zoomy(self, arg): - try: arg.direction - except AttributeError: direction = arg - else: - if arg.direction == Tk.SCROLL_UP: direction=1 - else: direction=-1 + def zoomy(self, direction): for a in self._active: - a.zoomy(direction) + a.yaxis.zoom(direction) self.canvas.draw() def save_figure(self): @@ -666,14 +646,14 @@ # so we just have to put it first default_filetype_name = filetypes[default_filetype] del filetypes[default_filetype] - + sorted_filetypes = filetypes.items() sorted_filetypes.sort() sorted_filetypes.insert(0, (default_filetype, default_filetype_name)) - + tk_filetypes = [ (name, '*.%s' % ext) for (ext, name) in sorted_filetypes] - + fname = asksaveasfilename( master=self.window, title='Save the figure', Modified: trunk/matplotlib/lib/matplotlib/ticker.py =================================================================== --- trunk/matplotlib/lib/matplotlib/ticker.py 2008-06-05 13:45:27 UTC (rev 5394) +++ trunk/matplotlib/lib/matplotlib/ticker.py 2008-06-05 14:18:31 UTC (rev 5395) @@ -639,17 +639,17 @@ ticks = self() numticks = len(ticks) + vmin, vmax = self.axis.get_view_interval() + vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05) if numticks>2: step = numsteps*abs(ticks[0]-ticks[1]) else: - vmin, vmax = self.axis.get_view_interval() - vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05) d = abs(vmax-vmin) step = numsteps*d/6. vmin += step vmax += step - self.axis.set_view_interval(vmin, vmax) + self.axis.set_view_interval(vmin, vmax, ignore=True) def zoom(self, direction): @@ -658,12 +658,9 @@ vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05) interval = abs(vmax-vmin) - interval = self.viewInterval.span() step = 0.1*interval*direction + self.axis.set_view_interval(vmin + step, vmax - step, ignore=True) - - self.axis.set_view_interval(vmin + step, vmax - step) - def refresh(self): 'refresh internal information based on current lim' pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |