| | 135 | |
|---|
| | 136 | |
|---|
| | 137 | if _USE_DOCK: |
|---|
| | 138 | class dDockTabs(dPageFrameMixin, aui.AuiNotebook): |
|---|
| | 139 | _evtPageChanged = readonly(aui.EVT_AUINOTEBOOK_PAGE_CHANGED) |
|---|
| | 140 | _evtPageChanging = readonly(aui.EVT_AUINOTEBOOK_PAGE_CHANGING) |
|---|
| | 141 | _tabposBottom = readonly(aui.AUI_NB_BOTTOM) |
|---|
| | 142 | _tabposRight = readonly(aui.AUI_NB_RIGHT) |
|---|
| | 143 | _tabposLeft = readonly(aui.AUI_NB_LEFT) |
|---|
| | 144 | _tabposTop = readonly(aui.AUI_NB_TOP) |
|---|
| | 145 | |
|---|
| | 146 | def __init__(self, parent, properties=None, attProperties=None, *args, **kwargs): |
|---|
| | 147 | self._baseClass = dDockTabs |
|---|
| | 148 | preClass = aui.AuiNotebook |
|---|
| | 149 | |
|---|
| | 150 | newStyle = (aui.AUI_NB_TOP | aui.AUI_NB_TAB_SPLIT | aui.AUI_NB_TAB_MOVE |
|---|
| | 151 | | aui.AUI_NB_SCROLL_BUTTONS | aui.AUI_NB_CLOSE_ON_ALL_TABS) |
|---|
| | 152 | if "style" in kwargs: |
|---|
| | 153 | newStyle = kwargs["style"] | newStyle |
|---|
| | 154 | kwargs["style"] = newStyle |
|---|
| | 155 | dPageFrameMixin.__init__(self, preClass, parent, properties, attProperties, *args, **kwargs) |
|---|
| | 156 | |
|---|
| | 157 | |
|---|
| | 158 | def insertPage(self, pos, pgCls=None, caption="", imgKey=None, |
|---|
| | 159 | ignoreOverride=False): |
|---|
| | 160 | """ Insert the page into the pageframe at the specified position, |
|---|
| | 161 | and optionally sets the page caption and image. The image |
|---|
| | 162 | should have already been added to the pageframe if it is |
|---|
| | 163 | going to be set here. |
|---|
| | 164 | """ |
|---|
| | 165 | # Allow subclasses to potentially override this behavior. This will |
|---|
| | 166 | # enable them to handle page creation in their own way. If overridden, |
|---|
| | 167 | # the method will return the new page. |
|---|
| | 168 | ret = None |
|---|
| | 169 | if not ignoreOverride: |
|---|
| | 170 | ret = self._insertPageOverride(pos, pgCls, caption, imgKey) |
|---|
| | 171 | if ret: |
|---|
| | 172 | return ret |
|---|
| | 173 | if pgCls is None: |
|---|
| | 174 | pgCls = self.PageClass |
|---|
| | 175 | if isinstance(pgCls, dabo.ui.dPage): |
|---|
| | 176 | pg = pgCls |
|---|
| | 177 | else: |
|---|
| | 178 | # See if the 'pgCls' is either some XML or the path of an XML file |
|---|
| | 179 | if isinstance(pgCls, basestring): |
|---|
| | 180 | xml = pgCls |
|---|
| | 181 | from dabo.lib.DesignerXmlConverter import DesignerXmlConverter |
|---|
| | 182 | conv = DesignerXmlConverter() |
|---|
| | 183 | pgCls = conv.classFromXml(xml) |
|---|
| | 184 | pg = pgCls(self) |
|---|
| | 185 | if not caption: |
|---|
| | 186 | # Page could have its own default caption |
|---|
| | 187 | caption = pg._caption |
|---|
| | 188 | if imgKey: |
|---|
| | 189 | idx = self._imageList[imgKey] |
|---|
| | 190 | bmp = self.GetImageList().GetBitmap(idx) |
|---|
| | 191 | self.InsertPage(pos, pg, caption=caption, bitmap=bmp) |
|---|
| | 192 | else: |
|---|
| | 193 | self.InsertPage(pos, pg, caption=caption) |
|---|
| | 194 | self.layout() |
|---|
| | 195 | return self.Pages[pos] |
|---|
| | 196 | def _insertPageOverride(self, pos, pgCls, caption, imgKey): pass |
|---|
| | 197 | else: |
|---|
| | 198 | dDockTabs = dPageFrame |
|---|
| 150 | | |
|---|
| 151 | | class _dPageList_test(dPageList): |
|---|
| 152 | | def initProperties(self): |
|---|
| 153 | | self.Width = 400 |
|---|
| 154 | | self.Height = 175 |
|---|
| 155 | | self.TabPosition = random.choice(("Top", "Bottom", "Left", "Right")) |
|---|
| 156 | | |
|---|
| 157 | | def afterInit(self): |
|---|
| 158 | | self.appendPage(caption="Introduction") |
|---|
| 159 | | self.appendPage(caption="Chapter I") |
|---|
| 160 | | self.Pages[0].BackColor = "darkred" |
|---|
| 161 | | self.Pages[1].BackColor = "darkblue" |
|---|
| 162 | | |
|---|
| 163 | | def onPageChanged(self, evt): |
|---|
| 164 | | print "Page number changed from %s to %s" % (evt.oldPageNum, evt.newPageNum) |
|---|
| 165 | | |
|---|
| 166 | | |
|---|
| 167 | | class _dPageSelect_test(dPageSelect): |
|---|
| 168 | | def initProperties(self): |
|---|
| 169 | | self.Width = 400 |
|---|
| 170 | | self.Height = 175 |
|---|
| 171 | | self.TabPosition = random.choice(("Top", "Bottom", "Left", "Right")) |
|---|
| 172 | | |
|---|
| 173 | | def afterInit(self): |
|---|
| 174 | | self.appendPage(caption="Introduction") |
|---|
| 175 | | self.appendPage(caption="Chapter I") |
|---|
| 176 | | self.Pages[0].BackColor = "darkred" |
|---|
| 177 | | self.Pages[1].BackColor = "darkblue" |
|---|
| 178 | | |
|---|
| 179 | | def onPageChanged(self, evt): |
|---|
| 180 | | print "Page number changed from %s to %s" % (evt.oldPageNum, evt.newPageNum) |
|---|
| | 222 | class _dPageFrame_test(TestMixin, dPageFrame): pass |
|---|
| | 223 | class _dPageList_test(TestMixin, dPageList): pass |
|---|
| | 224 | class _dPageSelect_test(TestMixin, dPageSelect): pass |
|---|
| | 225 | class _dDockTabs_test(TestMixin, dDockTabs): pass |
|---|