Пример #1
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.SetMinSize([self.default_width, self.default_height])
     self.SetCaption('Encounter Debug Window')
     self.sr.content.padding = 5
     self.encounterSpawnServer = sm.RemoteSvc('encounterSpawnServer')
     debugContainer = Container(parent=self.sr.content)
     Button(parent=debugContainer,
            align=uiconst.TOBOTTOM,
            label='Start Encounter',
            func=self._StartSelectedEncounter,
            padding=(0, 3, 0, 0))
     Button(parent=debugContainer,
            align=uiconst.TOBOTTOM,
            label='Stop Encounter',
            func=self._StopSelectedEncounter,
            padding=(0, 5, 0, 0))
     Button(parent=debugContainer,
            align=uiconst.TOBOTTOM,
            label='Clear Results',
            func=self._ClearResults,
            padding=(0, 5, 0, 0))
     self.results = Edit(parent=debugContainer,
                         align=uiconst.TOBOTTOM,
                         padding=(0, 5, 0, 0),
                         readonly=True,
                         name='results')
     self.encounterScroll = Scroll(parent=debugContainer,
                                   name='encounterScroll',
                                   align=uiconst.TOALL)
     self.encounterScroll.LoadContent(
         contentList=self._GetAvailableEncounters())
Пример #2
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     self.SetCaption(
         localization.GetByLabel(
             'UI/Browser/BrowserHistory/BrowserHistoryCaption'))
     self.SetMinSize((400, 256))
     mainArea = self.GetMainArea()
     mainArea.clipChildren = 0
     mainArea.padding = 6
     clearHistory = Button(parent=mainArea,
                           label=localization.GetByLabel(
                               'UI/Browser/BrowserHistory/ClearHistory'),
                           func=self.ClearHistory,
                           align=uiconst.BOTTOMRIGHT)
     self.scroll = Scroll(parent=mainArea,
                          padBottom=clearHistory.height + 6)
     self.LoadHistory()
Пример #3
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     name = attributes.bookmarkName
     url = attributes.url
     self.SetCaption(localization.GetByLabel('UI/Browser/EditBookmarks/Caption'))
     self.SetButtons(uiconst.OKCLOSE, okLabel=localization.GetByLabel('UI/Browser/EditBookmarks/Remove', selectedItems=0), okFunc=self.Remove, okModalResult=uiconst.ID_NONE)
     self.SetMinSize((256, 256))
     main = self.GetMainArea()
     main.clipChildren = 0
     Container(name='errorParent', parent=main, align=uiconst.TOBOTTOM, height=16, state=uiconst.UI_HIDDEN)
     toppar = Container(name='toppar', align=uiconst.TOTOP, height=66, parent=main, idx=0, padding=(const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding))
     c = Container(name='namecont', parent=toppar, align=uiconst.TOTOP, height=20, padBottom=5)
     label = Label(text=localization.GetByLabel('UI/Browser/EditBookmarks/Name'), fontsize=9, letterspace=2, state=uiconst.UI_DISABLED, parent=c, align=uiconst.CENTERLEFT, left=4)
     edit = SinglelineEdit(name='nameEdit', parent=c, align=uiconst.CENTERLEFT, width=150)
     edit.OnReturn = self.OnEnter
     self.nameEdit = edit
     c = Container(name='urlcont', parent=toppar, align=uiconst.TOTOP, height=20, padBottom=5)
     label2 = Label(text=localization.GetByLabel('UI/Browser/EditBookmarks/URL'), fontsize=9, letterspace=2, state=uiconst.UI_DISABLED, parent=c, align=uiconst.CENTERLEFT, left=4, uppercase=True)
     edit = SinglelineEdit(name='urlEdit', parent=c, align=uiconst.CENTERLEFT, width=150)
     edit.OnReturn = self.OnEnter
     self.urlEdit = edit
     self.nameEdit.left = self.urlEdit.left = max(35, label.textwidth + 6, label2.textwidth + 6)
     b = Button(parent=toppar, label=localization.GetByLabel('UI/Browser/EditBookmarks/Add'), func=self.OnEnter, align=uiconst.BOTTOMRIGHT)
     editBtn = Button(parent=toppar, label=localization.GetByLabel('UI/Browser/EditBookmarks/Edit'), pos=(b.width + const.defaultPadding,
      0,
      0,
      0), func=self.OnEdit, align=uiconst.BOTTOMRIGHT)
     editBtn.state = uiconst.UI_HIDDEN
     self.editBtn = editBtn
     name = StripTags(name).strip()
     if name:
         self.nameEdit.SetValue(name)
     if url:
         self.urlEdit.SetValue(url)
     self.scroll = Scroll(parent=main, padding=(const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding,
      const.defaultPadding))
     sm.GetService('sites')
     self.RefreshSites()
