Logo Search packages:      
Sourcecode: pythoncard version File versions  Download package

def textRouter::TextRouter::on_menuManilaUploadPicture_select (   self,
  event 
)

Upload's an image to the Manila server.

Definition at line 933 of file textRouter.py.

00933                                                       :
        """Upload's an image to the Manila server."""
        if not self.checkManilaAccounts(3):
            return

        curManilaAccount = self.theManilaAccounts[self.theCurrentManilaAccount]

        if not curManilaAccount.checkSetupOK():
            self.status(curManilaAccount.getErrorMessage())
            return

        wildcard = "JPG files (*.jpg;*.jpeg)|*.jpg;*.jpeg|GIF files (*.gif)|*.gif|All Files (*.*)|*.*"

        result = dialog.fileDialog(self, 'Open...', \
                                self.generalPrefs["defaultDirectory"], '', \
                                wildcard)
        if result.accepted:
            path = result.paths[0]
            
            if path.endswith("gif"):
                mimeType = "image/gif"
            elif path.endswith("jpeg") or path.endswith("jpg"):
                mimeType = "image/jpeg"
            else:
                imgTypes = ["image/jpeg", "image/gif"]
                dlgC = ChooserDialog(self, 'Choose Image Type', \
                                     "Choose the type of your image (Manila only supprts GIF + JPEG)...", \
                                     imgTypes, imgTypes[0])
                result = dlgC.showModal()
                if not result.accepted:
                    self.status("Image uploading cancelled.")
                    dlgC.destroy()
                    return
                i = dlgC.components.options.findString(dlgC.components.options.stringSelection)
                if i == -1:
                    self.status("Image uploading cancelled (no mime type selected for image).")
                    dlgC.destroy()
                    return
                dlgC.destroy()
                mimeType = imgTypes[i]

            result = dialog.textEntryDialog(self, 'Picture Name:', 'Picture Name', '')
            if result.accepted:
                imageTitle = result.text

                self.showWaitMsg("Uploadng image...")
                msg = curManilaAccount.manilaCreateMsg(imageTitle,\
                                                       "...", "text/x-outline-tabbed")
                if curManilaAccount.anErrorOccured():
                    self.status("Error uploading image: %s" % curManilaAccount.getErrorMessage())
                else:
                    curManilaAccount.manilaAttachPicture(msg["msgnum"], path, mimeType)
                    if curManilaAccount.anErrorOccured():
                        self.status("Error uploading image: %s" % curManilaAccount.getErrorMessage())
                    else:
                        self.status("Image uploaded successfully.")
            else:
                self.status("Image upload cancelled.")
        else:
            self.status("Image upload cancelled.")


    def on_menuManilaPostNewStory_select(self, event):


Generated by  Doxygen 1.6.0   Back to index