Code Monkey home page Code Monkey logo

test-ipyvuetify's Introduction

ipyvuetify

Version Version Conda Version Binder

Jupyter widgets based on vuetify UI components which implement Google's Material Design Spec with the Vue.js framework.

Installation

To install use pip:

$ pip install ipyvuetify
$ jupyter nbextension enable --py --sys-prefix ipyvuetify

# for Jupyter Lab
$ jupyter labextension install jupyter-vuetify

For a development installation (requires npm),

$ git clone https://github.com/mariobuikhuizen/ipyvuetify.git
$ cd ipyvuetify
$ pip install -e .
$ jupyter nbextension install --py --symlink --sys-prefix ipyvuetify
$ jupyter nbextension enable --py --sys-prefix ipyvuetify

Usage

For examples see the example notebook.

The Vuetify documentation can be used to find all available components and attributes (in the left side bar or use the search field). Ipyvuetify tries to stay close to the Vue.js and Vuetify template syntax, but there are some differences:

Description Vuetify ipyvuetify
Component names are in CamelCase and the v- prefix is stripped <v-list-tile .../> ListTile(...)
Child components and text are defined in the children traitlet <v-btn>text <v-icon .../></v-btn> Btn(children=['text', Icon(...)])
Flag attributes require a boolean value <v-btn round ... Btn(round=True ...
Attributes are snake_case <v-menu offset-y .. Menu(offset_y=True ...
The v_model attribute (value in ipywidgets) contains the value directly <v-slider v-model="some_property" ... Slider(v_model=25...
Event listeners are defined with on_event <v-btn @click='someMethod()' ... button.on_event('click', some_method)
def some_method(widget, event, data):
Regular HTML tags can made with the Html class <div>...</div> Html(tag='div', children=[...])
The attributes class and style need to be suffixed with an underscore <v-btn class="mr-3" style="..." > Btn(class_='mr-3', style_='...')

Advanced usage

.sync

The .sync property modifier functionality can be achieved by using an event named:
update:[propertyNameInCamelCase].

Vuetify:
<v-navigation-drawer :mini-variant.sync=...
ipyvuetify:
drawer = v.NavigationDrawer(mini_variant=True, ...)

def update_mini(widget, event, data):
    drawer.mini_variant = data`

drawer.on_event('update:miniVariant', update_mini)

(scoped) slots

Vuetify:
<v-menu>
  <template slot:activator="{ on }">
    <v-btn v-on="on">...</v-btn>
  </template>
  <v-list>
    ...
  </v-list>
</v-menu>
ipyvuetify:
Menu(v_slots=[{
    'name': 'activator',
    'variable': 'x',
    'children': Btn(v_on='x.on', children=[...])
}], children=[
    List(...)
])

For non scoped slots 'scope': 'x' and v_on can be omitted.

Alternate usage

For a more web development centric way of development and a closer match to the Vue/Vuetify api, VuetifyTemplate can be used. See the example or Binder.

Make a sub class of VuetifyTemplate, define your own traitlets and set a template string. The traitlets will be accessible from the template as if they were in a vue-model. Methods can be called by defining a method with a prefix vue_ e.g. def vue_button_click(self, data) and calling it from the template e.g. @click="button_click(e)".

test-ipyvuetify's People

Contributors

mariobuikhuizen avatar maartenbreddels avatar jovanveljanoski avatar michamucha avatar dependabot[bot] avatar

Watchers

James Cloos avatar

test-ipyvuetify's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.