Пример #4
0
class GraphsWindow(Window):
    __guid__ = 'form.GraphsWindow'
    default_caption = 'Blue stats graphs'
    default_minSize = (600, 500)

    def ApplyAttributes(self, attributes):
        self._ready = False
        Window.ApplyAttributes(self, attributes)
        self.graphs = GraphManager()
        self.graphs.SetEnabled(True)
        if hasattr(self, 'SetTopparentHeight'):
            self.SetTopparentHeight(0)
            self.container = Container(parent=self.sr.main,
                                       align=uiconst.TOALL)
        else:
            self.container = Container(parent=self.sr.content,
                                       align=uiconst.TOALL)
        self.settingsContainer = Container(parent=self.container,
                                           align=uiconst.TOTOP,
                                           height=30)
        self.showTimersChk = Checkbox(parent=self.settingsContainer,
                                      align=uiconst.TOLEFT,
                                      text='Timers',
                                      checked=True,
                                      width=120,
                                      height=30,
                                      callback=self.PopulateScroll)
        self.showMemoryChk = Checkbox(parent=self.settingsContainer,
                                      align=uiconst.TOLEFT,
                                      text='Memory counters',
                                      checked=True,
                                      width=120,
                                      height=30,
                                      callback=self.PopulateScroll)
        self.showLowCountersChk = Checkbox(parent=self.settingsContainer,
                                           align=uiconst.TOLEFT,
                                           text='Low counters',
                                           checked=True,
                                           width=120,
                                           height=30,
                                           callback=self.PopulateScroll)
        self.showHighCountersChk = Checkbox(parent=self.settingsContainer,
                                            align=uiconst.TOLEFT,
                                            text='High counters',
                                            checked=True,
                                            width=120,
                                            height=30,
                                            callback=self.PopulateScroll)
        self.resetBtn = Button(parent=self.settingsContainer,
                               align=uiconst.TORIGHT,
                               label='Reset peaks',
                               width=120,
                               height=30,
                               func=self.PopulateScroll)
        self.refreshBtn = Button(parent=self.settingsContainer,
                                 align=uiconst.TORIGHT,
                                 label='Refresh',
                                 width=120,
                                 height=30,
                                 func=self.PopulateScroll)
        self.scroll = Scroll(parent=self.container,
                             id='blueGraphsScroll',
                             align=uiconst.TOTOP,
                             height=200)
        self.graphsContainer = Container(parent=self.container,
                                         align=uiconst.TOALL)
        self._ready = True
        self.PopulateScroll()

    def Close(self, *args, **kwargs):
        self.graphs.SetEnabled(False)
        Window.Close(self, *args, **kwargs)

    def DelayedRefresh_thread(self):
        blue.synchro.SleepWallclock(600)
        self.PopulateScroll()

    def DelayedRefresh(self):
        uthread.new(self.DelayedRefresh_thread)

    def ResetPeaks(self, *args):
        blue.statistics.ResetPeaks()
        self.DelayedRefresh()

    def PopulateScroll(self, *args):
        typesIncluded = []
        if self.showTimersChk.GetValue():
            typesIncluded.append('time')
        if self.showMemoryChk.GetValue():
            typesIncluded.append('memory')
        if self.showLowCountersChk.GetValue():
            typesIncluded.append('counterLow')
        if self.showHighCountersChk.GetValue():
            typesIncluded.append('counterHigh')
        stats = blue.statistics.GetValues()
        desc = blue.statistics.GetDescriptions()
        contentList = []
        for key, value in desc.iteritems():
            type = value[1]
            if type in typesIncluded:
                peak = stats[key][1]
                if type == 'memory':
                    label = '%s<t>%s<t>%s' % (key, FormatMemory(peak),
                                              value[0])
                elif type.startswith('counter'):
                    label = '%s<t>%s<t>%s' % (key, niceNum(peak, 1), value[0])
                elif type == 'time':
                    label = '%s<t>%s<t>%s' % (key, niceNum(peak,
                                                           1e-10), value[0])
                listEntry = ScrollEntryNode(
                    decoClass=SE_GenericCore,
                    id=id,
                    name=key,
                    peak=peak,
                    desc=value[0],
                    label=label,
                    GetMenu=self.GetListEntryMenu,
                    OnDblClick=self.OnListEntryDoubleClicked)
                contentList.append(listEntry)

        self.scroll.Load(contentList=contentList,
                         headers=['Name', 'Peak', 'Description'],
                         noContentHint='No Data available')

    def GetListEntryMenu(self, listEntry):
        return (('Right-click action 1', None), ('Right-click action 2', None))

    def OnListEntryDoubleClicked(self, listEntry):
        node = listEntry.sr.node
        if self.graphs.HasGraph(node.name):
            self.graphs.RemoveGraph(node.name)
        else:
            self.graphs.AddGraph(node.name)

    def _OnResize(self):
        if self._ready:
            l, t, w, h = self.graphsContainer.GetAbsolute()
            scaledAbs = (uicore.ScaleDpi(l), uicore.ScaleDpi(t),
                         uicore.ScaleDpi(w), uicore.ScaleDpi(h))
            self.graphs.AdjustViewports(scaledAbs)
 def ConstructBottomCont(self):
     self.scroll = Scroll(parent=self.bottomCont, multiselect=True)
     self.LoadScroll()
