** I’m trying to create a nested panel like the figure below. **
I think I want a GridPanel as the main container then 3 ColumnPanels as the nested containers.
I want to make the left component to hide and the right panel to expand when the button is clicked.
The containers align left to right. What am I doing wrong?
Code Sample:
from ._anvil_designer import Form1Template
from anvil import *
class Form1(Form1Template):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# make a GridPanel container
# gp = GridPanel(background='yellow', role='grid-panel')
# gp.border = "1px"
# gp.add_component(Label(text="Label 1", background='blue', foreground="white"), row=0, col_xs=0, width_xs=2)
# gp.add_component(TextBox(text="Some text"), row=0, col_xs=2, width_xs=6)
# gp.add_component(Button(text="Submit", background='red'), row=45, col_xs=0, width_xs=12)
# self.add_component(gp)
self.grid_panel = GridPanel(background='green')
# add it to the form template
self.add_component(self.grid_panel)
# make a ColumnPanel
self.navbar2 = ColumnPanel(role='navbar2', background="lightblue")
# add it to the GridPanel, this will be the top row and span 2 columns
self.grid_panel.add_component(self.navbar2, row=0, col_xs=2, full_width_row=True, )
# populate the ColumnPanel
self.hamburger_button_new = Button(text='Hamburger2', icon='fa-bars')
self.navbar2.add_component(self.hamburger_button_new)
self.navbar2.add_component(Label(text='Home'))
self.navbar2.add_component(Label(text='About'))
self.navbar2.add_component(Label(text='Help'))
self.navbar2.add_component(Label(text='Account'))
#create a left ColumnPanel window
self.left_panel2 = ColumnPanel(role='left-panel2', background="yellow")
# add it to row 1, column 0
self.grid_panel.add_component(self.left_panel2, row=1, col_xs=0, full_width_row=False,)
self.left_panel2.add_component(Label(text='Left Panel'))
#create a right window
self.right_panel2 = ColumnPanel(role='left-panel2', background="red")
# add it to row 1, column 1
self.grid_panel.add_component(self.right_panel2, row=1, col_xs=1, full_width_row=False,)
self.right_panel2.add_component(Label(text='Right Panel'))
Clone link:
share a copy of your app