Coder Social home page Coder Social logo

codelv / enaml-web Goto Github PK

View Code? Open in Web Editor NEW
99.0 15.0 17.0 42.4 MB

Build interactive websites with enaml

Home Page: https://codelv.com/projects/enaml-web/

License: MIT License

Python 96.16% Makefile 0.25% C 3.59%
enaml lxml python web-components web

enaml-web's Issues

django integration

Is there any way to integrate this with django currently?

If not, can I use this to spit out static html?

Docs

Better docs than the readme would be nice.

Launching a func when rendering component for the time and without end user action

Hello,
I would like to launch a a func for collecting datas from the DB and assigning to component attribute at widget initialization.
Currently, I have this working by launching my function in my main.py file in the tornado RequestHandler. I would like to make my component containing the maximum code it use.

enamldef MyComponent(Html):
    attr datas

    async func get_datas_from_db(**parameters):
        return datas

    IOLoop.current().add_callback(get_datas_from_db, parameters) # Here is the syntax error

   Conditionnal:
        condition << datas is not None
       Looper:
            ...........

I haven't seen something like on_prepare which could be usefull (prepare)

Any idea ?

Regards

Idea: Streamed HTML

Streamed HTML as discussed here: The weirdly obscure art of Streamed HTML looks nice for performance enhancement.

I got an idea to have something similar in enaml-web but don't know if realistic:
I think we can add a "compute_order"property to Tag (default to 1). At the first pass for render, the engine will only compute Nodes (Tags) with compute_order=1 and send result to the browser. A second pass is done for rendering nodes with "compute_order=2". New nodes and updates are send to the client with websocket.

Do you thing it can be a good approach ?

Do you think it can be achieved without rewriting all enaml ?

Adding observe event on a variable inside enaml file

Edit: The above question solution will be useless in my case because I want an async function to be run when observed value change and I think I'll not able to call such a function inside enaml block.


I would like to create a component with business logic embedded.

    Select: 
        self.observe('value', test)
        func test(self, change):
            pass
        Option:
            value = "0"
            text = "Zero"
        Option:
            value = "1"
            text = "One"

A syntax error is raised.

Any idea if it's possible ?

How to alternate classes ?

Been trying out enaml I can see it has conditionals is this the best way to do this something like this ?

conditional << 2 % index
conditional:
    Div:
        cls = 'one'
conditional:
    Div:
        cls = 'two'

or is there a way to do this in a single line ?

How to implement a file upload button?

I'm interested in a very simple page that just provided an upload button.

If this was desktop Enaml I guess I would follow these steps:

  1. Window with a button
  2. On button click open a FileDialog widget
  3. Get the local file path when the widget closes
  4. Use Python's file to get the bytes and then "do stuff" with bytes.

Are there similar widgets in Enable-Web? How might you go about doing this?

Multi-pages website: Best pattern

Hello.

I'm trying to setup a muti-pages website (was websocket only before).

My Base page is structured like this:

# index.enaml

enamldef Item(Div):
    attrs item_ref

enamldef Statistics(Div):
    attrs datas

enamldef Home(Div):
    attrs datas

enamldef Index(MaterializePage): index:

    Block:
        block = parent.header
       .........
    Block: main_content:
        block = parent.content
        Home:
            pass
# main.py