Пример #6
0
class WebsiteTrustManagementWindowCore(Window):
    __guid__ = 'uicls.WebsiteTrustManagementWindowCore'
    __notifyevents__ = ['OnTrustedSitesChange']
    default_windowID = 'WebsiteTrustManagementWindow'

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        initialUrl = attributes.initialUrl
        self.SetCaption(localization.GetByLabel('UI/Browser/TrustedSites'))
        self.SetMinSize((368, 300))
        mainArea = self.GetMainArea()
        mainArea.top = 2
        self.inputContainer = Container(name='inputContainer',
                                        parent=mainArea,
                                        align=uiconst.TOTOP,
                                        height=50)
        self.bodyContainer = Container(name='bodyContainer',
                                       parent=mainArea,
                                       align=uiconst.TOALL,
                                       pos=(0, 0, 0, 0))
        self.trustContainer = Container(name='trustContainer',
                                        parent=self.bodyContainer,
                                        align=uiconst.TOTOP,
                                        height=76)
        self.ignoreContainer = Container(name='ignoreContainer',
                                         parent=self.bodyContainer,
                                         align=uiconst.TOBOTTOM,
                                         height=76)
        urlInputContainer = Container(name='urlInputContainer',
                                      parent=self.inputContainer,
                                      align=uiconst.TOTOP,
                                      height=22,
                                      top=3)
        inputButtonContainer = Container(name='urlInputButtonContainer',
                                         parent=self.inputContainer,
                                         align=uiconst.TOBOTTOM,
                                         height=20,
                                         padRight=4)
        self.urlText = Label(
            text=localization.GetByLabel('UI/Browser/EditBookmarks/URL'),
            parent=urlInputContainer,
            align=uiconst.TOLEFT,
            padLeft=6,
            state=uiconst.UI_DISABLED,
            uppercase=1,
            fontsize=10,
            letterspace=1)
        self.urlInput = SinglelineEdit(name='urlInput',
                                       parent=urlInputContainer,
                                       align=uiconst.TOTOP,
                                       padRight=const.defaultPadding,
                                       padLeft=const.defaultPadding)
        self.trustBtn = Button(
            parent=inputButtonContainer,
            label=localization.GetByLabel('UI/Browser/TrustSite'),
            align=uiconst.TORIGHT,
            padLeft=4,
            padBottom=3,
            func=self.TrustSite)
        self.trustBtn.hint = localization.GetByLabel(
            'UI/Browser/TrustManagementTrustHint')
        self.ignoreBtn = Button(
            parent=inputButtonContainer,
            label=localization.GetByLabel('UI/Browser/IgnoreSite'),
            align=uiconst.TORIGHT,
            padLeft=4,
            padBottom=3,
            func=self.IgnoreSite)
        self.ignoreBtn.hint = localization.GetByLabel(
            'UI/Browser/TrustManagementIgnoreHint')
        trustBtnContainer = Container(name='trustBtnContainer',
                                      parent=self.trustContainer,
                                      align=uiconst.TOBOTTOM,
                                      height=22,
                                      padRight=4)
        trustRemoveBtn = Button(
            parent=trustBtnContainer,
            label=localization.GetByLabel('UI/Commands/Remove'),
            align=uiconst.TORIGHT,
            padLeft=4,
            padBottom=3,
            func=self.RemoveTrustedSite)
        trustRemoveBtn.hint = localization.GetByLabel(
            'UI/Browser/TrustManagementRemoveTrustHint')
        trustTextContainer = Container(name='trustTextContainer',
                                       parent=self.trustContainer,
                                       align=uiconst.TOTOP,
                                       height=14)
        Label(text=localization.GetByLabel('UI/Browser/TrustedSites'),
              parent=trustTextContainer,
              state=uiconst.UI_DISABLED,
              fontsize=10,
              left=10,
              top=3)
        trustScrollContainer = Container(name='trustScrollContainer',
                                         parent=self.trustContainer,
                                         align=uiconst.TOALL)
        self.trustScroll = Scroll(
            parent=trustScrollContainer,
            padding=(const.defaultPadding, const.defaultPadding,
                     const.defaultPadding, const.defaultPadding))
        ignoreBtnContainer = Container(name='ignoreBtnContainer',
                                       parent=self.ignoreContainer,
                                       align=uiconst.TOBOTTOM,
                                       height=22,
                                       padRight=4)
        ignoreRemoveBtn = Button(
            parent=ignoreBtnContainer,
            label=localization.GetByLabel('UI/Commands/Remove'),
            align=uiconst.TORIGHT,
            padLeft=4,
            padBottom=3,
            func=self.RemoveIgnoredSite)
        ignoreRemoveBtn.hint = localization.GetByLabel(
            'UI/Browser/TrustManagementRemoveIgnoredHint')
        ignoreTextContainer = Container(name='ignoreTextContainer',
                                        parent=self.ignoreContainer,
                                        align=uiconst.TOTOP,
                                        height=14)
        Label(text=localization.GetByLabel('UI/Browser/IgnoredSites'),
              parent=ignoreTextContainer,
              state=uiconst.UI_DISABLED,
              fontsize=10,
              left=10,
              top=3)
        ignoreScrollContainer = Container(name='ignoreScrollContainer',
                                          parent=self.ignoreContainer,
                                          align=uiconst.TOALL)
        self.ignoreScroll = Scroll(
            parent=ignoreScrollContainer,
            padding=(const.defaultPadding, const.defaultPadding,
                     const.defaultPadding, const.defaultPadding))
        self.inited = 1
        self.sitesSvc = sm.GetService('sites')
        self.RefreshSites()
        if initialUrl is not None:
            self.urlInput.SetValue(initialUrl)

    def _OnResize(self, *args):
        uthread.new(self.__OnResize, *args)

    def __OnResize(self, *args):
        if not getattr(self, 'inited', False):
            return
        bodyHeight = self.bodyContainer.absoluteBottom - self.bodyContainer.absoluteTop
        halfSize = int(bodyHeight / 2)
        if halfSize * 2 != bodyHeight:
            self.trustContainer.height = halfSize + 1
        else:
            self.trustContainer.height = halfSize
        self.ignoreContainer.height = halfSize

    def TrustSite(self, *args):
        value = self.urlInput.GetValue()
        if not value:
            eve.Message('trustedSiteManagementPleaseEnterUrl')
            return
        value = value.strip()
        if value is not None and len(value) > 0:
            self.sitesSvc.AddTrustedSite(value)
        else:
            eve.Message('trustedSiteManagementPleaseEnterUrl')

    def IgnoreSite(self, *args):
        value = self.urlInput.GetValue()
        if not value:
            eve.Message('trustedSiteManagementPleaseEnterUrl')
            return
        value = value.strip()
        if value is not None and len(value) > 0:
            self.sitesSvc.AddIgnoredSite(value)
        else:
            eve.Message('trustedSiteManagementPleaseEnterUrl')

    def RemoveTrustedSite(self, *args):
        selected = self.trustScroll.GetSelected()
        if not len(selected):
            eve.Message('trustedSiteManagementPleaseSelectSite')
            return
        for entry in selected:
            self.sitesSvc.RemoveTrustedSite(entry.retval)

    def RemoveIgnoredSite(self, *args):
        selected = self.ignoreScroll.GetSelected()
        if not len(selected):
            eve.Message('trustedSiteManagementPleaseSelectSite')
            return
        for entry in selected:
            self.sitesSvc.RemoveTrustedSite(entry.retval)

    def OnTrustedSitesChange(self, *etc):
        self.RefreshSites()

    def OnGetTrustMenu(self, entry):
        return [(localization.GetByLabel('UI/Commands/Remove'),
                 sm.GetService('sites').RemoveTrustedSite,
                 (entry.sr.node.retval, ))]

    def RefreshSites(self):
        trustScrollList = []
        ignoreScrollList = []
        for key, value in self.sitesSvc.GetTrustedSites().iteritems():
            if value.auto:
                continue
            trustScrollList.append(
                ScrollEntryNode(decoClass=SE_GenericCore,
                                label=key,
                                retval=key,
                                trustData=value,
                                GetMenu=self.OnGetTrustMenu))

        for key, value in self.sitesSvc.GetIgnoredSites().iteritems():
            if value.auto:
                continue
            ignoreScrollList.append(
                ScrollEntryNode(decoClass=SE_GenericCore,
                                label=key,
                                retval=key,
                                trustData=value,
                                GetMenu=self.OnGetTrustMenu))

        self.trustScroll.Load(contentList=trustScrollList)
        self.ignoreScroll.Load(contentList=ignoreScrollList)
