コード例 #1
0
ファイル: header.py プロジェクト: mpm2050/Raven
    def _createHeaderPanel(self):
        panel = wx.Panel(self, wx.ID_ANY)
        panel.SetBackgroundColour(wx.WHITE)

        self.headerLink = wx.HyperlinkCtrl(panel, wx.ID_ANY,
                                           self._getHeaderTitle(),
                                           self._getHeaderHelpURL())
        self.headerLink.SetFont(getDefaultFontBold())
        self.headerMessage = wx.StaticText(panel, wx.ID_ANY,
                                           self._getHeaderMessage())
        headerImagePath = self._getHeaderImagePath()
        if not headerImagePath:
            headerImagePath = u"images/dialogs/image/header_image.png"  #$NON-NLS-1$
        self.headerIcon = ZStaticBitmap(
            panel,
            getResourceRegistry().getBitmap(headerImagePath))

        linkAndMsgSizer = wx.BoxSizer(wx.VERTICAL)
        linkAndMsgSizer.Add(self.headerLink, 0, wx.ALL, 2)
        linkAndMsgSizer.Add(self.headerMessage, 1, wx.EXPAND | wx.ALL, 2)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddSizer(linkAndMsgSizer, 1, wx.EXPAND | wx.ALL, 5)
        sizer.Add(self.headerIcon, 0, wx.EXPAND | wx.ALL, 10)

        panel.SetAutoLayout(True)
        panel.SetSizer(sizer)

        return panel
コード例 #2
0
ファイル: translationeditor.py プロジェクト: mpm2050/Raven
    def _createNonHeaderWidgets(self):
        self.showOnlyCB = wx.CheckBox(
            self, wx.ID_ANY,
            _extstr(u"translationeditor.ShowOnlyUntranslated"))  #$NON-NLS-1$
        self.listProvider = ZStringBundleProvider(self.model)
        self.listBox = ZListViewEx(self.listProvider, self, wx.ID_ANY)
        bitmap = getFlagBitmapForLocale(u"en_US")  #$NON-NLS-1$
        self.englishFlag = ZStaticBitmap(self, bitmap)
        self.englishLabel = wx.StaticText(
            self, wx.ID_ANY,
            _extstr(u"translationeditor.EnglishValue"))  #$NON-NLS-1$
        bitmap = getFlagBitmapForLocale(
            self.model.getTranslation().getLocale().toString())
        if bitmap is None:
            bitmap = getEmptyFlagBitmap()
        self.translationFlag = ZStaticBitmap(self, bitmap)
        self.translationLabel = wx.StaticText(self, wx.ID_ANY,
                                              self.translationDisplayName)
        self.englishText = wx.TextCtrl(self,
                                       wx.ID_ANY,
                                       style=wx.TE_MULTILINE | wx.TE_READONLY
                                       | wx.TE_BESTWRAP)
        self.translationText = wx.TextCtrl(
            self,
            wx.ID_ANY,
            style=wx.TE_MULTILINE | wx.TE_BESTWRAP | wx.TE_PROCESS_ENTER)

        self.translationText.Enable(False)

        self.staticLine = wx.StaticLine(self, wx.HORIZONTAL)