class IndexHandler(RequestHandler):
    async def get(self):
        path = self.request.path
        page = path.split('/)[1]

        if page == 'home':
                datas = await Model_A().get_datas()
        if page == 'statistics':
                datas = await Model_B().get_datas()
        
        index = Index()
       #
       # Here, how to change the content of index.main_content with datas set to the choosed child datas attribute
       #    
        self.write(index.render())

I was wondering if there is a solution for changing the main_content child widget with specific attributes datas from python file. This file handle request.

Do you have any suggestion about other patterns to accomplish that ?

Regards

NotImplementedError with file observer

app.deferred_call(self.queue_reload)

from web.impl.lxml_app import LxmlApplication
import signal

def main():
    app = LxmlApplication()
    app.init_reloader()
    signal.pause()

results in

Detected changes in ./index.enaml, scheduling reload...
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/dev/.pyenv/versions/3.6.5/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/dev/.local/share/virtualenvs/quiz_backend-RJ5HRaNa/lib/python3.6/site-packages/watchdog/observers/api.py", line 199, in run
    self.dispatch_events(self.event_queue, self.timeout)
  File "/home/dev/.local/share/virtualenvs/quiz_backend-RJ5HRaNa/lib/python3.6/site-packages/watchdog/observers/api.py", line 368, in dispatch_events
    handler.dispatch(event)
  File "/home/dev/.local/share/virtualenvs/quiz_backend-RJ5HRaNa/lib/python3.6/site-packages/watchdog/events.py", line 322, in dispatch
    self.on_any_event(event)
  File "/home/dev/.local/share/virtualenvs/quiz_backend-RJ5HRaNa/lib/python3.6/site-packages/web/impl/lxml_app.py", line 83, in on_any_event
    app.deferred_call(self.queue_reload)
  File "/home/dev/.local/share/virtualenvs/quiz_backend-RJ5HRaNa/lib/python3.6/site-packages/enaml/application.py", line 278, in deferred_call
    raise NotImplementedError
NotImplementedError

error using tornado for data-binding demo

Hi, I'm getting this error in the browser console when running the data binding demo using tornado. Any ideas where to start looking? Shall I check the javascript or do you think it's tornado?

VM47:164 WebSocket connection to 'ws://localhost:8888/' failed: Error during WebSocket handshake: Unexpected response code: 200
WrappedWebSocket @ VM47:164

Thanks

running multiple instances

Hi @frmdstryr could you give some comments on how to serve a site with a different instance of the model for each browser window? When I was testing enaml-web a couple of months ago, every new browser window would show the same view when changes were made in one view. Perhaps this is just my lack of understanding of tornado?

Enaml-web and Django

Hello,
I'll have to create a project. I'm hesitating using enaml-web with Django. Enaml-web is so fun !!

I have seen the question has already been asked #8.
You have answered

Yes. You can create a LxmlApplication which has no server component and then render pages for any application (django, flask, etc..) or save them to a file to make a static site.

You talked about LxmlApplication. Haven't see any code relating to that in master.

Could you give me some hints and how to do this coupling ?

Regards

Django integration 2: How to persist Atom object between user request

Hello !!!
I'm trying to integrate Enaml-web and Django using the CACHE system used ind dataframe example here:

CACHE[viewer.id] = viewer

I don't achieve to persist this object between users interactions, in other works, after the answer has been sent back to the user browser.

Any idea to achieve that ?

Here is my simple view:

from django.http import HttpResponse

from web.core.app import WebApplication
import enaml

with enaml.imports():
    from .index import Index
enaml_web_app = WebApplication()



def testview(request):
    # I would like to cache index to be able to retrieve it later.
    index = Index()
    return HttpResponse(index.render())

Use enaml-web as markup language

THIS might sound a little annoying,

I'm trying to use it as a markup language, because i'm sick of writing HTML.

I don't want to deal with the hassle of running python on web browser or using web-sockets to communicate with server.

I just want a better way to write UI than HTML

Related SO question

Insertion does not retain order

Ex this does not retain the order of 'Home', *menu_items, 'Contact

Ul:
  Li:
    text = 'Home'
  Looper:
    iterable << menu_items
    Li:
      text = loop_item
  Li:
     text = 'Contact'

When a new item is added to the menu_items it is appended after last item ('Contact' in the example) when it should be inserted in proper order. To support this the child_added event must include the index where it should be inserted.

Error on pip install

pip install git+https://github.com/codelv/enaml-web.git
Collecting git+https://github.com/codelv/enaml-web.git
  Cloning https://github.com/codelv/enaml-web.git to /private/var/folders/mn/wzflzlvn1ngg1vtyzd0s4sgc0000gn/T/pip-f734ms7a-build
Collecting distribute (from enaml-web==0.1.0)
  Using cached distribute-0.7.3.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/mn/wzflzlvn1ngg1vtyzd0s4sgc0000gn/T/pip-build-4lkpjyuv/distribute/setuptools/__init__.py", line 2, in <module>
        from setuptools.extension import Extension, Library
      File "/private/var/folders/mn/wzflzlvn1ngg1vtyzd0s4sgc0000gn/T/pip-build-4lkpjyuv/distribute/setuptools/extension.py", line 5, in <module>
        from setuptools.dist import _get_unpatched
      File "/private/var/folders/mn/wzflzlvn1ngg1vtyzd0s4sgc0000gn/T/pip-build-4lkpjyuv/distribute/setuptools/dist.py", line 7, in <module>
        from setuptools.command.install import install
      File "/private/var/folders/mn/wzflzlvn1ngg1vtyzd0s4sgc0000gn/T/pip-build-4lkpjyuv/distribute/setuptools/command/__init__.py", line 8, in <module>
        from setuptools.command import install_scripts
      File "/private/var/folders/mn/wzflzlvn1ngg1vtyzd0s4sgc0000gn/T/pip-build-4lkpjyuv/distribute/setuptools/command/install_scripts.py", line 3, in <module>
        from pkg_resources import Distribution, PathMetadata, ensure_directory
      File "/private/var/folders/mn/wzflzlvn1ngg1vtyzd0s4sgc0000gn/T/pip-build-4lkpjyuv/distribute/pkg_resources.py", line 1518, in <module>
        register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
    AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/mn/wzflzlvn1ngg1vtyzd0s4sgc0000gn/T/pip-build-4lkpjyuv/distribute/

Support for Python 3?

I noticed that the examples all use cyclone, which is Python2 only. Is it possible to use enaml-web with any Python3 web servers?

Plotly example: How to update the graph in an enaml-web way ?

Do you think it's possible to replace a plotly graph with websocket by just modifyng the traces and display attribute of PlotlyGraph component ?
It doesn't works for me. Plotly.js doesn't seems to react when data-traces are modified in the DOM.

Any idea to do that without writing js for collecting all datas from Plotly div attribute and lauching a Plotly.react command ?

SVG node

Better support for svg would be nice

Meta tag property ?

class Meta(Tag):

Trying to add open graph data but I cant use property I assume it needs to be added to the above link ?

Or perhaps not as property does not appear to be a standard tag, so would I need to create a new element type ? and if so any docs on how to go about doing that ?

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.