Пример #7
0
 def GetNoItemNode(self, *args, **kwds):
     return Scroll.GetNoItemNode(self, *args, **kwds)
Пример #8
0
 def ScrollToProportion(self, *args, **kwds):
     return Scroll.ScrollToProportion(self, *args, **kwds)
Пример #9
0
 def Scroll(self, *args, **kwds):
     return Scroll.Scroll(self, *args, **kwds)
Пример #10
0
 def OnEnd(self, *args, **kwds):
     return Scroll.OnEnd(self, *args, **kwds)
Пример #11
0
 def GetContentWidth(self, *args, **kwds):
     return Scroll.GetContentWidth(self, *args, **kwds)
Пример #12
0
 def OnClipperResize(self, *args, **kwds):
     return Scroll.OnClipperResize(self, *args, **kwds)
Пример #13
0
 def GetContentContainer(self, *args, **kwds):
     return Scroll.GetContentContainer(self, *args, **kwds)
Пример #14
0
 def GetSelected(self, *args, **kwds):
     return Scroll.GetSelected(self, *args, **kwds)
 def _OnCharThread(self, *args, **kwds):
     return Scroll._OnCharThread(self, *args, **kwds)
Пример #16
0
 def GetContentHeight(self, *args, **kwds):
     return Scroll.GetContentHeight(self, *args, **kwds)
