@@ -501,26 +501,6 @@ def show(mainloop=True):
501501 else : gtk .mainloop ()
502502
503503
504- def _quit_after_print_xvfb (* args ):
505- for manager in Gcf .get_all_fig_managers ():
506- gtk .main_quit ()
507-
508-
509- def show_xvfb ():
510- """
511- Print the pending figures only then quit, no screen draw
512- """
513- for manager in Gcf .get_all_fig_managers ():
514- #manager.canvas.set_do_plot(False)
515- manager .window .show ()
516-
517- gtk .idle_add (_quit_after_print_xvfb )
518- if gtk .pygtk_version >= (2 ,4 ,0 ):
519- gtk .main ()
520- else :
521- gtk .mainloop ()
522-
523-
524504def new_figure_manager (num , * args , ** kwargs ):
525505 """
526506 Create a new figure manager instance
@@ -756,9 +736,9 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
756736 # pixbuf.save() recognises 'jpeg' not 'jpg'
757737 if ext == 'jpg' : ext = 'jpeg'
758738 pixbuf .save (filename , ext )
759- # try: pixbuf.save(filename, ext)
760- # except gobject.GError, exc:
761- # error_msg('Save figure failure:\n%s' % (exc,), parent=self)
739+ try : pixbuf .save (filename , ext )
740+ except gobject .GError , exc :
741+ error_msg ('Save figure failure:\n %s' % (exc ,), parent = self )
762742
763743 elif ext in ('eps' , 'ps' , 'svg' ,):
764744 if ext == 'svg' :
@@ -768,34 +748,30 @@ def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w',
768748
769749 fc = self .switch_backends (FigureCanvas )
770750 fc .print_figure (filename , dpi , facecolor , edgecolor , orientation )
771- # try:
772- # fc = self.switch_backends(FigureCanvas)
773- # fc.print_figure(filename, dpi, facecolor, edgecolor, orientation)
774- # except IOError, exc:
775- # error_msg("Save figure failure:\n%s: %s" %
776- # (exc.filename, exc.strerror), parent=self)
777- # except Exception, exc:
778- # error_msg("Save figure failure:\n%s" % exc, parent=self)
751+ try :
752+ fc = self .switch_backends (FigureCanvas )
753+ fc .print_figure (filename , dpi , facecolor , edgecolor , orientation )
754+ except IOError , exc :
755+ error_msg ("Save figure failure:\n %s: %s" %
756+ (exc .filename , exc .strerror ), parent = self )
757+ except Exception , exc :
758+ error_msg ("Save figure failure:\n %s" % exc , parent = self )
779759
780760 elif ext in ('bmp' , 'raw' , 'rgb' ,):
781761 try :
782762 from backend_agg import FigureCanvasAgg as FigureCanvas
783763 except :
784- raise MPLError ('Save figure failure:\n '
785- 'Agg must be loaded to save as bmp, raw and rgb' )
786- #error_msg('Save figure failure:\n'
787- # 'Agg must be loaded to save as bmp, raw and rgb',
788- # parent=self)
764+ error_msg ('Save figure failure:\n '
765+ 'Agg must be loaded to save as bmp, raw and rgb' ,
766+ parent = self )
789767 else :
790768 fc = self .switch_backends (FigureCanvas )
791769 fc .print_figure (filename , dpi , facecolor , edgecolor , orientation )
792770
793771 else :
794- raise MPLError ('Format "%s" is not supported.\n Supported formats are %s.' %
795- (ext , ', ' .join (IMAGE_FORMAT )))
796- #error_msg('Format "%s" is not supported.\nSupported formats are %s.' %
797- # (ext, ', '.join(IMAGE_FORMAT)),
798- # parent=self)
772+ error_msg ('Format "%s" is not supported.\n Supported formats are %s.' %
773+ (ext , ', ' .join (IMAGE_FORMAT )),
774+ parent = self )
799775
800776 # restore figure settings
801777 self .figure .dpi .set (origDPI )
@@ -866,39 +842,6 @@ def destroy(self, *args):
866842 gtk .main_quit ()
867843
868844
869- class Dialog_MeasureTool (gtk .Dialog ):
870- def __init__ (self ):
871- gtk .Dialog .__init__ (self )
872- self .set_title ("Axis measurement tool" )
873- self .vbox .set_spacing (1 )
874- tooltips = gtk .Tooltips ()
875-
876- self .posFmt = 'Position: x=%1.4f y=%1.4f'
877- self .deltaFmt = 'Delta : x=%1.4f y=%1.4f'
878-
879- self .positionLabel = gtk .Label (self .posFmt % (0 ,0 ))
880- self .vbox .pack_start (self .positionLabel )
881- self .positionLabel .show ()
882- tooltips .set_tip (self .positionLabel ,
883- "Move the mouse to data point over axis" )
884-
885- self .deltaLabel = gtk .Label (self .deltaFmt % (0 ,0 ))
886- self .vbox .pack_start (self .deltaLabel )
887- self .deltaLabel .show ()
888-
889- tip = "Left click and hold while dragging mouse to measure " + \
890- "delta x and delta y"
891- tooltips .set_tip (self .deltaLabel , tip )
892-
893- self .show ()
894-
895- def update_position (self , x , y ):
896- self .positionLabel .set_text (self .posFmt % (x ,y ))
897-
898- def update_delta (self , dx , dy ):
899- self .deltaLabel .set_text (self .deltaFmt % (dx ,dy ))
900-
901-
902845class NavigationToolbar2GTK (NavigationToolbar2 , gtk .Toolbar ):
903846 # list of toolitems to add to the toolbar, format is:
904847 # text, tooltip_text, image_file, callback(str)
@@ -1419,11 +1362,6 @@ def get_filename_from_user (self):
14191362 self .path = filename
14201363 break
14211364 else :
1422- # XXX exception causes method to terminate w/o closing window
1423- # but want to repeat loop until selection is made
1424- # so a popup IS more appropriate?
1425- #raise MPLError('Format "%s" is not supported.\nSupported formats are %s.' %
1426- # (ext, ', '.join(IMAGE_FORMAT)))
14271365 error_msg ('Image format "%s" is not supported' % ext ,
14281366 parent = self )
14291367 self .set_current_name (os .path .split (root )[1 ] + '.' + menu_ext )
0 commit comments