def _saveIfChanged(self): """ Check to see if the current document has changed. If so, ask the user if it should be saved. If so, prompt for a path and save the file to that path. If the user does not want to save the file, or the Cancel button is pressed in the Save As dialog, do nothing. """ # If the current document is unchanged, return. changed = self._sourceLibraryDocumentEditor.getChanged() if not changed: return # The current document has changed, so ask the user if it # should be saved. If not, return. path = self._path if path is None: message = 'The document has been modified.' else: message = 'The document "%s" has been modified. ' % path message += ' Do you want to save your changes?' saveFile = askyesno(title='ModelEditor', message=message) if not saveFile: return # If the file has no associated path, get one. If the Cancel button # is pressed, return without saving the file. if path is None: path = SaveAs().show() if path == '': return # Save the document. self._save(path)
def _onFileExportToObsSim(self): if debug: print 'File/Export to ObsSim...' # Get the new path for this document. If none, return. path = SaveAs().show() if path == (): return # Export the file. self._exportToObsSim(path)
def _onFileSaveAs(self): if debug: print 'File/Save As...' # Get the new path for this document. If none, return. path = SaveAs().show() if path == (): return # Save the document. self._save(path)
def my_asksaveasfilename(self): # objects remember last result dir/file if not self.saveDialog: self.saveDialog = SaveAs(initialdir=self.startfiledir, filetypes=self.ftypes) return self.saveDialog.show()
def myasksaveasfilename_all(): global saveAllDialog if not saveAllDialog: saveAllDialog = SaveAs(title='PyMail Save All File') return saveAllDialog.show()
def myasksaveasfilename_one(): global saveOneDialog if not saveOneDialog: saveOneDialog = SaveAs(title='PyMail Save File') return saveOneDialog.show()
# similar to the screen height scaler here, but only shrinks: # x, y = imgwide, imghigh # if x > scrwide: y = max(y * scrwide / x, 1); x = scrwide # if y > scrhigh: x = max(x * scrhigh / y, 1); y = scrhigh ############################################################## import sys, math, os from Tkinter import * from tkFileDialog import SaveAs, Directory import Image # PIL Image: also in Tkinter from ImageTk import PhotoImage # PIL photo widget replacement from viewer_thumbs import makeThumbs # developed earlier in book # remember last dirs across all windows saveDialog = SaveAs(title='Save As (filename gives image type)') openDialog = Directory(title='Select Image Directory To Open') appname = 'PyPhoto 1.0: ' class ScrolledCanvas(Canvas): """ a canvas in a container that automatically makes vertical and horizontal scrollbars for itself """ def __init__(self, container): Canvas.__init__(self, container) self.config(borderwidth=0) vbar = Scrollbar(container) hbar = Scrollbar(container, orient='horizontal')
def ask_saveas(title, message, filetypes, defaultDir=None, defaultFile=None): dlg = SaveAs(title=title, message=message, filetypes=filetypes) filename = dlg.show() return filename