Пример #17
0
 def OnHome(self, *args, **kwds):
     return Scroll.OnHome(self, *args, **kwds)
Пример #18
0
 def GetContentParentSize(self, *args, **kwds):
     return Scroll.GetContentParentSize(self, *args, **kwds)
Пример #19
0
 def OnMouseWheel(self, *args, **kwds):
     return Scroll.OnMouseWheel(self, *args, **kwds)
Пример #20
0
 def UpdatePositionLoop(self, *args, **kwds):
     Scroll.UpdatePositionLoop(self, *args, **kwds)
Пример #21
0
 def GetScrollProportion(self, *args, **kwds):
     return Scroll.GetScrollProportion(self, *args, **kwds)
Пример #22
0
 def UpdateScrollHandle(self, *args, **kwds):
     return Scroll.UpdateScrollHandle(self, *args, **kwds)
Пример #23
0
 def GetMinSize(self, *args, **kwds):
     return Scroll.GetMinSize(self, *args, **kwds)
Пример #24
0
 def OnChar(self, *args, **kwds):
     return Scroll.OnChar(self, *args, **kwds)
Пример #25
0
 def ShowHint(self, *args, **kwds):
     return Scroll.ShowHint(self, *args, **kwds)
Пример #26
0
 def _OnCharThread(self, *args, **kwds):
     return Scroll._OnCharThread(self, *args, **kwds)
