🔍 Code Extractor

class Extending_column

Maturity: 28

A Panel ReactiveHTML component that creates a simple div container with an extendable column layout, displaying a parameter value within an HTML template.

File:
/tf/active/vicechatdev/resources/py2html.py
Lines:
500 - 504
Complexity:
simple

Purpose

This class extends Panel's ReactiveHTML to create a custom HTML component that renders a div element with the class 'extend_col'. It's designed to display dynamic content through the 'parameter' attribute, which can be updated reactively. The component is useful for creating custom UI elements in Panel dashboards where you need a simple container that can display and update content dynamically based on parameter changes.

Source Code

class Extending_column(ReactiveHTML):
    parameter = param.Parameter()
    _template = """
    <div class="extend_col" id="extend_col">${parameter}</div>
    """

Parameters

Name Type Default Kind
bases ReactiveHTML -

Parameter Details

parameter: A generic param.Parameter that can hold any value to be displayed within the HTML template. This parameter is reactive, meaning changes to it will automatically update the rendered HTML. It can accept any Python object that can be converted to a string representation for display in the HTML div element.

Return Value

Instantiation returns an Extending_column object, which is a Panel ReactiveHTML component. This object can be added to Panel layouts and will render as an HTML div element. The object maintains reactive bindings between the parameter attribute and the rendered HTML, automatically updating the display when the parameter changes.

Class Interface

Methods

__init__(parameter=None, **params)

Purpose: Initialize the Extending_column component with optional parameter value and other Panel component parameters

Parameters:

  • parameter: Optional initial value for the parameter attribute (default: None)
  • **params: Additional keyword arguments passed to the ReactiveHTML parent class (e.g., width, height, css_classes, name)

Returns: An instance of Extending_column

Attributes

Name Type Description Scope
parameter param.Parameter A reactive parameter that holds the content to be displayed in the HTML div. Changes to this attribute trigger automatic re-rendering of the component. Can hold any Python object. class
_template str The HTML template string that defines the component's structure. Uses Panel's template syntax with ${parameter} for reactive binding. This is a class-level attribute that defines how the component renders. class

Dependencies

  • param
  • panel

Required Imports

import param
import panel as pn
from panel.reactive import ReactiveHTML

Usage Example

import param
import panel as pn
from panel.reactive import ReactiveHTML

class Extending_column(ReactiveHTML):
    parameter = param.Parameter()
    _template = """
    <div class="extend_col" id="extend_col">${parameter}</div>
    """

# Instantiate the component
extend_col = Extending_column(parameter='Hello World')

# Display in a Panel app
pn.extension()
app = pn.Column(extend_col)
app.servable()

# Update the parameter dynamically
extend_col.parameter = 'Updated content'

# Or use with other Panel components
extend_col2 = Extending_column(parameter=pn.widgets.TextInput(value='Interactive'))
pn.Row(extend_col, extend_col2).show()

Best Practices

  • Always initialize the parameter attribute when instantiating to avoid displaying empty content
  • The parameter can accept any object, but ensure it has a meaningful string representation for display
  • Use this component within a Panel application context (after calling pn.extension())
  • The component inherits all ReactiveHTML functionality, so you can use Panel's reactive programming patterns
  • The _template attribute uses ${parameter} syntax for reactive binding - changes to parameter automatically update the HTML
  • Consider adding custom CSS styling to the 'extend_col' class for better visual presentation
  • This component is best used as a building block for more complex custom Panel components
  • Remember that ReactiveHTML components need to be served through Panel's server or displayed using Panel's display methods

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class Extending_row 87.8% similar

    A Panel ReactiveHTML component that renders a parameter value inside a div element with the class 'extend_row'.

    From: /tf/active/vicechatdev/resources/py2html.py
  • class Clickable_header 56.1% similar

    A clickable header component that displays text as a hyperlink and tracks the number of times it has been clicked.

    From: /tf/active/vicechatdev/resources/py2html.py
  • class custom_tabulator 55.0% similar

    A custom extension of Panel's Tabulator widget that overrides the _patch method to handle data updates with special logic for filtering, sorting, and remote pagination scenarios.

    From: /tf/active/vicechatdev/panel_edits/custom_tabulator.py
  • class Study_progress_v1 52.9% similar

    A Panel ReactiveHTML component that displays study progress as a visual taskbar with completed and pending items represented by SVG icons.

    From: /tf/active/vicechatdev/resources/py2html.py
  • function _eval_panel 52.6% similar

    Evaluates and initializes a panel component (function, template, or panel object) within a Bokeh document context, handling different panel types and modifying the document accordingly.

    From: /tf/active/vicechatdev/patches/server.py
← Back to Browse