class ZImageDialog(ZValidatingHeaderDialog, ZPersistentDialogMixin): def __init__(self, parent, model): # model is instance of ZEditImageModel. self.model = model self.aspectRatio = 0.0 title = _extstr(u"imagedialog.EditImageInformation") #$NON-NLS-1$ if not self.model.isEditMode(): title = _extstr(u"imagedialog.InsertImage") #$NON-NLS-1$ ZValidatingHeaderDialog.__init__(self, parent, wx.ID_ANY, title, style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name = u"ZImageDialog") #$NON-NLS-1$ bestHeight = self.GetBestSizeTuple()[1] self.SetMinSize(wx.Size(-1, bestHeight)) ZPersistentDialogMixin.__init__(self, IZBlogAppUserPrefsKeys.IMAGE_DIALOG, True, True) # end __init__() def _createNonHeaderWidgets(self): self.imagePropsStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.ImageProperties")) #$NON-NLS-1$ self.sizeStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Size")) #$NON-NLS-1$ self.alignmentStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Alignment")) #$NON-NLS-1$ self.borderStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Border")) #$NON-NLS-1$ self.srcLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Src")) #$NON-NLS-1$ #$NON-NLS-2$ self.altTextLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.ALTText")) #$NON-NLS-1$ #$NON-NLS-2$ self.titleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Title")) #$NON-NLS-1$ #$NON-NLS-2$ self.classLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Class")) #$NON-NLS-1$ #$NON-NLS-2$ self.widthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$ self.heightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Height")) #$NON-NLS-1$ #$NON-NLS-2$ wildcard = u"Image files|*.gif;*.jpg;*.png;*.jpeg" #$NON-NLS-1$ self.filePicker = wx.FilePickerCtrl(self, wildcard=wildcard,style=wx.FLP_OPEN|wx.FLP_FILE_MUST_EXIST )#|wx.FLP_USE_TEXTCTRL) self.srcText = ZValidatingTextCtrl(ZFileUrlSelectionValidator(_extstr(u"imagedialog.InvalidImageURLError")), self, wx.ID_ANY) #$NON-NLS-1$ self.altText = wx.TextCtrl(self, wx.ID_ANY) self.titleText = wx.TextCtrl(self, wx.ID_ANY) self.classText = wx.TextCtrl(self, wx.ID_ANY) self.lockAspect = wx.CheckBox(self,wx.ID_ANY, u"%s" % _extstr(u"imagedialog.LockAspect")) #$NON-NLS-2$ #$NON-NLS-1$ flags = ZIntegerSelectionValidator.ALLOW_EMPTY | ZIntegerSelectionValidator.ALLOW_ZERO | ZIntegerSelectionValidator.POSITIVE_ONLY self.widthText = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self, wx.ID_ANY) self.heightText = ZValidatingTextCtrl(ZIntegerSelectionValidator(flags=flags), self, wx.ID_ANY) alignments = [] for aname in ZImageAlignMenuLabels.ALIGN_KEYWORDS: alignments.append( ZImageAlignMenuLabels.ALIGN_LABELS[aname] ) #$NON-NLS-1$ self.alignChoices = wx.Choice(self, wx.ID_ANY, (100, 50), choices = alignments) self.borderStyleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Style")) #$NON-NLS-1$ #$NON-NLS-2$ self.borderWidthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$ self.borderColorLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Color")) #$NON-NLS-1$ #$NON-NLS-2$ borders = [] for bname in ZImageBorderMenuLabels.BORDER_KEYWORDS: borders.append( ZImageBorderMenuLabels.BORDER_LABELS[bname] ) self.borderStyles = wx.Choice(self, wx.ID_ANY, (200, 50), choices = borders) self.borderWidthValidator = ZCssLengthSelectionValidator() self.borderWidthText = ZValidatingTextCtrl(self.borderWidthValidator, self, wx.ID_ANY) self.borderColorPicker = wx.ColourPickerCtrl(self) self.marginStaticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagedialog.Margin")) #$NON-NLS-1$ self.marginLeftLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Left")) #$NON-NLS-1$ #$NON-NLS-2$ self.marginRightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Right")) #$NON-NLS-1$ #$NON-NLS-2$ self.marginTopLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Top")) #$NON-NLS-1$ #$NON-NLS-2$ self.marginBotLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagedialog.Bottom")) #$NON-NLS-1$ #$NON-NLS-2$ self.marginTopText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY) self.marginBotText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY) self.marginLeftText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY) self.marginRightText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY) # end _createNonHeaderWidgets() def _initAspectRatio(self): try: self.aspectRatio = (float(self.widthText.GetValue() ) / float(self.heightText.GetValue() )) except: self.aspectRatio = 0.0 self.lockAspect.SetValue(self.aspectRatio > 0) self.lockAspect.Enable(self.aspectRatio > 0) # end _initAspectRatio() def _populateNonHeaderWidgets(self): self.srcText.SetValue( getSafeString( self.model.getAttribute(u"src") ) ) #$NON-NLS-1$ self.altText.SetValue( getSafeString( self.model.getAttribute(u"alt") ) ) #$NON-NLS-1$ self.titleText.SetValue( getSafeString( self.model.getAttribute(u"title") ) ) #$NON-NLS-1$ self.classText.SetValue( getSafeString( self.model.getAttribute(u"class") ) ) #$NON-NLS-1$ self.widthText.SetValue( getSafeString( self.model.getAttribute(u"width") ) ) #$NON-NLS-1$ self.heightText.SetValue( getSafeString( self.model.getAttribute(u"height") ) ) #$NON-NLS-1$ self._initAspectRatio() (top, right, bot, left) = self.model.getMargins() self.marginTopText.SetValue(getSafeString(top)) self.marginRightText.SetValue(getSafeString(right)) self.marginBotText.SetValue(getSafeString(bot)) self.marginLeftText.SetValue(getSafeString(left)) (width, style, cssColor) = self.model.getBorder() if cssColor: color = wx.Colour(cssColor.getRed(), cssColor.getGreen(), cssColor.getBlue()) self.borderColorPicker.SetColour(color) self.borderWidthText.SetValue(getSafeString(width)) style = getSafeString(style).lower() idx = 0 try: idx = ZImageBorderMenuLabels.BORDER_KEYWORDS.index( style ) except: idx = 0 self.borderStyles.SetSelection(idx) self._updateBorderControlsState() align = getSafeString( self.model.getAttribute(u"align") ) #$NON-NLS-1$ # align = None, Left etc. # find index within keywords idx = 0 try: idx = ZImageAlignMenuLabels.ALIGN_KEYWORDS.index( align.lower() ) except: idx = 0 self.alignChoices.SetSelection(idx) # end _populateNonHeaderWidgets() def _layoutNonHeaderWidgets(self): # Image Properties srcAndFileSizer = wx.BoxSizer(wx.HORIZONTAL) srcAndFileSizer.Add(self.srcText, 1, wx.EXPAND | wx.ALL, 1) srcAndFileSizer.Add(self.filePicker, 0, wx.ALL, 1) imagePropsGridSizer = wx.FlexGridSizer(4, 2, 2, 2) imagePropsGridSizer.AddGrowableCol(1) imagePropsGridSizer.Add(self.srcLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) imagePropsGridSizer.AddSizer(srcAndFileSizer, 1, wx.EXPAND | wx.ALL, 1) imagePropsGridSizer.Add(self.altTextLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) imagePropsGridSizer.Add(self.altText, 1, wx.EXPAND | wx.ALL, 1) imagePropsGridSizer.Add(self.titleLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) imagePropsGridSizer.Add(self.titleText, 1, wx.EXPAND | wx.ALL, 1) imagePropsGridSizer.Add(self.classLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) imagePropsGridSizer.Add(self.classText, 1, wx.EXPAND | wx.ALL, 1) imagePropsStaticBoxSizer = wx.StaticBoxSizer(self.imagePropsStaticBox, wx.VERTICAL) imagePropsStaticBoxSizer.AddSizer(imagePropsGridSizer, 1, wx.EXPAND | wx.ALL, 5) # Size sizeGridSizer = wx.FlexGridSizer(2, 2, 2, 2) sizeGridSizer.Add(self.widthLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) sizeGridSizer.Add(self.widthText, 1, wx.EXPAND | wx.ALL, 1) sizeGridSizer.Add(self.heightLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) sizeGridSizer.Add(self.heightText, 1, wx.EXPAND | wx.ALL, 1) sizeStaticBoxSizer = wx.StaticBoxSizer(self.sizeStaticBox, wx.VERTICAL) sizeStaticBoxSizer.Add(self.lockAspect, 0, wx.EXPAND | wx.ALL, 5) sizeStaticBoxSizer.AddSizer(sizeGridSizer, 1, wx.EXPAND | wx.ALL, 5) alignmentStaticBoxSizer = wx.StaticBoxSizer(self.alignmentStaticBox, wx.VERTICAL) alignmentStaticBoxSizer.Add(self.alignChoices, 1, wx.EXPAND | wx.ALL, 5) # Border borderGridSizer = wx.FlexGridSizer(3, 2, 2, 2) borderGridSizer.Add(self.borderStyleLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) borderGridSizer.Add(self.borderStyles, 1, wx.EXPAND | wx.ALL, 1) borderGridSizer.Add(self.borderWidthLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) borderGridSizer.Add(self.borderWidthText, 1, wx.EXPAND | wx.ALL, 1) borderGridSizer.Add(self.borderColorLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) borderGridSizer.Add(self.borderColorPicker, 0,wx.ALL, 1) borderStaticBoxSizer = wx.StaticBoxSizer(self.borderStaticBox, wx.VERTICAL) borderStaticBoxSizer.AddSizer(borderGridSizer, 1, wx.EXPAND | wx.ALL, 5) marginGridSizer = wx.FlexGridSizer(4, 4, 2, 2) marginGridSizer.Add(self.marginTopLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) marginGridSizer.Add(self.marginTopText, 1, wx.EXPAND | wx.ALL, 1) marginGridSizer.Add(self.marginLeftLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) marginGridSizer.Add(self.marginLeftText, 1, wx.EXPAND | wx.ALL, 1) marginGridSizer.Add(self.marginBotLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) marginGridSizer.Add(self.marginBotText, 1, wx.EXPAND | wx.ALL, 1) marginGridSizer.Add(self.marginRightLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) marginGridSizer.Add(self.marginRightText, 1, wx.EXPAND | wx.ALL, 1) marginStaticBoxSizer = wx.StaticBoxSizer(self.marginStaticBox, wx.VERTICAL) marginStaticBoxSizer.AddSizer(marginGridSizer, 1, wx.EXPAND | wx.ALL, 5) # Size + Alignment Box Sizer sizeAndAlignmentBoxSizer = wx.FlexGridSizer(2, 2, 2, 2) sizeAndAlignmentBoxSizer.AddSizer(sizeStaticBoxSizer, 1, wx.EXPAND | wx.ALL, 2) sizeAndAlignmentBoxSizer.AddSizer(borderStaticBoxSizer, 1, wx.EXPAND | wx.ALL, 2) sizeAndAlignmentBoxSizer.AddSizer(alignmentStaticBoxSizer, 1, wx.EXPAND | wx.ALL, 2) sizeAndAlignmentBoxSizer.AddSizer(marginStaticBoxSizer, 1, wx.EXPAND | wx.ALL, 2) # Dialog Sizer dialogBoxSizer = wx.BoxSizer(wx.VERTICAL) dialogBoxSizer.AddSizer(imagePropsStaticBoxSizer, 0, wx.EXPAND | wx.ALL, 5) dialogBoxSizer.AddSizer(sizeAndAlignmentBoxSizer, 0, wx.EXPAND | wx.ALL, 5) return dialogBoxSizer # end _layoutNonHeaderWidgets() def _bindWidgetEvents(self): self.Bind(wx.EVT_FILEPICKER_CHANGED, self.onFilePickerChanged, self.filePicker) self.Bind(wx.EVT_CHOICE, self.onBorderStyleChanged, self.borderStyles) self.Bind(wx.EVT_TEXT, self.onImageWidthChange, self.widthText) self.Bind(wx.EVT_TEXT, self.onImageHeightChange, self.heightText) self._bindValidatingWidget(self.srcText) self._bindValidatingWidget(self.widthText) self._bindValidatingWidget(self.heightText) self._bindValidatingWidget(self.borderWidthText) self._bindValidatingWidget(self.marginTopText) self._bindValidatingWidget(self.marginRightText) self._bindValidatingWidget(self.marginBotText) self._bindValidatingWidget(self.marginLeftText) self.Bind(wx.EVT_BUTTON, self.onOK, self.FindWindowById(wx.ID_OK)) # end _bindWidgetEvents() def _updateModel(self): self.model.setAttribute(u"src", self.srcText.GetValue().strip() ) #$NON-NLS-1$ self.model.setAttribute(u"alt", self.altText.GetValue().strip() ) #$NON-NLS-1$ self.model.setAttribute(u"title", self.titleText.GetValue().strip() ) #$NON-NLS-1$ self.model.setAttribute(u"class", self.classText.GetValue().strip() ) #$NON-NLS-1$ idx = self.alignChoices.GetSelection() if idx >=0 and idx < len(ZImageAlignMenuLabels.ALIGN_KEYWORDS): align = ZImageAlignMenuLabels.ALIGN_KEYWORDS[idx] self.model.setAttribute(u"align", align.lower() ) #$NON-NLS-1$ # Width and height width = 0 height = 0 try: width = int(self.widthText.GetValue()) height = int(self.heightText.GetValue()) except: pass if width > 0 and height > 0: self.model.setAttribute(u"width", u"%d" % width ) #$NON-NLS-1$ #$NON-NLS-2$ self.model.setAttribute(u"height", u"%d" % height ) #$NON-NLS-1$ #$NON-NLS-2$ # Margin t = self.marginTopText.GetValue().strip() r = self.marginRightText.GetValue().strip() b = self.marginBotText.GetValue().strip() l = self.marginLeftText.GetValue().strip() self.model.setMargins(t,r,b,l) # Border style = ZImageBorderMenuLabels.BORDER_KEYWORDS[0] # default is None idx = self.borderStyles.GetSelection() if idx >=0 and idx < len(ZImageBorderMenuLabels.BORDER_KEYWORDS): style = ZImageBorderMenuLabels.BORDER_KEYWORDS[idx] width = self.borderWidthText.GetValue().strip() cssHexColor = self.borderColorPicker.GetColour().GetAsString(wx.C2S_HTML_SYNTAX) self.model.setBorder(width, style, cssHexColor) # end updateModel def onOK(self, event): self._updateModel() event.Skip() # end onOK() def onImageHeightChange(self, event): #@UnusedVariable if self.lockAspect.IsChecked() and self.aspectRatio > 0: try: height = int(self.heightText.GetValue()) width = int(height * self.aspectRatio) self.widthText.ChangeValue(unicode(width)) except: pass event.Skip() # end onImageHeightChange() def onImageWidthChange(self, event): #@UnusedVariable if self.lockAspect.IsChecked() and self.aspectRatio > 0: try: width = int(self.widthText.GetValue()) height = int(width / self.aspectRatio) self.heightText.ChangeValue(unicode(height)) except: pass event.Skip() # end onImageWidthChange() def _updateBorderControlsState(self): enable = self.borderStyles.GetCurrentSelection() > 0 if enable: self.borderWidthValidator.setFlags(0) else: self.borderWidthValidator.setFlags(ZCssLengthSelectionValidator.ALLOW_EMPTY) self.borderWidthText.validate() if enable and not self.borderWidthText.GetValue(): self.borderWidthText.SetValue(u"1px") #$NON-NLS-1$ self.borderWidthText.Enable(enable) self.borderColorPicker.Enable(enable) # end _updateBorderControlsState() def onBorderStyleChanged(self, event): #@UnusedVariable self._updateBorderControlsState() # end onBorderStyleChanged def onFilePickerChanged(self, event): path = getNoneString( event.GetPath()) if path: self.srcText.SetValue(path) event.Skip() # end onFilePickerChanged def _getHeaderTitle(self): if self.model.isEditMode(): return _extstr(u"imagedialog.Edit_Image") #$NON-NLS-1$ else: return _extstr(u"imagedialog.Insert_Image") #$NON-NLS-1$ # end _getHeaderTitle() def _getHeaderMessage(self): if self.model.isEditMode(): return _extstr(u"imagedialog.ImageDialogEditDescription") #$NON-NLS-1$ else: return _extstr(u"imagedialog.ImageDialogInsertDescription") #$NON-NLS-1$ # end _getHeaderMessage() def _getHeaderImagePath(self): return u"images/dialogs/image/header_image.png" #$NON-NLS-1$ # end _getHeaderImagePath() def _getButtonTypes(self): return ZBaseDialog.OK_BUTTON | ZBaseDialog.CANCEL_BUTTON
class ZNewPublisherSiteUrlPage(ZNewPublisherSiteWizardPageBase): def __init__(self, model, parent): ZNewPublisherSiteWizardPageBase.__init__(self, model, parent) # end __init__() def _createWidgets(self): self.description1 = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.WelcomeMessage")) #$NON-NLS-1$ self.description1.SetFont(getDefaultFontBold()) self.description2 = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.WizardDescription"), size=wx.Size(-1, 80)) #$NON-NLS-1$ self.urlLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.BlogUrlLabel")) #$NON-NLS-1$ urlValidator = ZUrlSelectionValidator( _extstr(u"publishersitewizard.BlogUrlInvalid"), nonEmpty=False) #$NON-NLS-1$ self.urlText = ZValidatingTextCtrl(urlValidator, self, wx.ID_ANY) self.urlText.SetToolTipString( _extstr(u"publishersitewizard.BlogUrlTooltip")) #$NON-NLS-1$ self.animateControl = ZProgressLabelCtrl(self) self.clickHereHyperlink = wx.HyperlinkCtrl( self, wx.ID_ANY, _extstr(u"publishersitewizard.NoBlogYet"), u"http://www.blogger.com/?ref=ZoundryRaven" ) #$NON-NLS-2$ #$NON-NLS-1$ # end _createWidgets() def _populateWidgets(self): self._showBusy(False) # end _populateWidgets() def _bindWidgetEvents(self): self._bindValidatingWidget(self.urlText) # end _bindWidgetEvents() def _layoutWidgets(self): flexGridSizer = wx.FlexGridSizer(1, 2, 5, 5) flexGridSizer.AddGrowableCol(1) flexGridSizer.Add(self.urlLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.urlText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.animateControl, 0, wx.EXPAND | wx.ALIGN_LEFT | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.clickHereHyperlink, 0, wx.ALL, 5) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.description1, 0, wx.EXPAND | wx.ALL, 10) box.Add(self.description2, 0, wx.EXPAND | wx.ALL, 10) box.AddSizer(flexGridSizer, 0, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(box) # end _layoutWidgets() def _showBusy(self, enable, text=u""): #$NON-NLS-1$ if getNoneString(text): self.animateControl.setLabel(text) self.animateControl.Show(enable) # end _showBusy() def _getSiteUrl(self): return self.urlText.GetValue().strip() # end _getSiteUrl() def getDataProperties(self): rval = {} rval[u"siteurl-page.url"] = self._getSiteUrl() #$NON-NLS-1$ return rval # end getDataProperties() def _refresh(self, eventType, eventData): if eventType == u"begin-autodiscover": #$NON-NLS-1$ self.urlText.Enable(False) self._showBusy(True, u"Checking... %s" % self._getSiteUrl()) #$NON-NLS-1$ elif eventType == u"end-autodiscover": #$NON-NLS-1$ self.urlText.Enable(True) self._showBusy(False) elif eventType == u"error-autodiscover": #$NON-NLS-1$ (errMsg, errDetails, err) = eventData #@UnusedVariable ZShowErrorMessage(self, errMsg, errDetails) # end _refresh() def onEnter(self, session, eventDirection): #@UnusedVariable self.urlText.SetFocus() # end onEnter() def onExit(self, session, eventDirection): if eventDirection == ZWizardPage.NEXT: oldValue = session.getProperty(u"siteurl-page.url") #$NON-NLS-1$ newValue = self._getSiteUrl() # auto discover if there is a new value and it not empty if newValue and newValue != oldValue: # check for cached discover data cacheMap = session.getProperty( u"siteurl-page.discover-info-cache") #$NON-NLS-1$ if cacheMap and cacheMap.has_key(newValue): discoverInfo = cacheMap[newValue] session.setProperty(u"siteurl-page.discover-info", discoverInfo) #$NON-NLS-1$ else: task = ZAutodiscoverTask(self, session) self._fireBeginBackgroundTaskEvent(task) return False elif oldValue and not newValue: # new value does not exist. reset auto-disc. session.setProperty(u"siteurl-page.discover-info", None) #$NON-NLS-1$ return True
class ZNewPublisherSiteApiInfoPage(ZNewPublisherSiteWizardPageBase): def __init__(self, model, parent): ZNewPublisherSiteWizardPageBase.__init__(self, model, parent) # end __init__() def _createWidgets(self): self.description1 = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.ApiInfo")) #$NON-NLS-1$ self.description1.SetFont(getDefaultFontBold()) self.description2 = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.ApiInfoDescription"), size=wx.Size(-1, 40)) #$NON-NLS-1$ self.accLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.AccountNameLabel")) #$NON-NLS-1$ accNameValidator = ZPublisherAccountNameValidator(self._getModel()) self.accText = ZValidatingTextCtrl(accNameValidator, self, wx.ID_ANY) self.accText.SetToolTipString( _extstr(u"publishersitewizard.AccountNameTooltip")) #$NON-NLS-1$ self.siteLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.SiteTypeLabel")) #$NON-NLS-1$ comboValidator = ZNonEmptySelectionValidator( _extstr(u"publishersitewizard.EmptySiteTypeSelectionError") ) #$NON-NLS-1$ self.siteCombo = ZValidatingBitmapComboBox(comboValidator, self, wx.ID_ANY, style=wx.CB_READONLY) self.siteCombo.SetToolTipString( _extstr(u"publishersitewizard.SiteTypeTooltip")) #$NON-NLS-1$ self.Bind(wx.EVT_COMBOBOX, self.onComboEvent, self.siteCombo.widget) self.autodiscoveryHint = wx.StaticText(self, wx.ID_ANY, u"") #$NON-NLS-1$ self.usernameLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.UsernameLabel")) #$NON-NLS-1$ usernameValidator = ZNonEmptySelectionValidator( _extstr(u"publishersitewizard.EmptyUsername")) #$NON-NLS-1$ self.usernameText = ZValidatingTextCtrl(usernameValidator, self, wx.ID_ANY) self.usernameText.SetToolTipString( _extstr(u"publishersitewizard.UsernameTooltip")) #$NON-NLS-1$ self.passwordLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.PasswordLabel")) #$NON-NLS-1$ passwordValidator = ZNonEmptySelectionValidator( _extstr(u"publishersitewizard.EmptyPassword")) #$NON-NLS-1$ self.passwordText = ZValidatingTextCtrl(passwordValidator, self, wx.ID_ANY, style=wx.TE_PASSWORD) self.passwordText.SetToolTipString( _extstr(u"publishersitewizard.PasswordTooltip")) #$NON-NLS-1$ self.apiUrlLabel = wx.StaticText( self, wx.ID_ANY, _extstr(u"publishersitewizard.ApiUrlLabel")) #$NON-NLS-1$ apiUrlValidator = ZUrlSelectionValidator( _extstr(u"publishersitewizard.ApiUrlInvalid")) #$NON-NLS-1$ self.apiUrlText = ZValidatingTextCtrl(apiUrlValidator, self, wx.ID_ANY) self.apiUrlText.SetToolTipString( _extstr(u"publishersitewizard.ApiUrlTooltip")) #$NON-NLS-1$ self.apiUrlHint = wx.StaticText(self, wx.ID_ANY, u"Api Url hints") #$NON-NLS-1$ self.animateControl = ZProgressLabelCtrl(self) # end _createWidgets() def _populateWidgets(self): self._showBusy(False) siteDefList = [] siteDefList.extend(self._getModel().listPublisherSites()) siteDefList.sort(lambda x, y: cmp(x.getName().lower(), y.getName().lower())) for siteDef in siteDefList: bitmap = siteDef.getIconAsBitmap() self.siteCombo.Append(siteDef.getName(), siteDef, bitmap) # end _populateWidgets() def _bindWidgetEvents(self): self._bindValidatingWidget(self.accText) self._bindValidatingWidget(self.siteCombo) self._bindValidatingWidget(self.usernameText) self._bindValidatingWidget(self.passwordText) self._bindValidatingWidget(self.apiUrlText) # end _bindWidgetEvents() def _layoutWidgets(self): flexGridSizer = wx.FlexGridSizer(7, 2, 5, 5) flexGridSizer.AddGrowableCol(1) flexGridSizer.Add(self.accLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.accText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.siteLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.siteCombo, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.autodiscoveryHint, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.usernameLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.usernameText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.passwordLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.passwordText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(self.apiUrlLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.apiUrlText, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.apiUrlHint, 0, wx.EXPAND | wx.RIGHT, 5) flexGridSizer.Add(wx.StaticText(self, wx.ID_ANY), 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) flexGridSizer.Add(self.animateControl, 0, wx.EXPAND | wx.ALIGN_LEFT | wx.RIGHT, 5) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.description1, 0, wx.EXPAND | wx.ALL, 10) box.Add(self.description2, 0, wx.EXPAND | wx.ALL, 10) box.AddSizer(flexGridSizer, 0, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(box) # end _layoutWidgets() def getDataProperties(self): rval = {} rval[u"apiinfo-page.accname"] = self.accText.GetValue().strip( ) #$NON-NLS-1$ site = self._getSelectedSite() id = None if site: id = site.getId() rval[u"apiinfo-page.siteid"] = id #$NON-NLS-1$ rval[u"apiinfo-page.username"] = self.usernameText.GetValue().strip( ) #$NON-NLS-1$ rval[u"apiinfo-page.password"] = self.passwordText.GetValue().strip( ) #$NON-NLS-1$ rval[u"apiinfo-page.apiurl"] = self.apiUrlText.GetValue().strip( ) #$NON-NLS-1$ return rval # end getDataProperties() def _enableControls(self, enable): self.accText.Enable(enable) self.siteCombo.Enable(enable) self.usernameText.Enable(enable) self.passwordText.Enable(enable) self.apiUrlText.Enable(enable) def _showBusy(self, enable, text=u""): #$NON-NLS-1$ if getNoneString(text): self.animateControl.setLabel(text) self.animateControl.Show(enable) def _updateDiscoverInfo(self, discoverInfo): hint = u"" #$NON-NLS-1$ if discoverInfo: if discoverInfo.engineName: hint = u"Autodiscovered %s" % discoverInfo.engineName #$NON-NLS-1$ else: hint = u"Autodiscover information not available." #$NON-NLS-1$ if discoverInfo.username and not self.usernameText.GetValue(): self.usernameText.SetValue(discoverInfo.username) if discoverInfo.siteId: self._selectSiteId(discoverInfo.siteId) apiUrl = None if getNoneString(discoverInfo.apiUrl): apiUrl = discoverInfo.apiUrl else: # find api url from site def apiUrl = self._getDefaultUrlForSelectedSite() if apiUrl: self.apiUrlText.SetValue(apiUrl) self.autodiscoveryHint.SetLabel(hint) def _refresh(self, eventType, eventData): if eventType == u"begin-listblogs": #$NON-NLS-1$ self._enableControls(False) self._showBusy(True, u"Getting blog list...") #$NON-NLS-1$ elif eventType == u"end-listblogs": #$NON-NLS-1$ self._enableControls(True) self._showBusy(False) elif eventType == u"error-listblogs": #$NON-NLS-1$ (errMsg, errDetails, err) = eventData #@UnusedVariable ZShowErrorMessage(self, errMsg, errDetails) def onEnter(self, session, eventDirection): self.accText.SetFocus() if eventDirection == ZWizardPage.NEXT: discoverInfo = session.getProperty( u"siteurl-page.discover-info") #$NON-NLS-1$ #print u"ApiInfoPageinfo-Enter discinfo=", discoverInfo # FIXME (PJ) delete this #$NON-NLS-1$ self._updateDiscoverInfo(discoverInfo) def onExit(self, session, eventDirection): # look up blog list if data has changed if eventDirection == ZWizardPage.NEXT: siteId = self._getSelectedSite().getId() username = self.usernameText.GetValue().strip() password = self.passwordText.GetValue().strip() apiUrl = self.apiUrlText.GetValue().strip() key = siteId + username + password + apiUrl oldKey = session.getProperty( u"apiinfo-page.modifykey") #$NON-NLS-1$ if not oldKey or oldKey != key: task = ZListBlogsTask(self, session, siteId, username, password, apiUrl, key) self._fireBeginBackgroundTaskEvent(task) return False return True def onComboEvent(self, event): #@UnusedVariable defUrl = self._getDefaultUrlForSelectedSite() if defUrl: self.apiUrlText.SetValue(defUrl) def _getDefaultUrlForSelectedSite(self): # Attempts to get the default or predefined url for the currenly selected site. siteDef = self._getSelectedSite() defUrl = self._getModel().getDefaultApiUrl(siteDef) return defUrl def _selectSiteId(self, siteId): n = self.siteCombo.GetCount() for idx in range(n): data = self.siteCombo.GetClientData(idx) if data and data.getId() == siteId: self.siteCombo.SetSelection(idx) self.siteCombo.validate() break def _getSelectedSite(self): data = None idx = self.siteCombo.GetSelection() if idx != -1: data = self.siteCombo.GetClientData(idx) # print "SELSITE %s %s" % (data.getName(),data.getId()) return data
class ZThumbnailImageDialog(ZValidatingHeaderDialog, ZPersistentDialogMixin): def __init__(self, parent): self.model = ZThumbnailImageDialogModel() title = _extstr(u"imagehandlerdialog.Generate_Thumbnail") #$NON-NLS-1$ ZValidatingHeaderDialog.__init__(self, parent, wx.ID_ANY, title, style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, name = u"ZThumbnailImageDialog") #$NON-NLS-1$ bestHeight = self.GetBestSizeTuple()[1] self.SetMinSize(wx.Size(-1, bestHeight)) ZPersistentDialogMixin.__init__(self, IZBlogAppUserPrefsKeys.DND_THUMBNAIL_DIALOG, True, True) # end __init__() def _createNonHeaderWidgets(self): self.doNotGenRadioButton = wx.RadioButton(self, wx.ID_ANY, _extstr(u"imagehandlerdialog.DoNotGenerateOption")) #$NON-NLS-1$ self.genRadioButton = wx.RadioButton(self, wx.ID_ANY, _extstr(u"imagehandlerdialog.GenerateOption")) #$NON-NLS-1$ self.tnSettingsGroupBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"imagehandlerdialog.ThumbnailSettings")) #$NON-NLS-1$ self.sizeLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _extstr(u"imagehandlerdialog.Size")) #$NON-NLS-1$ #$NON-NLS-2$ sizeChoices = [] for size in ZThumbnailSizeMenuLabels.SIZE_KEYWORDS: sizeChoices.append(ZThumbnailSizeMenuLabels.SIZE_LABELS[size]) self.sizeChoice = wx.Choice(self, wx.ID_ANY, (100, 50), choices = sizeChoices) self.alignLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Alignment")) #$NON-NLS-1$ #$NON-NLS-2$ alignments = [] for aname in ZImageAlignMenuLabels.ALIGN_KEYWORDS: alignments.append( ZImageAlignMenuLabels.ALIGN_LABELS[aname] ) #$NON-NLS-1$ self.alignChoice = wx.Choice(self, wx.ID_ANY, (100, 50), choices = alignments) self.borderStaticBox = wx.StaticBox(self, wx.ID_ANY, _blogappextstr(u"imagedialog.Border")) #$NON-NLS-1$ self.borderStyleLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Style")) #$NON-NLS-1$ #$NON-NLS-2$ self.borderWidthLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Width")) #$NON-NLS-1$ #$NON-NLS-2$ self.borderColorLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Color")) #$NON-NLS-1$ #$NON-NLS-2$ borders = [] for bname in ZImageBorderMenuLabels.BORDER_KEYWORDS: borders.append( ZImageBorderMenuLabels.BORDER_LABELS[bname] ) self.borderStyleChoice = wx.Choice(self, wx.ID_ANY, (200, 50), choices = borders) self.borderWidthValidator = ZCssLengthSelectionValidator() self.borderWidthText = ZValidatingTextCtrl(self.borderWidthValidator, self, wx.ID_ANY) self.borderColorPicker = wx.ColourPickerCtrl(self) self.marginStaticBox = wx.StaticBox(self, wx.ID_ANY, _blogappextstr(u"imagedialog.Margin")) #$NON-NLS-1$ self.marginLeftLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Left")) #$NON-NLS-1$ #$NON-NLS-2$ self.marginRightLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Right")) #$NON-NLS-1$ #$NON-NLS-2$ self.marginTopLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Top")) #$NON-NLS-1$ #$NON-NLS-2$ self.marginBotLabel = wx.StaticText(self, wx.ID_ANY, u"%s:" % _blogappextstr(u"imagedialog.Bottom")) #$NON-NLS-1$ #$NON-NLS-2$ self.marginTopText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1)) self.marginBotText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1)) self.marginLeftText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1)) self.marginRightText = ZValidatingTextCtrl(ZCssLengthSelectionValidator(flags=ZCssLengthSelectionValidator.ALLOW_EMPTY), self, wx.ID_ANY, size=wx.Size(25, -1)) # end _createNonHeaderWidgets() def _populateNonHeaderWidgets(self): genTNFlag = self.model.generateTNFlag self.genRadioButton.SetValue(genTNFlag) self.doNotGenRadioButton.SetValue(not genTNFlag) self._enableWidgets(genTNFlag) tnSize = self._recallThumbnailSize() idx = 0 try: idx = ZThumbnailSizeMenuLabels.SIZE_KEYWORDS.index( tnSize ) except: idx = 1 self.sizeChoice.SetSelection(idx) (top, right, bot, left) = self._recallMargins() self.marginTopText.SetValue(getSafeString(top)) self.marginRightText.SetValue(getSafeString(right)) self.marginBotText.SetValue(getSafeString(bot)) self.marginLeftText.SetValue(getSafeString(left)) (width, style, cssColor) = self._recallBorder() if cssColor: red = cssColor[0] green = cssColor[1] blue = cssColor[2] color = wx.Colour(red, green, blue) self.borderColorPicker.SetColour(color) self.borderWidthText.SetValue(getSafeString(width)) style = getSafeString(style).lower() idx = 0 try: idx = ZImageBorderMenuLabels.BORDER_KEYWORDS.index( style ) except: idx = 0 self.borderStyleChoice.SetSelection(idx) self._updateBorderControlsState() align = getSafeString(self._recallAlignment()) idx = 0 try: idx = ZImageAlignMenuLabels.ALIGN_KEYWORDS.index( align.lower() ) except: idx = 0 self.alignChoice.SetSelection(idx) # end _populateNonHeaderWidgets() def _recallThumbnailSize(self): return self.model.size # end _recallThumbnailSize() def _recallMargins(self): return (self.model.marginTop, self.model.marginRight, self.model.marginBottom, self.model.marginLeft) # end _recallMargins() def _recallBorder(self): return (self.model.borderWidth, self.model.borderStyle, self.model.borderColor) # end _recallBorder() def _recallAlignment(self): return self.model.alignment # end _recallAlignment() def _layoutNonHeaderWidgets(self): # Border borderGridSizer = wx.FlexGridSizer(3, 2, 2, 2) borderGridSizer.Add(self.borderStyleLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) borderGridSizer.Add(self.borderStyleChoice, 1, wx.EXPAND | wx.ALL, 1) borderGridSizer.Add(self.borderWidthLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) borderGridSizer.Add(self.borderWidthText, 1, wx.EXPAND | wx.ALL, 1) borderGridSizer.Add(self.borderColorLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) borderGridSizer.Add(self.borderColorPicker, 0,wx.ALL, 1) # Margins marginGridSizer = wx.FlexGridSizer(4, 4, 2, 2) marginGridSizer.AddGrowableCol(1) marginGridSizer.AddGrowableCol(3) marginGridSizer.Add(self.marginTopLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) marginGridSizer.Add(self.marginTopText, 1, wx.EXPAND | wx.ALL, 1) marginGridSizer.Add(self.marginLeftLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) marginGridSizer.Add(self.marginLeftText, 1, wx.EXPAND | wx.ALL, 1) marginGridSizer.Add(self.marginBotLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) marginGridSizer.Add(self.marginBotText, 1, wx.EXPAND | wx.ALL, 1) marginGridSizer.Add(self.marginRightLabel, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1) marginGridSizer.Add(self.marginRightText, 1, wx.EXPAND | wx.ALL, 1) borderSizer = wx.StaticBoxSizer(self.borderStaticBox, wx.VERTICAL) borderSizer.AddSizer(borderGridSizer, 1, wx.EXPAND | wx.ALL, 2) marginSizer = wx.StaticBoxSizer(self.marginStaticBox, wx.VERTICAL) marginSizer.AddSizer(marginGridSizer, 1, wx.EXPAND | wx.ALL, 2) sizeSizer = wx.BoxSizer(wx.HORIZONTAL) sizeSizer.Add(self.sizeLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) sizeSizer.Add(self.sizeChoice, 0, wx.ALL, 2) alignSizer = wx.BoxSizer(wx.HORIZONTAL) alignSizer.Add(self.alignLabel, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2) alignSizer.Add(self.alignChoice, 0, wx.ALL, 2) sizeAndBorderSizer = wx.BoxSizer(wx.VERTICAL) sizeAndBorderSizer.AddSizer(sizeSizer, 0, wx.EXPAND | wx.ALL, 1) sizeAndBorderSizer.AddSizer(borderSizer, 1, wx.EXPAND | wx.ALL, 1) alignAndMarginSizer = wx.BoxSizer(wx.VERTICAL) alignAndMarginSizer.AddSizer(alignSizer, 0, wx.EXPAND | wx.ALL, 1) alignAndMarginSizer.AddSizer(marginSizer, 1, wx.EXPAND | wx.ALL, 1) twoColumnSizer = wx.BoxSizer(wx.HORIZONTAL) twoColumnSizer.AddSizer(sizeAndBorderSizer, 2, wx.EXPAND | wx.ALL, 1) twoColumnSizer.AddSizer(alignAndMarginSizer, 3, wx.EXPAND | wx.ALL, 1) tnSettingsSizer = wx.StaticBoxSizer(self.tnSettingsGroupBox, wx.VERTICAL) tnSettingsSizer.AddSizer(twoColumnSizer, 0, wx.EXPAND | wx.ALL, 2) mainSizer = wx.BoxSizer(wx.VERTICAL) mainSizer.Add(self.doNotGenRadioButton, 0, wx.ALL, 3) mainSizer.Add(self.genRadioButton, 0, wx.ALL, 3) mainSizer.AddSizer(tnSettingsSizer, 1, wx.EXPAND | wx.ALL, 3) return mainSizer # end _layoutNonHeaderWidgets() def _bindWidgetEvents(self): self.Bind(wx.EVT_CHOICE, self.onBorderStyleChanged, self.borderStyleChoice) self.Bind(wx.EVT_RADIOBUTTON, self.onDoNotGenButton, self.doNotGenRadioButton) self.Bind(wx.EVT_RADIOBUTTON, self.onGenerateButton, self.genRadioButton) self._bindValidatingWidget(self.borderWidthText) self._bindValidatingWidget(self.marginTopText) self._bindValidatingWidget(self.marginRightText) self._bindValidatingWidget(self.marginBotText) self._bindValidatingWidget(self.marginLeftText) self.Bind(wx.EVT_BUTTON, self.onOK, self.FindWindowById(wx.ID_OK)) # end _bindWidgetEvents() def _enableWidgets(self, enabled = True): self.tnSettingsGroupBox.Enable(enabled) self.sizeLabel.Enable(enabled) self.sizeChoice.Enable(enabled) self.alignLabel.Enable(enabled) self.alignChoice.Enable(enabled) self.borderStaticBox.Enable(enabled) self.borderStyleLabel.Enable(enabled) self.borderStyleChoice.Enable(enabled) self.borderWidthLabel.Enable(enabled) self.borderWidthText.Enable(enabled) self.borderColorLabel.Enable(enabled) self.borderColorPicker.Enable(enabled) self.marginStaticBox.Enable(enabled) self.marginTopLabel.Enable(enabled) self.marginTopText.Enable(enabled) self.marginLeftLabel.Enable(enabled) self.marginLeftText.Enable(enabled) self.marginBotLabel.Enable(enabled) self.marginBotText.Enable(enabled) self.marginRightLabel.Enable(enabled) self.marginRightText.Enable(enabled) # end _enableWidgets() def _updateModel(self): self.model.generateTNFlag = self.genRadioButton.GetValue() # TN Size idx = self.sizeChoice.GetSelection() if idx >=0 and idx < len(ZThumbnailSizeMenuLabels.SIZE_KEYWORDS): size = ZThumbnailSizeMenuLabels.SIZE_KEYWORDS[idx] self.model.size = size # Alignment idx = self.alignChoice.GetSelection() if idx >=0 and idx < len(ZImageAlignMenuLabels.ALIGN_KEYWORDS): align = ZImageAlignMenuLabels.ALIGN_KEYWORDS[idx] self.model.alignment = align # Margin t = self.marginTopText.GetValue().strip() r = self.marginRightText.GetValue().strip() b = self.marginBotText.GetValue().strip() l = self.marginLeftText.GetValue().strip() self.model.marginTop = t self.model.marginRight = r self.model.marginBottom = b self.model.marginLeft = l # Border style = ZImageBorderMenuLabels.BORDER_KEYWORDS[0] # default is None idx = self.borderStyleChoice.GetSelection() if idx >=0 and idx < len(ZImageBorderMenuLabels.BORDER_KEYWORDS): style = ZImageBorderMenuLabels.BORDER_KEYWORDS[idx] width = self.borderWidthText.GetValue().strip() color = self.borderColorPicker.GetColour() self.model.borderStyle = style self.model.borderWidth = width self.model.borderColor = (color.Red(), color.Green(), color.Blue()) # end updateModel() def onDoNotGenButton(self, event): self._enableWidgets(False) self.isValid = True self._doValid() event.Skip() # end onDoNotGenButton() def onGenerateButton(self, event): self._enableWidgets(True) self._validate() event.Skip() # end onGenerateButton() def onOK(self, event): self._updateModel() self.model._saveToPrefs() event.Skip() # end onOK() def _updateBorderControlsState(self): enable = self.borderStyleChoice.GetCurrentSelection() > 0 if enable: self.borderWidthValidator.setFlags(0) else: self.borderWidthValidator.setFlags(ZCssLengthSelectionValidator.ALLOW_EMPTY) self.borderWidthText.validate() if enable and not self.borderWidthText.GetValue(): self.borderWidthText.SetValue(u"1px") #$NON-NLS-1$ self.borderWidthText.Enable(enable) self.borderColorPicker.Enable(enable) # end _updateBorderControlsState() def onBorderStyleChanged(self, event): self._updateBorderControlsState() event.Skip() # end onBorderStyleChanged() def getModel(self): return self.model # end getModel() def _getHeaderTitle(self): return _extstr(u"imagehandlerdialog.CreateImageThumbnail") #$NON-NLS-1$ # end _getHeaderTitle() def _getHeaderMessage(self): return _extstr(u"imagehandlerdialog.CreateImageThumbnailDesc") #$NON-NLS-1$ # end _getHeaderMessage() def _getHeaderImagePath(self): return u"images/dialogs/image/header_image.png" #$NON-NLS-1$