<jupyter_start><jupyter_text>vvapp.app_templates>  Ipyvuetify Jupyter application templates  Ideas* Inputs are a list of widgets* Outputs are a dict, with tab title and a function to generate an output with one argument, the input list* App Title is a string<jupyter_code># export

class App():
    def __init__(self, app_title='', inputs=[], outputs={}, *args, **kwargs):
        self.app_title = app_title
        self.inputs = inputs
        self.outputs = outputs

    def show(self):
        output_containers = [ipywidgets.Output() for i in self.outputs]

        nav_button = v.AppBarNavIcon(class_='mt-1 mb-1 mx-2', )

        progress_spinner = v.ProgressCircular(indeterminate=False,
                                              class_='mt-2 mb-2 mx-2')

        mybutton = v.Btn(class_='icon',
                         style_='min-width:100px',
                         color='primary',
                         children=[v.Icon(children=['mdi-check'])])

        cancel_button = v.Btn(class_='icon',
                              style_='min-width:100px',
                              color='error',
                              children=[v.Icon(children=['mdi-cancel'])])

        myinputs = v.Container(children=[
            *self.inputs,
            v.Row(children=[
                v.Col(width=6, children=[mybutton]),
                v.Col(width=6, children=[cancel_button])
            ])
        ])

        vnd = v.NavigationDrawer(v_model=True,
                                 absolute=True,
                                 right=False,
                                 style_='min-height=800px;',
                                 children=[
                                     v.Html(tag='div',
                                            class_="headline",
                                            children=["Configuration"]), myinputs
                                 ])


        def toggle_drawer(widget, event, data):
            vnd.v_model = not vnd.v_model

        def get_data(myinputs = self.inputs):
            return pd.DataFrame({'a':[1,2,3],'b':[2,3,4]})

        def inputs_complete(widget, event, data):
            vnd.v_model = not vnd.v_model
            progress_spinner.indeterminate = True
            try:
                df = get_data(myinputs)
                for j, i in enumerate(self.outputs):
                    output_containers[j].clear_output()
                    with output_containers[j]:
                        display(self.outputs[i](self.inputs))
                progress_spinner.indeterminate = False
            except:
                return

        nav_button.on_event('click', toggle_drawer)
        cancel_button.on_event('click', toggle_drawer)
        mybutton.on_event('click', inputs_complete)

        return v.Container(
            class_='mx-auto my-0 py-0',
            style_='',
            children=[
                v.Tabs(
                    background_color="primary",
                    style_='min-height:600px',
                    dark=True,
                    children=[
                        nav_button,
                        v.ToolbarTitle(class_='py-2 px-4', children=[self.app_title]),
                        *[v.Tab(children=[i]) for i in self.outputs.keys()],
                        *[v.TabItem(children=[i]) for i in output_containers],
                        v.Spacer(),
                        progress_spinner,
                    ]), vnd
            ])<jupyter_output><empty_output><jupyter_text>To Use The App Template, you must define the title of the app  (`app_title`), input configuration (`inputs`), and outputs (`outputs`).* `app_title` - a string formatted title for the app, to be displayed in the menu bar* `inputs` - a list of input widgets* `outputs` - a list of *functions*, with a single input - the list of inputsThe outputs are functions, because they will be evaluated and re-evaluated when the submit button in the configuration panel is pressed.<jupyter_code>def first_output(inputs):
    time.sleep(2)
    return v.Btn(children=["Input Text: "+inputs[0].v_model])

def second_output(inputs):
    time.sleep(2)
    return v.Btn(children=["Input Number: "+str(inputs[1].v_model)])

outputs = {'Tab1': first_output, 'Tab2': second_output}

app_title = "My Title"

inputs = [
    input_text(placeholder='Enter text here', label='Text Input', v_model='Some Text 1234!'),
    input_number(v_model=100, label='A Numeric Input')
]

App(inputs=inputs, outputs=outputs, app_title=app_title).show()
#hide
from nbdev.export import notebook2script 
notebook2script()<jupyter_output>Converted 00_inputs.ipynb.
Converted 01_outputs.ipynb.
Converted 02_app_templates.ipynb.
Converted index.ipynb.
{'fraction_non_alphanumeric': 0.11033460398136383, 'fraction_numerical': 0.010800508259212199, 'mean_word_length': 1.8062982768865121, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '60694', 'license': 'Apache-2.0', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1282, 'n_words': 294, 'path': '02_app_templates.ipynb', 'repo_name': 'radinplaid/vvapp', 'size': '4722'}