コード例 #3
0
ファイル: flickrprovider.py プロジェクト: mpm2050/Raven
    def _createWidgets(self):
        self.descriptionLabel = wx.StaticText(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.FlickrAuthDescription"))  #$NON-NLS-1$
        self.stepOneLabel = wx.StaticText(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.BeginAuthLabel"))  #$NON-NLS-1$
        self.stepOneButton = wx.Button(
            self, wx.ID_ANY, _extstr(u"flickrprovider.Begin"))  #$NON-NLS-1$
        self.stepTwoLabel = wx.StaticText(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.ClickHereLabel"))  #$NON-NLS-1$
        self.stepTwoButton = wx.Button(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.Authorized"))  #$NON-NLS-1$

        self.resultLabel = wx.StaticText(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.NotYetAuthorized"))  #$NON-NLS-1$
        self.completeBitmap = getResourceRegistry().getBitmap(
            u"images/common/check.png")  #$NON-NLS-1$
        self.completeImage = ZStaticBitmap(self, self.completeBitmap)
        self.warningBitmap = getResourceRegistry().getBitmap(
            u"images/common/warning.png")  #$NON-NLS-1$
        self.warningImage = ZStaticBitmap(self, self.warningBitmap)
コード例 #4
0
 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
コード例 #5
0
ファイル: wizard.py プロジェクト: Tidosho/zoundryraven
 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
コード例 #6
0
ファイル: textbox.py プロジェクト: mpm2050/Raven
 def _createWidgets(self):
     self.textBox = wx.TextCtrl(self,
                                wx.ID_ANY,
                                style=wx.NO_BORDER | wx.TE_PROCESS_ENTER)
     hasChoices = len(self.choices) > 1
     self.bitmapButton = ZImageButton(self, self.bitmap, hasChoices, None,
                                      hasChoices)
     self.staticBitmap = ZStaticBitmap(self, self.bitmap)
     self.clearButton = self._createClearButton()
     self._createChoiceMenu()
コード例 #7
0
ファイル: aboutdialog.py プロジェクト: mpm2050/Raven
    def _createRavenInfoPage(self):
        self.infoPanel = wx.Panel(self.notebook, wx.ID_ANY)
        self.infoPanel.SetBackgroundColour(wx.WHITE)

        self.aboutBmp = getResourceRegistry().getBitmap(
            u"images/about/about.png")  #$NON-NLS-1$
        self.aboutImage = ZStaticBitmap(self.infoPanel, self.aboutBmp)

        ver = version.ZVersion()
        verDate = ZSchemaDateTime(ver.getBuildDate())

        self.versionLabelLabel = wx.StaticText(
            self.infoPanel, wx.ID_ANY,
            u"%s: " % _extstr(u"splash.Version"))  #$NON-NLS-1$ #$NON-NLS-2$
        self.versionLabelLabel.SetFont(getDefaultFontBold())
        self.versionLabel = wx.StaticText(self.infoPanel, wx.ID_ANY,
                                          ver.getFullVersionString())
        self.dateLabelLabel = wx.StaticText(
            self.infoPanel, wx.ID_ANY,
            u"%s: " % _extstr(u"splash.BuiltOn"))  #$NON-NLS-1$ #$NON-NLS-2$
        self.dateLabelLabel.SetFont(getDefaultFontBold())
        self.dateLabel = wx.StaticText(self.infoPanel, wx.ID_ANY,
                                       verDate.toString(localTime=True))

        return self.infoPanel
コード例 #8
0
ファイル: splash.py プロジェクト: mpm2050/Raven
    def _createSplashPanel(self, parent):
        ver = version.ZVersion()
        verDate = ZSchemaDateTime(ver.getBuildDate())

        panel = wx.Panel(parent, wx.ID_ANY)
        panel.SetBackgroundColour(wx.WHITE)
        splashFilename = u"splash.png"  #$NON-NLS-1$
        if isPortableEnabled():
            splashFilename = u"splash_portable.png"  #$NON-NLS-1$
        bitmap = getResourceRegistry().getBitmap(u"images/splash/%s" %
                                                 splashFilename)  #$NON-NLS-1$
        splashImage = ZStaticBitmap(panel, bitmap)

        versionLabelLabel = wx.StaticText(
            panel, wx.ID_ANY,
            u"%s: " % _extstr(u"splash.Version"))  #$NON-NLS-1$ #$NON-NLS-2$
        versionLabelLabel.SetFont(getDefaultFontBold())
        versionLabel = wx.StaticText(panel, wx.ID_ANY,
                                     ver.getFullVersionString())
        dateLabelLabel = wx.StaticText(
            panel, wx.ID_ANY,
            u"%s: " % _extstr(u"splash.BuiltOn"))  #$NON-NLS-1$ #$NON-NLS-2$
        dateLabelLabel.SetFont(getDefaultFontBold())
        dateLabel = wx.StaticText(panel, wx.ID_ANY,
                                  verDate.toString(localTime=True))

        verAndDateSizer = wx.BoxSizer(wx.HORIZONTAL)
        verAndDateSizer.Add(versionLabelLabel, 0, wx.EXPAND | wx.RIGHT, 2)
        verAndDateSizer.Add(versionLabel, 0, wx.EXPAND | wx.RIGHT, 10)
        verAndDateSizer.Add(dateLabelLabel, 0, wx.EXPAND | wx.RIGHT, 2)
        verAndDateSizer.Add(dateLabel, 0, wx.EXPAND)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splashImage, 0, wx.EXPAND)
        sizer.AddSizer(verAndDateSizer, 0, wx.EXPAND | wx.ALL, 5)

        panel.SetSizer(sizer)
        panel.SetAutoLayout(True)

        return panel
コード例 #9
0
ファイル: header.py プロジェクト: Tidosho/zoundryraven
    def _createHeaderPanel(self):
        panel = wx.Panel(self, wx.ID_ANY)
        panel.SetBackgroundColour(wx.WHITE)

        self.headerLink = wx.HyperlinkCtrl(panel, wx.ID_ANY, self._getHeaderTitle(), self._getHeaderHelpURL())
        self.headerLink.SetFont(getDefaultFontBold())
        self.headerMessage = wx.StaticText(panel, wx.ID_ANY, self._getHeaderMessage())
        headerImagePath = self._getHeaderImagePath()
        if not headerImagePath:
            headerImagePath = u"images/dialogs/image/header_image.png"  # $NON-NLS-1$
        self.headerIcon = ZStaticBitmap(panel, getResourceRegistry().getBitmap(headerImagePath))

        linkAndMsgSizer = wx.BoxSizer(wx.VERTICAL)
        linkAndMsgSizer.Add(self.headerLink, 0, wx.ALL, 2)
        linkAndMsgSizer.Add(self.headerMessage, 1, wx.EXPAND | wx.ALL, 2)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddSizer(linkAndMsgSizer, 1, wx.EXPAND | wx.ALL, 5)
        sizer.Add(self.headerIcon, 0, wx.EXPAND | wx.ALL, 10)

        panel.SetAutoLayout(True)
        panel.SetSizer(sizer)

        return panel
コード例 #10
0
ファイル: textbox.py プロジェクト: mpm2050/Raven
class ZAdvancedTextBox(wx.Panel):
    def __init__(self, parent, bitmap, choices, multiSelect=False):
        self.bitmap = bitmap
        self.choices = choices
        self.selectedChoices = []
        self.multiSelect = multiSelect
        self.backgroundColor = getDefaultControlBackgroundColor()
        self.borderColor = getDefaultControlBorderColor()

        wx.Panel.__init__(self, parent, wx.ID_ANY, style=wx.NO_BORDER)

        self.SetBackgroundColour(self.backgroundColor)

        self._createWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()

    # end __init__()

    def GetValue(self):
        return self.textBox.GetValue()

    # end GetValue()

    def SetValue(self, value):
        self.textBox.SetValue(value)

    # end SetValue()

    def SetToolTipString(self, tooltip):
        self.textBox.SetToolTipString(tooltip)

    # end SetToolTipString()

    def setCurrentChoice(self, choiceId):
        self.selectedChoices = [choiceId]

    # end setCurrentChoice()

    def setCurrentChoices(self, choiceIds):
        self.selectedChoices = choiceIds

    # end setCurrentChoices()

    def getCurrentChoice(self):
        if self.multiSelect:
            raise ZAppFrameworkException(
                u"Attempted to get a single choice from an advanced text box configured for multiple selection."
            )  #$NON-NLS-1$
        if self.selectedChoices:
            return self.selectedChoices[0]
        return None

    # end getCurrentChoice()

    def getCurrentChoices(self):
        if not self.multiSelect:
            raise ZAppFrameworkException(
                u"Attempted to get multiple choices from an advanced text box configured for single selection."
            )  #$NON-NLS-1$
        return self.selectedChoices

    # end getCurrentChoice()

    def _createWidgets(self):
        self.textBox = wx.TextCtrl(self,
                                   wx.ID_ANY,
                                   style=wx.NO_BORDER | wx.TE_PROCESS_ENTER)
        hasChoices = len(self.choices) > 1
        self.bitmapButton = ZImageButton(self, self.bitmap, hasChoices, None,
                                         hasChoices)
        self.staticBitmap = ZStaticBitmap(self, self.bitmap)
        self.clearButton = self._createClearButton()
        self._createChoiceMenu()

    # end _createWidgets()

    def _createChoiceMenu(self):
        menuModel = self._createChoiceMenuModel()
        menuContext = ZMenuActionContext(self)
        contentProvider = ZModelBasedMenuContentProvider(
            menuModel, menuContext)
        eventHandler = ZModelBasedMenuEventHandler(menuModel, menuContext)
        self.menu = ZMenu(self, menuModel.getRootNode(), contentProvider,
                          eventHandler)

    # end _createChoiceMenu()

    def _createChoiceMenuModel(self):
        model = ZMenuModel()
        for (label, bitmap, id) in self.choices:
            action = ZTextBoxChoiceAction(id)
            menuId = model.addMenuItemWithAction(label, 0, action)
            model.setMenuItemCheckbox(menuId, True)
            model.setMenuItemBitmap(menuId, bitmap)
        return model

    # end _createChoiceMenuModel()

    def _createClearButton(self):
        registry = getResourceRegistry()
        clearBmp = registry.getBitmap(
            u"images/widgets/textbox/clear.png")  #$NON-NLS-1$
        clearHoverBmp = registry.getBitmap(
            u"images/widgets/textbox/clear-hover.png")  #$NON-NLS-1$
        return ZImageButton(self, clearBmp, False, clearHoverBmp, False)

    # end _createClearButton()

    def _layoutWidgets(self):
        (w, h) = getTextDimensions(u"Zoundry",
                                   self.textBox)  #$NON-NLS-1$ @UnusedVariable
        self.textBox.SetSizeHints(-1, h + 2)

        box = wx.BoxSizer(wx.HORIZONTAL)
        box.Add(self.staticBitmap, 0, wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT, 3)
        box.Add(self.bitmapButton, 0, wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT, 3)
        box.Add((3, -1))
        box.Add(self.textBox, 1, wx.EXPAND | wx.TOP, 3)
        box.Add(self.clearButton, 0, wx.ALIGN_CENTER | wx.RIGHT | wx.LEFT, 3)

        self.clearButton.Show(False)
        if self.choices is None or len(self.choices) == 0:
            self.staticBitmap.Show(True)
            self.bitmapButton.Show(False)
        else:
            self.staticBitmap.Show(False)
            self.bitmapButton.Show(True)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.AddSizer(box, 1, wx.EXPAND | wx.ALL, 2)
        self.SetAutoLayout(True)
        self.SetSizer(sizer)
        self.Layout()

    # end _layoutWidgets()

    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_PAINT, self.onPaint, self)
        self.Bind(wx.EVT_ERASE_BACKGROUND, self.onEraseBackground, self)
        self.Bind(wx.EVT_BUTTON, self.onButtonClicked, self.bitmapButton)
        self.Bind(wx.EVT_TEXT, self.onText, self.textBox)
        self.Bind(wx.EVT_TEXT_ENTER, self.onPropagateEvent, self.textBox)
        self.Bind(wx.EVT_BUTTON, self.onClearButtonClicked, self.clearButton)

    # end _bindWidgetEvents()

    def onButtonClicked(self, event):
        if len(self.choices) > 1:
            (w, h) = self.GetSizeTuple()  #@UnusedVariable
            pos = wx.Point(1, h - 2)
            self.menu.refresh()
            self.PopupMenu(self.menu, pos)
        event.Skip

    # end onButtonClicked()

    def onClearButtonClicked(self, event):
        self.SetValue(u"")  #$NON-NLS-1$
        self.clearButton.Show(False)
        txtEvent = wx.CommandEvent(wxEVT_COMMAND_TEXT_ENTER, self.GetId())
        self.GetEventHandler().AddPendingEvent(txtEvent)
        event.Skip()

    # end onClearButtonClicked()

    def onText(self, event):
        if self.clearButton.IsShown() and not self.textBox.GetValue():
            self.clearButton.Show(False)
            self.Layout()
        elif not self.clearButton.IsShown() and self.textBox.GetValue():
            self.clearButton.Show(True)
            self.Layout()
        self.onPropagateEvent(event)

    # end onText()

    def onPropagateEvent(self, event):
        # Propagate the event
        event = event.Clone()
        event.SetId(self.GetId())
        self.GetEventHandler().AddPendingEvent(event)

    # end onPropagateEvent()

    def onEraseBackground(self, event):  #@UnusedVariable
        pass

    # end onEraseBackground()

    def onPaint(self, event):
        (width, height) = self.GetSizeTuple()
        paintDC = wx.BufferedPaintDC(self)
        paintDC.SetBackground(
            wx.Brush(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DFACE),
                     wx.SOLID))
        paintDC.Clear()

        # Draw the background white
        brush = wx.Brush(self.backgroundColor)
        paintDC.SetPen(wx.Pen(self.borderColor, 1, wx.SOLID))
        paintDC.SetBrush(brush)
        paintDC.DrawRectangle(0, 0, width, height)

        del paintDC
        event.Skip()

    # end onPaint

    def onChoice(self, choiceId):
        # Update the internal selection state.
        if self.multiSelect:
            if not choiceId in self.selectedChoices:
                self.selectedChoices.append(choiceId)
        else:
            self.selectedChoices = [choiceId]

        event = ZAdvTextBoxOptionEvent(self.GetId(), choiceId)
        self.GetEventHandler().AddPendingEvent(event)

    # end onChoice()

    def onUnChoice(self, choiceId):
        if choiceId in self.selectedChoices:
            self.selectedChoices.remove(choiceId)
コード例 #11
0
ファイル: header.py プロジェクト: mpm2050/Raven
class ZHeaderDialog(ZBaseDialog):
    def __init__(self,
                 parent,
                 id,
                 title,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 name=u"ZHeaderDialog"):  #$NON-NLS-1$):
        ZBaseDialog.__init__(self, parent, id, title, pos, size, style, name)

    # end __init__()

    def _createContentWidgets(self):
        u"Creates a control for the dialog header and a static line below it."  #$NON-NLS-1$
        self.headerPanel = self._createHeaderPanel()
        self.headerStaticLine = wx.StaticLine(self)

        self._createNonHeaderWidgets()

    # end _createContentWidgets()

    def _populateContentWidgets(self):
        u"Populates the header with data."  #$NON-NLS-1$
        self._populateNonHeaderWidgets()

    # end _populateContentWidgets()

    def _layoutContentWidgets(self):
        sizer = self._layoutNonHeaderWidgets()

        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.headerPanel, 0, wx.EXPAND)
        box.Add(self.headerStaticLine, 0, wx.EXPAND)
        box.AddSizer(sizer, 1, wx.EXPAND | wx.ALL,
                     self._getNonHeaderContentBorder())

        return box

    # end _layoutContentWidgets()

    def _createHeaderPanel(self):
        panel = wx.Panel(self, wx.ID_ANY)
        panel.SetBackgroundColour(wx.WHITE)

        self.headerLink = wx.HyperlinkCtrl(panel, wx.ID_ANY,
                                           self._getHeaderTitle(),
                                           self._getHeaderHelpURL())
        self.headerLink.SetFont(getDefaultFontBold())
        self.headerMessage = wx.StaticText(panel, wx.ID_ANY,
                                           self._getHeaderMessage())
        headerImagePath = self._getHeaderImagePath()
        if not headerImagePath:
            headerImagePath = u"images/dialogs/image/header_image.png"  #$NON-NLS-1$
        self.headerIcon = ZStaticBitmap(
            panel,
            getResourceRegistry().getBitmap(headerImagePath))

        linkAndMsgSizer = wx.BoxSizer(wx.VERTICAL)
        linkAndMsgSizer.Add(self.headerLink, 0, wx.ALL, 2)
        linkAndMsgSizer.Add(self.headerMessage, 1, wx.EXPAND | wx.ALL, 2)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddSizer(linkAndMsgSizer, 1, wx.EXPAND | wx.ALL, 5)
        sizer.Add(self.headerIcon, 0, wx.EXPAND | wx.ALL, 10)

        panel.SetAutoLayout(True)
        panel.SetSizer(sizer)

        return panel

    # end _createHeaderPanel()

    def _updateHeader(self):
        self.headerLink.SetLabel(self._getHeaderTitle())
        self.headerLink.SetURL(self._getHeaderHelpURL())
        self.headerMessage.SetLabel(self._getHeaderMessage())
        self.headerIcon.setBitmap(getResourceRegistry().getBitmap(
            self._getHeaderImagePath()))
        self.headerPanel.Layout()
        self.headerPanel.Refresh()

    # end _updateHeader()

    def _getNonHeaderContentBorder(self):
        return 5

    # end _getNonHeaderContentBorder()

    def _createNonHeaderWidgets(self):
        u"Called to create the non header related widgets.  (abstract)"  #$NON-NLS-1$
        raise ZAbstractMethodCalledException(
            self.__class__, u"_createNonHeaderWidgets")  #$NON-NLS-1$

    # end _createNonHeaderWidgets()

    def _populateNonHeaderWidgets(self):
        u"Called to populate the non header related widgets."  #$NON-NLS-1$

    # end _populateNonHeaderWidgets()

    def _layoutNonHeaderWidgets(self):
        u"Called to layout the non header related widgets.  Should return a sizer.  (abstract)"  #$NON-NLS-1$
        raise ZAbstractMethodCalledException(
            self.__class__, u"_layoutNonHeaderWidgets")  #$NON-NLS-1$

    # end _layoutNonHeaderWidgets()

    def _getHeaderTitle(self):
        u"Returns the header title. (abstract)"  #$NON-NLS-1$
        raise ZAbstractMethodCalledException(self.__class__,
                                             u"_getHeaderTitle")  #$NON-NLS-1$

    # end _getHeaderTitle()

    def _getHeaderMessage(self):
        u"Returns the header message. (abstract)"  #$NON-NLS-1$
        raise ZAbstractMethodCalledException(
            self.__class__, u"_getHeaderMessage")  #$NON-NLS-1$

    # end _getHeaderMessage()

    def _getHeaderImagePath(self):
        u"Returns the path to an image that will be shown in the header. (abstract)"  #$NON-NLS-1$
        raise ZAbstractMethodCalledException(
            self.__class__, u"_getHeaderImagePath")  #$NON-NLS-1$

    # end _getHeaderImagePath()

    def _getHeaderHelpURL(self):
        u"Returns a http URL to the specific Online User Guide section for this dialog."  #$NON-NLS-1$
        # FIXME (EPW) Create a context-sensitive Online Help URL here.
        return u"http://www.zoundry.com"  #$NON-NLS-1$
コード例 #12
0
ファイル: header.py プロジェクト: Tidosho/zoundryraven
class ZHeaderDialog(ZBaseDialog):
    def __init__(
        self,
        parent,
        id,
        title,
        pos=wx.DefaultPosition,
        size=wx.DefaultSize,
        style=wx.DEFAULT_DIALOG_STYLE,
        name=u"ZHeaderDialog",
    ):  # $NON-NLS-1$):
        ZBaseDialog.__init__(self, parent, id, title, pos, size, style, name)

    # end __init__()

    def _createContentWidgets(self):
        u"Creates a control for the dialog header and a static line below it."  # $NON-NLS-1$
        self.headerPanel = self._createHeaderPanel()
        self.headerStaticLine = wx.StaticLine(self)

        self._createNonHeaderWidgets()

    # end _createContentWidgets()

    def _populateContentWidgets(self):
        u"Populates the header with data."  # $NON-NLS-1$
        self._populateNonHeaderWidgets()

    # end _populateContentWidgets()

    def _layoutContentWidgets(self):
        sizer = self._layoutNonHeaderWidgets()

        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.headerPanel, 0, wx.EXPAND)
        box.Add(self.headerStaticLine, 0, wx.EXPAND)
        box.AddSizer(sizer, 1, wx.EXPAND | wx.ALL, self._getNonHeaderContentBorder())

        return box

    # end _layoutContentWidgets()

    def _createHeaderPanel(self):
        panel = wx.Panel(self, wx.ID_ANY)
        panel.SetBackgroundColour(wx.WHITE)

        self.headerLink = wx.HyperlinkCtrl(panel, wx.ID_ANY, self._getHeaderTitle(), self._getHeaderHelpURL())
        self.headerLink.SetFont(getDefaultFontBold())
        self.headerMessage = wx.StaticText(panel, wx.ID_ANY, self._getHeaderMessage())
        headerImagePath = self._getHeaderImagePath()
        if not headerImagePath:
            headerImagePath = u"images/dialogs/image/header_image.png"  # $NON-NLS-1$
        self.headerIcon = ZStaticBitmap(panel, getResourceRegistry().getBitmap(headerImagePath))

        linkAndMsgSizer = wx.BoxSizer(wx.VERTICAL)
        linkAndMsgSizer.Add(self.headerLink, 0, wx.ALL, 2)
        linkAndMsgSizer.Add(self.headerMessage, 1, wx.EXPAND | wx.ALL, 2)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.AddSizer(linkAndMsgSizer, 1, wx.EXPAND | wx.ALL, 5)
        sizer.Add(self.headerIcon, 0, wx.EXPAND | wx.ALL, 10)

        panel.SetAutoLayout(True)
        panel.SetSizer(sizer)

        return panel

    # end _createHeaderPanel()

    def _updateHeader(self):
        self.headerLink.SetLabel(self._getHeaderTitle())
        self.headerLink.SetURL(self._getHeaderHelpURL())
        self.headerMessage.SetLabel(self._getHeaderMessage())
        self.headerIcon.setBitmap(getResourceRegistry().getBitmap(self._getHeaderImagePath()))
        self.headerPanel.Layout()
        self.headerPanel.Refresh()

    # end _updateHeader()

    def _getNonHeaderContentBorder(self):
        return 5

    # end _getNonHeaderContentBorder()

    def _createNonHeaderWidgets(self):
        u"Called to create the non header related widgets.  (abstract)"  # $NON-NLS-1$
        raise ZAbstractMethodCalledException(self.__class__, u"_createNonHeaderWidgets")  # $NON-NLS-1$

    # end _createNonHeaderWidgets()

    def _populateNonHeaderWidgets(self):
        u"Called to populate the non header related widgets."  # $NON-NLS-1$

    # end _populateNonHeaderWidgets()

    def _layoutNonHeaderWidgets(self):
        u"Called to layout the non header related widgets.  Should return a sizer.  (abstract)"  # $NON-NLS-1$
        raise ZAbstractMethodCalledException(self.__class__, u"_layoutNonHeaderWidgets")  # $NON-NLS-1$

    # end _layoutNonHeaderWidgets()

    def _getHeaderTitle(self):
        u"Returns the header title. (abstract)"  # $NON-NLS-1$
        raise ZAbstractMethodCalledException(self.__class__, u"_getHeaderTitle")  # $NON-NLS-1$

    # end _getHeaderTitle()

    def _getHeaderMessage(self):
        u"Returns the header message. (abstract)"  # $NON-NLS-1$
        raise ZAbstractMethodCalledException(self.__class__, u"_getHeaderMessage")  # $NON-NLS-1$

    # end _getHeaderMessage()

    def _getHeaderImagePath(self):
        u"Returns the path to an image that will be shown in the header. (abstract)"  # $NON-NLS-1$
        raise ZAbstractMethodCalledException(self.__class__, u"_getHeaderImagePath")  # $NON-NLS-1$

    # end _getHeaderImagePath()

    def _getHeaderHelpURL(self):
        u"Returns a http URL to the specific Online User Guide section for this dialog."  # $NON-NLS-1$
        # FIXME (EPW) Create a context-sensitive Online Help URL here.
        return u"http://www.zoundry.com"  # $NON-NLS-1$
