Giter VIP home page Giter VIP logo

trame-vuetify's Introduction

trame-vuetify: Material Design widgets for trame

Test and Release

Trame-vuetify extend trame widgets and ui with all the beautiful Vuetify UI components. Vuetify is a UI Library with beautifully handcrafted Material Components. No design skills required โ€” everything you need to create amazing applications is at your fingertips.

This package is not supposed to be used by itself but rather should come as a dependency of trame. For any specificity, please refer to the trame documentation.

Installing

trame-vuetify can be installed with pip:

pip install --upgrade trame-vuetify

Usage

The Trame Tutorial is the place to go to learn how to use the library and start building your own application.

The API Reference documentation provides API-level documentation.

The Vuetify website is very well made for exploring components and understanding components' parameters and controls, while a reference to our wrapper API is available here.

The way trame translate Vue templates into plain Python code is by doing the following.

Material Design Widgets

First you need to import the vuetify module so you can instantiate the various Material Components like illustrated below. Moreover, in the documentation the component names use dashes as separators while in Python we use the Camelcase notation for the class name.

from trame.widgets import vuetify

# <v-btn>Hello World</v-btn>
btn = vuetify.VBtn("Hello World")

Boolean attributes

Implicit attribute values must be made explicit in Python by assigning True to them.

# <v-text-field disabled />
vuetify.VTextField(disabled=True)

Dash and colon separators

Any special characters (- and :) become _ in Python.

# <v-text-field v-model="myText" />
vuetify.VTextField(v_model=("myText",))

Events

Events in vue are prefixed with a @ but in Python we declare them the same way we declare regular attributes.

def runMethod():
    pass

# <v-btn @click="runMethod" />
vuetify.VBtn(click=runMethod)

License

trame-vuetify is made available under the MIT License. For more details, see LICENSE This license has been chosen to match the one use by Vuetify which is instrumental for making that library possible.

Community

Trame | Discussions | Issues | RoadMap | Contact Us

Enjoying trame?

Share your experience with a testimonial or with a brand approval.

trame-vuetify's People

Contributors

actions-user avatar jourdain avatar psavery avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trame-vuetify's Issues

VAppBar app property deprecated in Vuetify 3

Describe the bug
In trame.ui.vuetify3, there are the predefined Layouts such as SinglePageLayout. For example, in the definition of the VAppBar there is a parameter app=True. However, in vuetify3, this property was removed. See Vuetify3 API. As it stands, this parameter seemingly does nothing, yet it is used throughout the SinglePageLayout class.

with self:
with vuetify.VAppBar(app=True) as toolbar:
self.toolbar = toolbar

self.content = vuetify.VMain()
with vuetify.VFooter(app=True, classes="my-0 py-0") as footer:
self.footer = footer

self.app_layout = app_layout
with vuetify3.VAppBar(app=True) as toolbar:
self.toolbar = toolbar

with vuetify3.VFooter(
app=True, classes="my-0 py-0", border=True
) as footer:

To Reproduce

N/A

Code

N/A

Expected behavior

N/A

Screenshots

N/A

Platform:

Device:

  • Desktop
  • Mobile

OS:

  • Windows
  • MacOS
  • Linux
  • Android
  • iOS

Browsers Affected:

  • Chrome
  • Firefox
  • Microsoft Edge
  • Safari
  • Opera
  • Brave
  • IE 11

VDataTable doesn't work with client_type vue3

Issue

VDataTable doesn't work with client_type vue3

See below the source code, in the dedicated paragraph. It is a simplified version of 00_dataframe-table.py.

It works with CLIENT_TYPE = 'vue2'. It does not with CLIENT_TYPE = 'vue3'.

Inspecting the source code on the client reveals that the vdatable is not interpreted.

