Don't error gruesomely when someone exports nonexistant graph
sys.path[0] to get basepath of fpdb script
This commit is contained in:
		
							parent
							
								
									75dcf002f9
								
							
						
					
					
						commit
						1e047b6998
					
				
							
								
								
									
										4
									
								
								pyfpdb/GuiAutoImport.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										4
									
								
								pyfpdb/GuiAutoImport.py
									
									
									
									
									
										
										
										Normal file → Executable file
									
								
							| 
						 | 
					@ -135,8 +135,8 @@ class GuiAutoImport (threading.Thread):
 | 
				
			||||||
                    self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE, 
 | 
					                    self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE, 
 | 
				
			||||||
                                                    universal_newlines=True)
 | 
					                                                    universal_newlines=True)
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
#                    command = os.path.join(os.getcwd(),  'HUD_main.py') #  clearly doesn't work if you run from somewhere else.
 | 
					                    command = os.path.join(sys.path[0],  'HUD_main.py')
 | 
				
			||||||
                    command = self.config.execution_path('HUD_main.py') # Hi Ray. Sorry about this, kludging.
 | 
					                    #command = self.config.execution_path('HUD_main.py') # Hi Ray. Sorry about this, kludging.
 | 
				
			||||||
                    bs = 1
 | 
					                    bs = 1
 | 
				
			||||||
                    self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE, 
 | 
					                    self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE, 
 | 
				
			||||||
                                                    universal_newlines=True)
 | 
					                                                    universal_newlines=True)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -279,6 +279,8 @@ class GuiGraphViewer (threading.Thread):
 | 
				
			||||||
        win.destroy()
 | 
					        win.destroy()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def exportGraph (self, widget, data):
 | 
					    def exportGraph (self, widget, data):
 | 
				
			||||||
 | 
					        if self.fig is None:
 | 
				
			||||||
 | 
					            return # Might want to disable export button until something has been generated.
 | 
				
			||||||
        dia_chooser = gtk.FileChooserDialog(title="Please choose the directory you wish to export to:",
 | 
					        dia_chooser = gtk.FileChooserDialog(title="Please choose the directory you wish to export to:",
 | 
				
			||||||
                                            action=gtk.FILE_CHOOSER_ACTION_OPEN,
 | 
					                                            action=gtk.FILE_CHOOSER_ACTION_OPEN,
 | 
				
			||||||
                                            buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
 | 
					                                            buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
 | 
				
			||||||
| 
						 | 
					@ -359,6 +361,7 @@ class GuiGraphViewer (threading.Thread):
 | 
				
			||||||
        graphButton.connect("clicked", self.generateGraph, "cliced data")
 | 
					        graphButton.connect("clicked", self.generateGraph, "cliced data")
 | 
				
			||||||
        graphButton.show()
 | 
					        graphButton.show()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.fig = None
 | 
				
			||||||
        self.exportButton=gtk.Button("Export to File")
 | 
					        self.exportButton=gtk.Button("Export to File")
 | 
				
			||||||
        self.exportButton.connect("clicked", self.exportGraph, "show clicked")
 | 
					        self.exportButton.connect("clicked", self.exportGraph, "show clicked")
 | 
				
			||||||
        self.exportButton.show()
 | 
					        self.exportButton.show()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user