コード例 #13
0
ファイル: flickrprovider.py プロジェクト: mpm2050/Raven
class ZFlickrAuthorizationWizardPage(ZNewMediaStorageWizardPage):
    def __init__(self, model, parent):
        ZNewMediaStorageWizardPage.__init__(self, model, parent)
        self.flickr = flickrapi.FlickrAPI(FLICKR_API_KEY, SECRET)
        self.frob = None
        self.token = None
        self.authorized = False

    # end __init__()

    def _createWidgets(self):
        self.descriptionLabel = wx.StaticText(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.FlickrAuthDescription"))  #$NON-NLS-1$
        self.stepOneLabel = wx.StaticText(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.BeginAuthLabel"))  #$NON-NLS-1$
        self.stepOneButton = wx.Button(
            self, wx.ID_ANY, _extstr(u"flickrprovider.Begin"))  #$NON-NLS-1$
        self.stepTwoLabel = wx.StaticText(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.ClickHereLabel"))  #$NON-NLS-1$
        self.stepTwoButton = wx.Button(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.Authorized"))  #$NON-NLS-1$

        self.resultLabel = wx.StaticText(
            self, wx.ID_ANY,
            _extstr(u"flickrprovider.NotYetAuthorized"))  #$NON-NLS-1$
        self.completeBitmap = getResourceRegistry().getBitmap(
            u"images/common/check.png")  #$NON-NLS-1$
        self.completeImage = ZStaticBitmap(self, self.completeBitmap)
        self.warningBitmap = getResourceRegistry().getBitmap(
            u"images/common/warning.png")  #$NON-NLS-1$
        self.warningImage = ZStaticBitmap(self, self.warningBitmap)

    # end _createWidgets()

    def _populateWidgets(self):
        self.stepOneButton.Enable(True)
        self.stepTwoButton.Enable(False)
        self.warningImage.Show(True)
        self.completeImage.Show(False)
        self._fireInvalidEvent()

    # end _populateWidgets()

    def _bindWidgetEvents(self):
        self.Bind(wx.EVT_BUTTON, self.onStepOneButton, self.stepOneButton)
        self.Bind(wx.EVT_BUTTON, self.onStepTwoButton, self.stepTwoButton)

    # end _bindWidgetEvents()

    def _layoutWidgets(self):
        flexGridSizer = wx.FlexGridSizer(2, 2, 5, 5)
        flexGridSizer.AddGrowableCol(1)
        flexGridSizer.Add(self.stepOneLabel, 0,
                          wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
                          5)
        flexGridSizer.Add(self.stepOneButton, 0, wx.EXPAND | wx.RIGHT, 5)
        flexGridSizer.Add(self.stepTwoLabel, 0,
                          wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
                          5)
        flexGridSizer.Add(self.stepTwoButton, 0, wx.EXPAND | wx.RIGHT, 5)

        resultSizer = wx.BoxSizer(wx.HORIZONTAL)
        resultSizer.Add(self.warningImage, 0, wx.EXPAND | wx.ALL, 2)
        resultSizer.Add(self.completeImage, 0, wx.EXPAND | wx.ALL, 2)
        resultSizer.Add(self.resultLabel, 1, wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                        2)

        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(self.descriptionLabel, 1, wx.EXPAND | wx.ALL, 10)
        box.AddSizer(flexGridSizer, 1, wx.EXPAND | wx.ALL, 5)
        box.AddSizer(resultSizer, 0, wx.EXPAND | wx.ALL, 10)
        self.SetAutoLayout(True)
        self.SetSizer(box)

    # end _layoutWidgets()

    def onStepOneButton(self, event):
        bc = wx.BusyCursor()
        try:
            flickr = flickrapi.FlickrAPI(FLICKR_API_KEY, SECRET)
            (token,
             frob) = flickr.get_token_part_one(perms=u"delete")  #$NON-NLS-1$
            self.token = token
            self.frob = frob
            if token:
                self._onAuthorized()
            else:
                self.stepOneButton.Enable(False)
                self.stepTwoButton.Enable(True)
        finally:
            del bc
        event.Skip()

    # end onStepOneButton()

    def onStepTwoButton(self, event):
        token = None
        try:
            token = self.flickr.get_token_part_two((None, self.frob))
        except:
            pass
        if token:
            self.token = token
            self._onAuthorized()
        else:
            self.resultLabel.SetLabel(
                _extstr(u"flickrprovider.StillNotAuthorized"))  #$NON-NLS-1$
            self._populateWidgets()
        event.Skip()

    # end onStepTwoButton()

    def onEnter(self, session, eventDirection):  #@UnusedVariable
        self.paramsPageProps = session.getProperty(
            u"params-page.properties")  #$NON-NLS-1$
        if not self.authorized:
            self._fireInvalidEvent()

    # end onEnter()

    def onExit(self, session, eventDirection):  #@UnusedVariable
        if eventDirection == ZWizardPage.NEXT:
            params = session.getProperty(
                u"params-page.properties")  #$NON-NLS-1$
            params[u"token"] = self.token  #$NON-NLS-1$
        return True

    # end onExit()

    def _onAuthorized(self):
        self.resultLabel.SetLabel(
            _extstr(u"flickrprovider.RavenIsAuthorized"))  #$NON-NLS-1$
        self.warningImage.Show(False)
        self.completeImage.Show(True)
        self.Layout()
        self.stepOneButton.Enable(False)
        self.stepTwoButton.Enable(False)
        self._fireValidEvent()

    # end _onAuthorized()

    def getDataProperties(self):
        rval = {}
        if self.token:
            self.paramsPageProps[u"token"] = self.token  #$NON-NLS-1$
            rval[
                u"params-page.properties"] = self.paramsPageProps  #$NON-NLS-1$
        return rval
コード例 #14
0
ファイル: infodetailswidgets.py プロジェクト: mpm2050/Raven
    def _createWidgets(self):
        self.staticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"infodetailswidgets.Preview")) #$NON-NLS-1$

        self.generatingMsg = ZProgressLabelCtrl(self, _extstr(u"infodetailswidgets.GeneratingPreview")) #$NON-NLS-1$
        self.previewUnavailableMsg = wx.StaticText(self, wx.ID_ANY, _extstr(u"infodetailswidgets.PreviewUnavailable")) #$NON-NLS-1$
        self.previewBmp = ZStaticBitmap(self, None)
コード例 #15
0
ファイル: infodetailswidgets.py プロジェクト: mpm2050/Raven
class ZImagePreviewPanel(ZTransparentPanel):

    def __init__(self, parent):
        wx.Panel.__init__(self, parent, wx.ID_ANY)

        self._createWidgets()
        self._layoutWidgets()
    # end __init__()

    def _createWidgets(self):
        self.staticBox = wx.StaticBox(self, wx.ID_ANY, _extstr(u"infodetailswidgets.Preview")) #$NON-NLS-1$

        self.generatingMsg = ZProgressLabelCtrl(self, _extstr(u"infodetailswidgets.GeneratingPreview")) #$NON-NLS-1$
        self.previewUnavailableMsg = wx.StaticText(self, wx.ID_ANY, _extstr(u"infodetailswidgets.PreviewUnavailable")) #$NON-NLS-1$
        self.previewBmp = ZStaticBitmap(self, None)
    # end _createWidgets()

    def _layoutWidgets(self):
        staticBoxSizer = wx.StaticBoxSizer(self.staticBox, wx.HORIZONTAL)
        staticBoxSizer.Add(self.generatingMsg, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3)
        staticBoxSizer.Add(self.previewUnavailableMsg, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3)
        staticBoxSizer.Add(self.previewBmp, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3)

        self.SetAutoLayout(True)
        self.SetSizer(staticBoxSizer)
    # end _layoutWidgets()

    def reset(self):
        self.generatingMsg.Show(True)
        self.generatingMsg.start()
        self.previewUnavailableMsg.Show(False)
        self.previewBmp.Show(False)
    # end reset()

    def updateFromError(self, error):
        # Log the error
        getLoggerService().exception(error)
        self.generatingMsg.Show(False)
        self.generatingMsg.stop()
        self.previewUnavailableMsg.Show(True)
        self.previewBmp.Show(False)
    # end updateFromError()

    def updateFromConnectionRespInfo(self, connectionRespInfo): #@UnusedVariable
        # Do nothing...
        pass
    # end updateFromConnectionRespInfo()

    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)