Create a new view instance and set self.view default view, that will be used for checking on view parameters, before any element rendering is done, such as layout conditions and creating the right type of strings. >>> from pagebot.contexts import getContext >
(self, viewId=None, name=None, context=None)
| 1422 | return self.view |
| 1423 | |
| 1424 | def newView(self, viewId=None, name=None, context=None): |
| 1425 | """Create a new view instance and set self.view default view, that will |
| 1426 | be used for checking on view parameters, before any element rendering |
| 1427 | is done, such as layout conditions and creating the right type of |
| 1428 | strings. |
| 1429 | |
| 1430 | >>> from pagebot.contexts import getContext |
| 1431 | >>> from pagebot.elements.views import viewClasses |
| 1432 | >>> context = getContext('Flat') |
| 1433 | >>> doc = Document(name='TestDoc', w=300, h=400, autoPages=2, context=context) |
| 1434 | >>> doc.view.context, doc.context # Identical |
| 1435 | (<FlatContext>, <FlatContext>) |
| 1436 | >>> sorted(viewClasses.keys()) |
| 1437 | ['Git', 'Mamp', 'Page', 'Site'] |
| 1438 | >>> view = doc.newView('Page', 'myView', context=doc.context) |
| 1439 | >>> view.w, view.h |
| 1440 | (300pt, 400pt) |
| 1441 | >>> context = getContext('Html') |
| 1442 | >>> view = doc.newView('Site', context=context) |
| 1443 | >>> view.context, doc.view.context, doc.context # Identical |
| 1444 | (<HtmlContext>, <HtmlContext>, <HtmlContext>) |
| 1445 | """ |
| 1446 | if viewId is None: |
| 1447 | viewId = self.DEFAULT_VIEWID |
| 1448 | |
| 1449 | # Check if the context is supported by this view type. |
| 1450 | if context is None: |
| 1451 | context = getContext() |
| 1452 | |
| 1453 | view = self.view = self.views[viewId] = viewClasses[viewId](name=name |
| 1454 | or viewId, w=self.w, h=self.h, context=context) |
| 1455 | |
| 1456 | # Just set parent, without all functionality of self.addElement() |
| 1457 | view.setParent(self) |
| 1458 | return view |
| 1459 | |
| 1460 | # S A V E . J S O N |
| 1461 |
no test coverage detected