Skip to content

Commit

Permalink
add buttons in grid
Browse files Browse the repository at this point in the history
  • Loading branch information
aktech committed Aug 23, 2023
1 parent ec668e6 commit 910ae4a
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions jhub_apps/launcher/panel_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def _get_image_item(logo, desc, link):
return {"image": logo, "description": desc, "link": link}


def create_grid():
import panel as pn

# Define LOGO_MAPPING and other functions...

def create_grid_with_buttons():
items = [
_get_image_item(logo=LOGO_MAPPING.get('panel'), desc="Desc", link="/"),
_get_image_item(logo=LOGO_MAPPING.get('streamlit'), desc="Desc", link="/"),
Expand All @@ -55,12 +59,18 @@ def create_grid():
text-align: center;
transition: background-color 0.3s;
width: 200px; /* Set the width */
height: 200px; /* Set the height */
height: 250px; /* Set the height */
}
.card:hover {
background-color: lightgray;
}
.button-container {
display: flex;
justify-content: space-around;
margin-top: 10px;
}
"""

# Combine card_style CSS with the individual card contents
Expand All @@ -73,12 +83,17 @@ def create_grid():
<img src="{item["image"]}" width="150">
</a>
<div>{item["description"]}</div>
<div class="button-container">
<button class="btn btn-secondary">View</button>
<button class="btn btn-secondary">Edit</button>
<button class="btn btn-danger">Delete</button>
</div>
</div>
"""
cards.append(card_content)

# Create a GridSpec layout to arrange the cards in a grid
grid_spec = pn.GridSpec(sizing_mode="stretch_width", max_width=600)
grid_spec = pn.GridSpec(sizing_mode="stretch_width", max_width=800)

# Organize the cards in a matrix-like arrangement
num_columns = 3 # Number of columns in the matrix
Expand All @@ -91,6 +106,7 @@ def create_grid():
return grid_spec



def create_input_form():
input_form_widget = InputFormWidget(
name_input=pn.widgets.TextInput(name="Name"),
Expand Down Expand Up @@ -154,5 +170,5 @@ def button_callback(event):
return create_dashboard(event, input_form_widget, input_form)

input_form_widget.button_widget.on_click(button_callback)
created_apps = create_grid()
created_apps = create_grid_with_buttons()
return pn.Row(input_form, created_apps).servable()

0 comments on commit 910ae4a

Please sign in to comment.