'justPy toggle a Quasar drawer
I copied some HTML from Quasar for a page layout with a drawer and can not figure out how to toggle the drawer (sidebar). The button works to hide the drawer, but can not get it visible again. Or if you have an example or can point me in direction of a non-Quasar sidebar that works in a similar manner, that would be helpful.
def show_drawer(self,msg):
self.wbDrawer.show = True
def toggle_show_drawer(self, msg):
self.wbDrawer.show = not self.wbDrawer.show
def toggle_visible_drawer(self, msg):
if self.wbDrawerDiv.visibility_state == 'visible':
self.wbDrawerDiv.set_class('invisible')
self.wbDrawerDiv.visibility_state = 'invisible'
else:
self.wbDrawerDiv.set_class('visible')
self.wbDrawerDiv.visibility_state = 'visible'
self.btn1.visibility_state = 'visible'
def quasar_print():
wp = jp.QuasarPage()
c = jp.parse_html(html_string, a=wp)
for i in c.commands:
print(i)
return wp
def quasar_page():
wp = jp.QuasarPage()
wp.data["drawer"] = "open"
root = jp.Div(a=wp)
c1 = jp.Div(classes='q-pa-md', a=root)
wbLayout = jp.QLayout(view='hHh Lpr lff', container=True, style='height: 300px', classes='shadow-2 rounded-borders', a=c1)
wbHeader = jp.QHeader(elevated=True, classes='bg-black', a=wbLayout)
wbToolbar = jp.QToolbar(a=wbHeader)
wbToolbarBtn = jp.QBtn(flat=True, round=True, dense=True, icon='menu', a=wbToolbar,click=toggle_visible_drawer)
wbToolbarTitle = jp.QToolbarTitle(a=wbToolbar, text='Header')
wbDrawerDiv = jp.Div(a=wbLayout)
wbDrawer = jp.QDrawer( width=200, breakpoint=500, bordered=True, classes='bg-grey-3', a=wbDrawerDiv, model=[wp, 'drawer'])
wbScrollArea = jp.QScrollArea(classes='fit', a=wbDrawer)
c9 = jp.QList(a=wbScrollArea)
c10 = jp.Div(a=c9, text='scroll area')
btn1 = jp.Button(text='Hide me', a=wbScrollArea)
wbPageContainer = jp.QPageContainer(a=wbLayout)
wbPage = jp.QPage(padding=True, a=wbPageContainer)
pageText = jp.Div(a=wbPage, text='page container')
btnSideBar = jp.Button(text="button on SideBar", a=wbScrollArea)
# try both visible and show
btnVisible = jp.QBtn(text="toggle_visible_drawer", a=wbPage,click=toggle_visible_drawer)
btnShow = jp.QBtn(text="toggle_visible_drawer", a=wbPage,click=toggle_show_drawer)
return wp
jp.justpy(quasar_page)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|