Пример #27
0
 def ApplyAttributes(self, attributes):
     Window.ApplyAttributes(self, attributes)
     initialUrl = attributes.initialUrl
     self.SetCaption(localization.GetByLabel('UI/Browser/TrustedSites'))
     self.SetMinSize((368, 300))
     mainArea = self.GetMainArea()
     mainArea.top = 2
     self.inputContainer = Container(name='inputContainer',
                                     parent=mainArea,
                                     align=uiconst.TOTOP,
                                     height=50)
     self.bodyContainer = Container(name='bodyContainer',
                                    parent=mainArea,
                                    align=uiconst.TOALL,
                                    pos=(0, 0, 0, 0))
     self.trustContainer = Container(name='trustContainer',
                                     parent=self.bodyContainer,
                                     align=uiconst.TOTOP,
                                     height=76)
     self.ignoreContainer = Container(name='ignoreContainer',
                                      parent=self.bodyContainer,
                                      align=uiconst.TOBOTTOM,
                                      height=76)
     urlInputContainer = Container(name='urlInputContainer',
                                   parent=self.inputContainer,
                                   align=uiconst.TOTOP,
                                   height=22,
                                   top=3)
     inputButtonContainer = Container(name='urlInputButtonContainer',
                                      parent=self.inputContainer,
                                      align=uiconst.TOBOTTOM,
                                      height=20,
                                      padRight=4)
     self.urlText = Label(
         text=localization.GetByLabel('UI/Browser/EditBookmarks/URL'),
         parent=urlInputContainer,
         align=uiconst.TOLEFT,
         padLeft=6,
         state=uiconst.UI_DISABLED,
         uppercase=1,
         fontsize=10,
         letterspace=1)
     self.urlInput = SinglelineEdit(name='urlInput',
                                    parent=urlInputContainer,
                                    align=uiconst.TOTOP,
                                    padRight=const.defaultPadding,
                                    padLeft=const.defaultPadding)
     self.trustBtn = Button(
         parent=inputButtonContainer,
         label=localization.GetByLabel('UI/Browser/TrustSite'),
         align=uiconst.TORIGHT,
         padLeft=4,
         padBottom=3,
         func=self.TrustSite)
     self.trustBtn.hint = localization.GetByLabel(
         'UI/Browser/TrustManagementTrustHint')
     self.ignoreBtn = Button(
         parent=inputButtonContainer,
         label=localization.GetByLabel('UI/Browser/IgnoreSite'),
         align=uiconst.TORIGHT,
         padLeft=4,
         padBottom=3,
         func=self.IgnoreSite)
     self.ignoreBtn.hint = localization.GetByLabel(
         'UI/Browser/TrustManagementIgnoreHint')
     trustBtnContainer = Container(name='trustBtnContainer',
                                   parent=self.trustContainer,
                                   align=uiconst.TOBOTTOM,
                                   height=22,
                                   padRight=4)
     trustRemoveBtn = Button(
         parent=trustBtnContainer,
         label=localization.GetByLabel('UI/Commands/Remove'),
         align=uiconst.TORIGHT,
         padLeft=4,
         padBottom=3,
         func=self.RemoveTrustedSite)
     trustRemoveBtn.hint = localization.GetByLabel(
         'UI/Browser/TrustManagementRemoveTrustHint')
     trustTextContainer = Container(name='trustTextContainer',
                                    parent=self.trustContainer,
                                    align=uiconst.TOTOP,
                                    height=14)
     Label(text=localization.GetByLabel('UI/Browser/TrustedSites'),
           parent=trustTextContainer,
           state=uiconst.UI_DISABLED,
           fontsize=10,
           left=10,
           top=3)
     trustScrollContainer = Container(name='trustScrollContainer',
                                      parent=self.trustContainer,
                                      align=uiconst.TOALL)
     self.trustScroll = Scroll(
         parent=trustScrollContainer,
         padding=(const.defaultPadding, const.defaultPadding,
                  const.defaultPadding, const.defaultPadding))
     ignoreBtnContainer = Container(name='ignoreBtnContainer',
                                    parent=self.ignoreContainer,
                                    align=uiconst.TOBOTTOM,
                                    height=22,
                                    padRight=4)
     ignoreRemoveBtn = Button(
         parent=ignoreBtnContainer,
         label=localization.GetByLabel('UI/Commands/Remove'),
         align=uiconst.TORIGHT,
         padLeft=4,
         padBottom=3,
         func=self.RemoveIgnoredSite)
     ignoreRemoveBtn.hint = localization.GetByLabel(
         'UI/Browser/TrustManagementRemoveIgnoredHint')
     ignoreTextContainer = Container(name='ignoreTextContainer',
                                     parent=self.ignoreContainer,
                                     align=uiconst.TOTOP,
                                     height=14)
     Label(text=localization.GetByLabel('UI/Browser/IgnoredSites'),
           parent=ignoreTextContainer,
           state=uiconst.UI_DISABLED,
           fontsize=10,
           left=10,
           top=3)
     ignoreScrollContainer = Container(name='ignoreScrollContainer',
                                       parent=self.ignoreContainer,
                                       align=uiconst.TOALL)
     self.ignoreScroll = Scroll(
         parent=ignoreScrollContainer,
         padding=(const.defaultPadding, const.defaultPadding,
                  const.defaultPadding, const.defaultPadding))
     self.inited = 1
     self.sitesSvc = sm.GetService('sites')
     self.RefreshSites()
     if initialUrl is not None:
         self.urlInput.SetValue(initialUrl)
Пример #28
0
 def BrowseNodes(self, *args, **kwds):
     return Scroll.BrowseNodes(self, *args, **kwds)
