def _populateMediaSitesList(self, selectedMediaStorageId=None): self.mediaUploadCombo.Clear() # FIXME (PJ) create a new 're-usable' model which lists given blog site id + available media storages => maybe as a new control if self.blogSiteId: siteDef = self._getModel().getPublisherSite(self.blogSiteId) if siteDef.getCapabilities().supportsUploadMedia(): bitmap = siteDef.getIconAsBitmap() name = u"Blog Fileupload (via %s)" % siteDef.getName( ) #$NON-NLS-1$ self.mediaUploadCombo.Append(name, siteDef, bitmap) mediaStores = [] mediaStores.extend(self._getModel().getMediaStorages()) mediaStores.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) for mediaStore in mediaStores: mediaSite = self._getModel().getMediaSite(mediaStore) if mediaSite.isInternal(): continue name = mediaStore.getName() + u" (" + mediaSite.getDisplayName( ) + u")" #$NON-NLS-1$ #$NON-NLS-2$ iconPath = mediaSite.getIconPath() bitmap = wx.Image(iconPath, getImageType(iconPath)).ConvertToBitmap() self.mediaUploadCombo.Append(name, mediaStore, bitmap) # select first item if self.mediaUploadCombo.GetCount() > 0: if selectedMediaStorageId: self._selectMediaSite(selectedMediaStorageId) else: self.mediaUploadCombo.SetSelection(0) self.mediaUploadCombo.validate()
def _populateMediaSitesList(self, selectedMediaStorageId = None): self.mediaUploadCombo.Clear() # FIXME (PJ) create a new 're-usable' model which lists given blog site id + available media storages => maybe as a new control if self.blogSiteId: siteDef = self._getModel().getPublisherSite(self.blogSiteId) if siteDef.getCapabilities().supportsUploadMedia(): bitmap = siteDef.getIconAsBitmap() name = u"Blog Fileupload (via %s)" % siteDef.getName() #$NON-NLS-1$ self.mediaUploadCombo.Append(name, siteDef, bitmap) mediaStores = [] mediaStores.extend( self._getModel().getMediaStorages() ) mediaStores.sort( lambda x, y: cmp( x.getName().lower(), y.getName().lower() ) ) for mediaStore in mediaStores: mediaSite = self._getModel().getMediaSite(mediaStore) if mediaSite.isInternal(): continue name = mediaStore.getName() + u" (" + mediaSite.getDisplayName() + u")" #$NON-NLS-1$ #$NON-NLS-2$ iconPath = mediaSite.getIconPath() bitmap = wx.Image(iconPath, getImageType(iconPath)).ConvertToBitmap() self.mediaUploadCombo.Append(name, mediaStore, bitmap) # select first item if self.mediaUploadCombo.GetCount() > 0: if selectedMediaStorageId: self._selectMediaSite(selectedMediaStorageId) else: self.mediaUploadCombo.SetSelection(0) self.mediaUploadCombo.validate()
def _createWizardImageControl(self, imagePath): if imagePath is None: return None if not os.path.isfile(imagePath): return None image = wx.Image(imagePath, getImageType(imagePath)) bitmap = image.ConvertToBitmap() zbitmap = ZStaticBitmap(self, bitmap) zbitmap.setBackgroundColor(wx.Color(255, 255, 255)) return zbitmap
def updateFromConnectionResp(self, connectionResp): imagingService = getApplicationModel().getService(IZAppServiceIDs.IMAGING_SERVICE_ID) bgColor = self.GetBackgroundColour() tnParams = ZThumbnailParams(backgroundColor = (bgColor.Red(), bgColor.Green(), bgColor.Blue()), dropShadow = True) tnFile = os.path.join(getApplicationModel().getUserProfile().getTempDirectory(), u"_ZImagePreviewPanel_tn.png") #$NON-NLS-1$ try: imagingService.generateThumbnail(connectionResp.getContentFilename(), tnParams, tnFile) image = wx.Image(tnFile, getImageType(tnFile)) if image is None: raise ZException() bitmap = image.ConvertToBitmap() self.previewBmp.setBitmap(bitmap) deleteFile(tnFile) self.generatingMsg.Show(False) self.generatingMsg.stop() self.previewUnavailableMsg.Show(False) self.previewBmp.Show(True) except Exception, e: getLoggerService().exception(e) self.updateFromError(e)
def _populateImageList(self): for site in self.model.getMediaSites(): iconKey = site.getId() iconPath = site.getIconPath() icon = wx.Image(iconPath, getImageType(iconPath)).ConvertToBitmap() self.imageList.addImage(iconKey, icon)