vue2 :-) vue3 :-(
<div class="v-data-table elevation-1 ma-4 .... <vdatatable class="elevation-1 ma-4"

Question

  • Is this related with the fact that vdatatable migrates from lab to common components ?
  • How to make vdatatable work with vue3 ?

Environment

aiohttp==3.9.1
aiosignal==1.3.1
altair==5.2.0
attrs==23.1.0
certifi==2023.11.17
charset-normalizer==3.3.2
contourpy==1.2.0
cycler==0.12.1
fonttools==4.46.0
frozenlist==1.4.0
idna==3.6
Jinja2==3.1.2
jsonschema==4.20.0
jsonschema-specifications==2023.12.1
kiwisolver==1.4.5
MarkupSafe==2.1.3
matplotlib==3.8.2
multidict==6.0.4
numpy==1.26.2
packaging==23.2
pandas==2.1.4
Pillow==10.1.0
platformdirs==4.0.0
pooch==1.8.0
pyparsing==3.1.1
python-dateutil==2.8.2
pytz==2023.3.post1
pyvista==0.42.3
referencing==0.32.1
requests==2.31.0
rpds-py==0.16.2
scooby==0.9.2
six==1.16.0
toolz==0.12.0
trame==3.3.0
trame-client==2.13.0
trame-server==2.12.1
trame-vega==2.1.0
trame-vtk==2.6.2
trame-vuetify==2.3.1
tzdata==2023.4
urllib3==2.1.0
vtk==9.3.0
wslink==1.12.4
yarl==1.9.3

Sources

from trame.app import get_server
from itertools import cycle

import altair as alt
import pandas as pd
import numpy as np

# -----------------------------------------------------------------------------
# Trame setup
# -----------------------------------------------------------------------------
CLIENT_TYPE = "vue3"

if CLIENT_TYPE =="vue2":
    from trame.widgets import vuetify2 as vuetify
    from trame.ui.vuetify2 import SinglePageLayout
else:
    print("vue3")
    from trame.widgets import vuetify3 as vuetify
    from trame.ui.vuetify3 import SinglePageLayout

server = get_server(client_type=CLIENT_TYPE)
state, ctrl = server.state, server.controller

# --------------------------------------------------------------------------------
# Making dataframe
# --------------------------------------------------------------------------------
np.random.seed(4)
DATA_FRAME = None


def fetch_data(samples=15):
    global DATA_FRAME
    deltas = cycle(
        [
            pd.Timedelta(weeks=-2),
            pd.Timedelta(days=-1),
            pd.Timedelta(hours=-1),
            pd.Timedelta(0),
            pd.Timedelta(minutes=5),
            pd.Timedelta(seconds=10),
            pd.Timedelta(microseconds=50),
            pd.Timedelta(microseconds=10),
        ]
    )
    dummy_data = {
        "id": range(samples),
        "date_time_naive": pd.date_range("2021-01-01", periods=samples),
        "apple": np.random.randint(0, 100, samples) / 3.0,
        "banana": np.random.randint(0, 100, samples) / 5.0,
        "chocolate": np.random.randint(0, 100, samples),
        "group": np.random.choice(["A", "B"], size=samples),
        "season": np.random.choice(
            ["Spring", "Summer", "Fall", "Winter"], size=samples
        ),
        "date_only": pd.date_range("2020-01-01", periods=samples).date,
        "timedelta": [next(deltas) for i in range(samples)],
        "date_tz_aware": pd.date_range(
            "2022-01-01", periods=samples, tz="Asia/Katmandu"
        ),
    }
    DATA_FRAME = pd.DataFrame(dummy_data)
    return DATA_FRAME


fetch_data()

# --------------------------------------------------------------------------------
# Preparing table
# --------------------------------------------------------------------------------
header_options = {"apple": {"sortable": False}}
headers, rows = vuetify.dataframe_to_grid(DATA_FRAME, header_options)

table = {
    "headers": ("headers", headers),
    "items": ("rows", rows),
    "v_model": ("selection", []),
    "search": ("query", ""),
    "classes": "elevation-1 ma-4",
    "multi_sort": True,
    "dense": True,
    "show_select": True,
    "single_select": False,
    "item_key": "id",
}

# --------------------------------------------------------------------------------
# GUI
# --------------------------------------------------------------------------------

with SinglePageLayout(server) as layout:
    layout.title.set_text("Vuetify table example")
    with layout.toolbar:
        vuetify.VSpacer()
        vuetify.VTextField(
            v_model=("query",),
            placeholder="Search",
            dense=True,
            hide_details=True,
            prepend_icon="mdi-magnify",
        )

    with layout.content:
        vuetify.VDataTable(**table)

# -----------------------------------------------------------------------------
# Start server
# -----------------------------------------------------------------------------

if __name__ == "__main__":
    server.start()

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.