Skip to main content

Pythonic Vue.js

Project description




Install

using pip

pip install pyvuejs



Usage

start server by main.py file in project directory

python .\main.py



Config editing guide

  • config file has 2 dictionaries
    • pages: information of apps
    • server: server host, port information
pages = {
    "sample": {
        # entry, vue, url are required
        "entry": "src/app/main.py",
        "vue": "src/app/index.vue", 
        "url": "/sample",
        "title": "sample!"
    }
}

server = {
    # host and port are not required
    "host": "0.0.0.0",
    "port": 8080
}



VUE editing guide

same as vue.js, can support by linting

  • for now, template, style blocks are supported
<template>
    <div id="sample">
        <p>{{ text }}</p>
    </div>
</template>

<style>
    div#sample {
        width: 100%;
        height: 100%;
    }
</style>



App model editing guide

  • Model defines in main.py in app directory
  • same syntax as Vue.js javascript defines
  • get object by export property
from pyvuejs import Vue

class sample():
    def data(self):
        # return as dictionary
        return {
            "text": "hello, pyvuejs!"
        }

    def methods(self):
        def change_text(self):
            self.text = "I'm changed!"

        # return as dictionary
        return {
            "change_text": change_text
        }

# "__export__" must be defined
__export__ = Vue.createApp(sample).mount("#sample")


Component editing guide

  • component defines in component directory
  • name of python file is not important
  • components are registered as global component
  • get object by export property
from pyvuejs import Vue

class sample():
    # props are list only
    props = [ "label" ]
    # template is required
    template = "<label>{{ label }}</label>"

# "__export__" must be defined
__export__ = Vue.component("sample-label", sample)



Todo

  • method, created, mounted of component


License

pyvuejs is MIT license



Release History

  • V 0.1.0 [2020/07/17]
    • initial commit

  • V 0.2.0 [2020/07/18]

    • enable componenting
    • multi locational data binding
    • add computed binding
    • dataSession
  • V 0.2.1 [2020/07/19]

    • change decoration as "@method", "@compute"
    • multi locational strategy changed to IP from idGeneration
  • V 0.2.2 [2020/07/19]

    • bug fixes
    • parsing errors if model block is empy
  • V 0.2.2.Rev1 [2020/07/19]

    • bug fixes
    • show default favicon correctly
  • V 0.2.2.Rev2 [2020/07/20]

    • remove "Variable" model
    • change component's default size to 100% of parent
  • V 0.2.2.Rev3

    • depricated
    • revoke changes and upgrade to Rev4
  • V 0.2.2.Rev4 [2020/07/20]

    • variables can upload to session by adding ":session" when it's definition
    • session variables can be used in template by calling "sesssion" dictionary
  • V 0.2.2.Rev5 [2020/07/20]

    • change component parsing logic
    • component tag format changed to "<component name="[componentName]" />"
  • V 0.2.2.Rev6 [2020/07/20]

    • move multi locational strategy to initial viewpoints
    • add event bind decoration as "@event"
      • currently only support for "load", "show" event
    • enabled to import python modules in app's directory
      • base directory of modules is plugins
  • V 0.2.2.Rev7 [2020/07/20]

    • change pyvuejs object to class with constructor
    • bug fixed
      • pyvuejs calls other view's models also

  • V 0.3.0 [2020/07/21]

    • change backend server to flask from quart
    • changes in requirements.txt
    • bug fixed
      • session datas are not sync from view to model
  • V 0.3.0.Rev1 [2020/07/21]

    • bug fixed
      • session datas changed in vue model are not sync to model
  • V 0.3.1 [2020/07/21]

    • cli changed
      • "init" command is available from module cli
      • "run", "stop", "create", "remove" commands are moved to manage.py
    • logger added
      • server logs server-side loggings only
      • client(web) logs client-side loggings only
  • V 0.3.2 [2020/07/22]

    • standalone mode added
      • use PySide2 WebEngineView as UI
    • "logging" option added
      • if enable, server log to console
      • if not, server doesn't log to console
  • V 0.3.2.Rev1 [2020/07/22]

    • webview window can be invoked from model with name webview
  • V 0.3.2.Rev2 [2020/07/22]

    • bug fixed
      • multiple session datas upload correctly
  • V 0.3.3 [2020/07/22]

    • bug fixed
      • model's native functions got erros during interpreting
    • add pyvue-component tag and change component to pyvue-component
      • format change to normal html format, "<pyvue-component endpoint="componentName">"
    • webview attribute changed to appView
    • creating a new WebView window is available from model
  • V 0.3.3.Rev1 [2020/07/22]

    • bug fixed
      • decorator text was miss-parsed
  • V 0.3.4 [2020/07/22]

    • change UI module from PySide2 to pycefsharp
      • appView can be invoked, too

  • V 0.4.0 [2020/07/28]

    • change structure of project
      • project now managed by app
        • app has single view.html file
        • app can has multiple models in models.py
      • project information managed by .config file
    • cli changed
      • cli provides as follows
        • create-project
        • create-app
        • remove-app
        • start
        • stop
  • V 0.4.1 [2020/07/29]

    • remove unnecessary requirements
    • change session refresh interval from 0.5s to 0.1s
  • V 0.4.2 [2020/07/29]

    • change webview frontend from pycefsharp to pywebview
  • V 0.4.3 [2020/07/29]

    • change webview frontend from pywebview to PySide2
    • child window appears properly
  • V 0.5.0 [2020/08/10]

    • BIG CHANGES!
      • server changes to bottle
      • change project structure more likely to Vue.js
      • separate cli to pyvuejs-cli
  • V 0.5.1 [2020/08/10]

    • remove unsed requirement bottle-websocket
    • set server config by default if not configured
    • add default_app parameter to standalone server method
    • add show_messagebox method to webview
      • not receive result now

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvuejs-0.5.1.tar.gz (106.4 kB view details)

Uploaded Source

Built Distribution

pyvuejs-0.5.1-py3-none-any.whl (104.8 kB view details)

Uploaded Python 3

File details

Details for the file pyvuejs-0.5.1.tar.gz.

File metadata

  • Download URL: pyvuejs-0.5.1.tar.gz
  • Upload date:
  • Size: 106.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7

File hashes

Hashes for pyvuejs-0.5.1.tar.gz
Algorithm Hash digest
SHA256 0769733d977d3224b6c32b6fd6de144240fff10e7cce7d3c04e8da44d02d614d
MD5 7b0181b7ebd4f8353cd7c67de1a4033c
BLAKE2b-256 be0e26b862f80d1bc29c91d3d3c0880ecc0ed9c68c703058e0211b8eaa30a050

See more details on using hashes here.

File details

Details for the file pyvuejs-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: pyvuejs-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 104.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.7

File hashes

Hashes for pyvuejs-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94cb888c1ab7493a5701ae18f15319242322ac54f97db9a9e0f1c401d576e3db
MD5 ea8ec1822fd27eec5622f6fe5d3272e3
BLAKE2b-256 8ec020de3836f64c25ac422f7412b69dd9e823808ebbcada977cc045cd6112b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page