EasySci commited on
Commit
4458be8
·
1 Parent(s): 2295323

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -1,17 +1,17 @@
1
  import panel as pn
2
 
3
  # Create a Panel app with centered title
4
- title = pn.pane.HTML("<h1 style='text-align: center;'>My Panel App</h1>", width_policy='max', height_policy='max')
5
 
6
  # Create a toggleable sidebar with three horizontal lines icon
7
  toggle_sidebar = pn.widgets.Button(name='☰', button_type='primary', width=30, height=30)
8
  toggle_sidebar.js_on_click(args={'sidebar': toggle_sidebar}, code="""
9
  if (sidebar.width == 0) {
10
  sidebar.width = 200;
11
- buttons.visible = True;
12
  } else {
13
  sidebar.width = 0;
14
- buttons.visible = False;
15
  }
16
  """)
17
 
@@ -21,7 +21,7 @@ button2 = pn.widgets.Button(name='Button 2')
21
  button3 = pn.widgets.Button(name='Button 3')
22
 
23
  # Create a column layout for the buttons inside the toggleable sidebar
24
- buttons = pn.Column(button1, button2, button3, visible=False, sizing_mode='stretch_height', background='#f6f6f6')
25
 
26
  # Combine the title, toggle button, and sidebar
27
  app = pn.Column(
@@ -31,9 +31,10 @@ app = pn.Column(
31
  pn.layout.Divider(),
32
  pn.Row(buttons, sizing_mode='stretch_width'),
33
  sizing_mode='stretch_both',
 
34
  ),
35
  sizing_mode='stretch_both',
36
  )
37
 
38
  # Run the app
39
- app.servable()
 
1
  import panel as pn
2
 
3
  # Create a Panel app with centered title
4
+ title = pn.pane.HTML("<h1 style='text-align: center;'>My Panel App</h1>", width=300)
5
 
6
  # Create a toggleable sidebar with three horizontal lines icon
7
  toggle_sidebar = pn.widgets.Button(name='☰', button_type='primary', width=30, height=30)
8
  toggle_sidebar.js_on_click(args={'sidebar': toggle_sidebar}, code="""
9
  if (sidebar.width == 0) {
10
  sidebar.width = 200;
11
+ buttons.css_classes = ['visible'];
12
  } else {
13
  sidebar.width = 0;
14
+ buttons.css_classes = ['hidden'];
15
  }
16
  """)
17
 
 
21
  button3 = pn.widgets.Button(name='Button 3')
22
 
23
  # Create a column layout for the buttons inside the toggleable sidebar
24
+ buttons = pn.Column(button1, button2, button3, sizing_mode='stretch_height', background='#f6f6f6', css_classes=['hidden'])
25
 
26
  # Combine the title, toggle button, and sidebar
27
  app = pn.Column(
 
31
  pn.layout.Divider(),
32
  pn.Row(buttons, sizing_mode='stretch_width'),
33
  sizing_mode='stretch_both',
34
+ align='center',
35
  ),
36
  sizing_mode='stretch_both',
37
  )
38
 
39
  # Run the app
40
+ app.servable()