How to modularize and customise pages?
See original GitHub issueThe recent changes to page creation with the release of 0.9.0 renders the example discussed in #50 unfeasible:
class MainPage(ui.page):
def __init__(self):
super().__init__('/', dark=True)
with self:
ui.label('Hi!')
MainPage()
I have tried adapting the code (using PageBuilder) in the simple example, but failed to get it running as before.
from nicegui import ui
from nicegui.globals import page_builders
from nicegui.page import Page
from nicegui.page_builder import PageBuilder
class MainPage(Page):
def __init__(self):
super().__init__(dark=True)
ui.label('Hi!')
async def page_builder() -> Page:
return MainPage()
def index_page():
builder = PageBuilder(shared=False, function=page_builder)
page_builders.setdefault('/', builder)
index_page()
ui.run()
results in
raise RuntimeError('cannot find parent view, view stack is empty')
RuntimeError: cannot find parent view, view stack is empty
I have just recently migrated a great chunks of previously justpy code to the above inheritance approach including additional element/group classes (such as header, layout, pagecontainer, …) and am now seeking ways to make it work, again.
@falkoschindler: could you please guide me here, again? Thanks!
This issue is possibly related to #85.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Using modular design to create an efficient & cost-effective ...
During design, you can limit the number of complete page designs required by identifying the components that will be reused across your website....
Read more >Modular Pages - Grav Documentation
A Modular Page is a collection of pages stacked on top of each other to create a unified, single page. This lets you...
Read more >Modular Front-End Development & Design - Toptal
Through a modular design approach, it is possible to both save time and streamline ... When you connect them together in the right...
Read more >Modular Web Design - The Way Modern Websites Are Built
With modular web design, you can effectively cut the designer out of the process. You can assemble a live mockup of your landing...
Read more >Modular Web Design: Building a Website that Grows with Your ...
Modular design has revolutionized the way websites are built. The process involves creating a flexible system of standalone, reusable components ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rodja many thanks for providing the discussion #99 and examples showing how to make use of
ui.page
. Apologies for my late reply, unfortunately I currently cannot devote much time on digging deeper here. I will get back to you once I wrapped my head around using this pattern.Another pattern might be to define the content in a class and do the routing in main.py:
Or define the page content in a function: