def browseFile_(self, sender): panel = NSOpenPanel.openPanel() panel.setTitle_(NSLocalizedString("Select a Picture", "Label")) if panel.runModalForTypes_(NSArray.arrayWithObjects_("png", "tiff", "jpeg", "jpg", "tif")) == NSOKButton: path = unicode(panel.filename()) self.cropAndAddImage(path)
def browseFile_(self, sender): panel = NSOpenPanel.openPanel() panel.setTitle_(NSLocalizedString("Select a Picture", "Label")) if panel.runModalForTypes_( NSArray.arrayWithObjects_("png", "tiff", "jpeg", "jpg", "tif")) == NSOKButton: path = str(panel.filename()) self.cropAndAddImage(path)
def GetFile(message=None, filetypes = None, selectFolders = True, selectFiles = True): assert(filetypes) Panel = NSOpenPanel.openPanel() if message != None: Panel.setMessage_(message) Panel.setCanChooseFiles_(selectFiles) Panel.setCanChooseDirectories_(selectFolders) Panel.setAllowsMultipleSelection_(False) pressedButton = Panel.runModalForTypes_(filetypes) if pressedButton == 1: return Panel.filename() return None
def openFileTransferSelectionDialog(account, dest_uri): if not NSApp.delegate().contactsWindowController.sessionControllersManager.isMediaTypeSupported("file-transfer"): return panel = NSOpenPanel.openPanel() panel.setTitle_(u"Send File") panel.setAllowsMultipleSelection_(True) if panel.runModal() != NSOKButton: return filenames = [unicodedata.normalize("NFC", file) for file in panel.filenames()] NSApp.delegate().contactsWindowController.sessionControllersManager.send_files_to_contact( account, dest_uri, filenames )
def openFileTransferSelectionDialog(account, dest_uri, filename=None): if not NSApp.delegate().contactsWindowController.sessionControllersManager.isMediaTypeSupported('file-transfer'): return panel = NSOpenPanel.openPanel() panel.setTitle_(NSLocalizedString("Select Files or Folders and Click Open to Send", "Window title")) panel.setDirectoryURL_(NSURL.URLWithString_(filename)) panel.setAllowsMultipleSelection_(True) panel.setCanChooseDirectories_(True) if panel.runModal() != NSOKButton: return filenames = [unicodedata.normalize('NFC', file) for file in panel.filenames()] NSApp.delegate().contactsWindowController.sessionControllersManager.send_files_to_contact(account, dest_uri, filenames)
def GetFile(message=None, filetypes=None, selectFolders=True, selectFiles=True): assert (filetypes) Panel = NSOpenPanel.openPanel() if message != None: Panel.setMessage_(message) Panel.setCanChooseFiles_(selectFiles) Panel.setCanChooseDirectories_(selectFolders) Panel.setAllowsMultipleSelection_(False) pressedButton = Panel.runModalForTypes_(filetypes) if pressedButton == 1: return Panel.filename() return None
def buttonClicked_(self, sender): if sender.tag() == 20: # ch icon panel = NSOpenPanel.openPanel() panel.setTitle_(NSLocalizedString("Select Contact Icon", "Window title")) if panel.runModalForTypes_(NSArray.arrayWithObjects_("tiff", "png", "jpeg", "jpg")) == NSFileHandlingPanelOKButton: path = panel.filename() image = NSImage.alloc().initWithContentsOfFile_(path) self.photoImage.setImage_(image) elif sender.tag() == 21: # clear icon self.photoImage.setImage_(self.defaultPhotoImage) elif sender.tag() == 10: self.startDeallocTimer() NSApp.stopModalWithCode_(NSOKButton) else: self.startDeallocTimer() NSApp.stopModalWithCode_(NSCancelButton)
def GetFile(message=None, filetypes = None, selectFolders = True, selectFiles = True): assert(filetypes) try: from Foundation import NSOpenPanel except ImportError: # on Windows, use Fontlab's dialog (only supports single file, not folders) assert len(filetypes) == 1 filetype = filetypes[0] return fl.GetFileName(1, "", "", "%s file|*.%s" % (filetype.capitalize(), filetype)) Panel = NSOpenPanel.openPanel() if message != None: Panel.setMessage_(message) Panel.setCanChooseFiles_(selectFiles) Panel.setCanChooseDirectories_(selectFolders) Panel.setAllowsMultipleSelection_(False) pressedButton = Panel.runModalForTypes_(filetypes) if pressedButton == 1: return Panel.filename() return None
def openFileTransferSelectionDialog(account, dest_uri, filename=None): if not NSApp.delegate( ).contactsWindowController.sessionControllersManager.isMediaTypeSupported( 'file-transfer'): return panel = NSOpenPanel.openPanel() panel.setTitle_( NSLocalizedString("Select Files or Folders and Click Open to Send", "Window title")) panel.setDirectoryURL_(NSURL.URLWithString_(filename)) panel.setAllowsMultipleSelection_(True) panel.setCanChooseDirectories_(True) if panel.runModal() != NSOKButton: return filenames = [ unicodedata.normalize('NFC', file) for file in panel.filenames() ] NSApp.delegate( ).contactsWindowController.sessionControllersManager.send_files_to_contact( account, dest_uri, filenames)