class TestAnimationsWnd(Window):
    __guid__ = 'form.UIAnimationTest'
    __notifyevents__ = [
        'OnUITestAnimationSelected', 'OnTestAnimationsPlayAnimation'
    ]
    default_minSize = (500, 300)
    default_caption = 'UI Animations'
    default_windowID = 'UIAnimationTest'

    def ApplyAttributes(self, attributes):
        Window.ApplyAttributes(self, attributes)
        if hasattr(self, 'SetTopparentHeight'):
            self.SetTopparentHeight(0)
        if self.sr.main is None:
            self.sr.main = Container(parent=self.sr.maincontainer)
        self.mainItem = None
        self.mainSprite = None
        self.mainTransform = None
        self.inputObj = attributes.get('animObj', None)
        self.codeEdit = None
        self.duration = 0.5
        self.loops = 1
        self.curveSet = None
        if self.inputObj:
            self.mode = MODE_INPUT
        else:
            self.mode = MODE_NORMAL
        self.topCont = Container(name='topCont',
                                 parent=self.sr.main,
                                 align=uiconst.TOTOP,
                                 height=20)
        self.mainCont = Container(name='mainCont',
                                  parent=self.sr.main,
                                  align=uiconst.TOTOP,
                                  height=200)
        self.topRightCont = Container(name='topRightCont',
                                      parent=self.mainCont,
                                      align=uiconst.TORIGHT,
                                      width=100)
        self.spriteCont = Container(name='spriteCont', parent=self.mainCont)
        from carbonui.primitives.gridcontainer import GridContainer
        self.buttonCont = GridContainer(name='buttonCont',
                                        parent=self.sr.main,
                                        align=uiconst.TOBOTTOM,
                                        height=30,
                                        columns=3,
                                        lines=1)
        self.bottomCont = Container(name='bottomCont', parent=self.sr.main)
        self.ConstructTopCont()
        self.ConstructTopRightCont()
        self.ConstructBottomCont()
        self.ConstructMainCont()
        btns = [('Uncheck all', self.UncheckAll, ()),
                ('Stop all', self.StopAllAnimations, ()),
                ('Play selected', self.PlaySelected, ())]
        for label, func, args in btns:
            Button(parent=Container(parent=self.buttonCont),
                   label=label,
                   func=func,
                   align=uiconst.CENTER)

    def ConstructTopCont(self):
        checkBoxes = [(MODE_NORMAL, 'Normal'), (MODE_CODE, 'Code')]
        if self.inputObj:
            checkBoxes.append((MODE_INPUT, 'Input object'))
        for retval, text in checkBoxes:
            Checkbox(parent=self.topCont,
                     text=text,
                     groupname='radioGroup',
                     align=uiconst.TOLEFT,
                     checked=retval == self.mode,
                     callback=self.OnRadioButtonsChanged,
                     retval=retval,
                     width=100)

    def ConstructTopRightCont(self):
        self.durationEdit = SinglelineEdit(parent=self.topRightCont,
                                           name='durationEdit',
                                           align=uiconst.TOPRIGHT,
                                           label='duration',
                                           floats=(0.0, 10.0),
                                           setvalue=self.duration,
                                           pos=(5, 14, 100, 0),
                                           OnChange=self.OnDurationEditChanged)
        self.loopsEdit = SinglelineEdit(parent=self.topRightCont,
                                        name='loopEdit',
                                        align=uiconst.TOPRIGHT,
                                        label='loops',
                                        ints=(-1, 20),
                                        setvalue=self.loops,
                                        pos=(5, 52, 100, 0),
                                        OnChange=self.OnLoopEditChanged)
        options = [
            (funcName, getattr(uiconst, funcName)) for funcName in dir(uiconst)
            if funcName.startswith('ANIM_') and funcName != 'ANIM_LOOPCYCLE'
        ]
        self.curveTypeCombo = Combo(parent=self.topRightCont,
                                    label='curveType',
                                    options=options,
                                    name='',
                                    select=uiconst.ANIM_SMOOTH,
                                    pos=(5, 92, 100, 0),
                                    width=100,
                                    align=uiconst.TOPRIGHT)

    def ConstructMainCont(self):
        self.spriteCont.Flush()
        self.mainItem = None
        self.mainTransform = None
        self.mainSprite = None
        self.codeEdit = None
        if self.mode is MODE_NORMAL:
            self.mainTransform = Transform(parent=self.spriteCont,
                                           align=uiconst.CENTER,
                                           pos=(0, 0, 128, 128))
            self.mainSprite = Sprite(
                parent=self.mainTransform,
                align=uiconst.CENTER,
                pos=(0, 0, 128, 128),
                texturePath='res:/UI/Texture/CorpLogoLibs/419.png',
                texturePathSecondary='res:/UI/Texture/colorgradient.dds')
        elif self.mode is MODE_CODE:
            self.codeEdit = SinglelineEdit(
                parent=self.spriteCont,
                align=uiconst.TOTOP,
                label='Code that returns a UI object:',
                heigt=15,
                padding=(10, 30, 150, 0),
                setvalue=settings.user.ui.Get('TestAnimationsWndCode',
                                              'uicore.layer.sidePanels'))
            Button(parent=self.spriteCont,
                   align=uiconst.TOPLEFT,
                   label='Assign result',
                   top=60,
                   left=5,
                   func=self.OnAssignCodeBtn)
        elif self.mode is MODE_INPUT:
            self.mainItem = self.inputObj

    def OnDurationEditChanged(self, value):
        self.duration = float(value.replace(',', '.'))

    def OnLoopEditChanged(self, value):
        try:
            self.loops = int(value)
        except:
            self.loops = 0.5

    def ConstructBottomCont(self):
        self.scroll = Scroll(parent=self.bottomCont, multiselect=True)
        self.LoadScroll()

    def LoadScroll(self):
        scrolllist = []
        for funcName in dir(uicore.animations):
            if funcName.startswith('_'):
                continue
            func = getattr(uicore.animations, funcName)
            if not callable(func):
                continue
            node = ScrollEntryNode(decoClass=TestAnimationsCheckbox,
                                   label=funcName,
                                   animFunc=func)
            scrolllist.append(node)

        self.scroll.Load(contentList=scrolllist)

    def OnRadioButtonsChanged(self, button):
        self.mode = button.data['value']
        self.ConstructMainCont()

    def OnAssignCodeBtn(self, *args):
        exec 'self.mainItem=%s' % self.codeEdit.GetValue()
        settings.user.ui.Get('TestAnimationsWndCode', self.codeEdit.GetValue())

    def OnUITestAnimationSelected(self, animFunc):
        animFunc(self.mainItem)

    def PlaySelected(self, *args):
        if self.curveSet:
            self.curveSet.Stop()
        nodes = self.scroll.GetNodes()
        for node in nodes:
            if node.checked:
                self.PlayAnimation(node.animFunc, node.label)

    def StopAllAnimations(self, *args):
        for obj in (self.mainItem, self.mainTransform, self.mainSprite,
                    self.inputObj):
            if obj:
                obj.StopAnimations()

    def PlayAnimation(self, animFunc, funcName):
        if self.mode == MODE_NORMAL:
            if self.mainSprite and funcName.startswith('Sp'):
                obj = self.mainSprite
            else:
                obj = self.mainTransform
        else:
            obj = self.mainItem
        if obj:
            curveType = self.curveTypeCombo.GetValue()
            print 'PLAY', obj
            self.curveSet = animFunc(obj,
                                     duration=self.duration,
                                     loops=self.loops,
                                     curveType=curveType)

    def OnTestAnimationsPlayAnimation(self, animFunc, funcName):
        self.PlayAnimation(animFunc, funcName)

    def UncheckAll(self, *args):
        self.LoadScroll()

    def SetAnimationObject(self, animObj):
        self.mainItem = self.inputObj = animObj
Пример #30
0
 def OnDown(self, *args, **kwds):
     return Scroll.OnDown(self, *args, **kwds)
Пример #31
0
 def ApplyAttributes(self, attributes):
     self._ready = False
     Window.ApplyAttributes(self, attributes)
     self.graphs = GraphManager()
     self.graphs.SetEnabled(True)
     if hasattr(self, 'SetTopparentHeight'):
         self.SetTopparentHeight(0)
         self.container = Container(parent=self.sr.main,
                                    align=uiconst.TOALL)
     else:
         self.container = Container(parent=self.sr.content,
                                    align=uiconst.TOALL)
     self.settingsContainer = Container(parent=self.container,
                                        align=uiconst.TOTOP,
                                        height=30)
     self.showTimersChk = Checkbox(parent=self.settingsContainer,
                                   align=uiconst.TOLEFT,
                                   text='Timers',
                                   checked=True,
                                   width=120,
                                   height=30,
                                   callback=self.PopulateScroll)
     self.showMemoryChk = Checkbox(parent=self.settingsContainer,
                                   align=uiconst.TOLEFT,
                                   text='Memory counters',
                                   checked=True,
                                   width=120,
                                   height=30,
                                   callback=self.PopulateScroll)
     self.showLowCountersChk = Checkbox(parent=self.settingsContainer,
                                        align=uiconst.TOLEFT,
                                        text='Low counters',
                                        checked=True,
                                        width=120,
                                        height=30,
                                        callback=self.PopulateScroll)
     self.showHighCountersChk = Checkbox(parent=self.settingsContainer,
                                         align=uiconst.TOLEFT,
                                         text='High counters',
                                         checked=True,
                                         width=120,
                                         height=30,
                                         callback=self.PopulateScroll)
     self.resetBtn = Button(parent=self.settingsContainer,
                            align=uiconst.TORIGHT,
                            label='Reset peaks',
                            width=120,
                            height=30,
                            func=self.PopulateScroll)
     self.refreshBtn = Button(parent=self.settingsContainer,
                              align=uiconst.TORIGHT,
                              label='Refresh',
                              width=120,
                              height=30,
                              func=self.PopulateScroll)
     self.scroll = Scroll(parent=self.container,
                          id='blueGraphsScroll',
                          align=uiconst.TOTOP,
                          height=200)
     self.graphsContainer = Container(parent=self.container,
                                      align=uiconst.TOALL)
     self._ready = True
     self.PopulateScroll()
 def _DeselectNode(self, *args, **kwds):
     return Scroll._DeselectNode(self, *args, **kwds)