Skip to main content

a fast and simple micro-framework for small browser-based application

Project description

eui

a fast and simple micro-framework for small browser-based applications

example

Step 1:

create python file, main.py:

import eui
import webbrowser
import os


def say_hello(message):
    print('receive message from js:', message)
    eui.js('sayHello', message)


def startup_callback():
    # open UI file in browser
    webbrowser.open(os.getcwd() + '/static/index.html')


handlers = {
    'say_hello': say_hello
}

eui.start(handlers=handlers, startup_callback=startup_callback)

Step 2:

create UI file index.html in static folder:

<!DOCTYPE HTML>
<html>

<head>
   <meta charset="utf-8">
   <title>eui test</title>
   <script src="eui.js"></script>
   <script type="text/javascript">
      function sendMessage() {
         var message = document.getElementById('message').value;
         eui.py('say_hello', message);
      }

      function sayHello(message) {
         alert('receive message from py: ' + message);
      }

   </script>

</head>

<body>
   <input id="message">
   <button onclick="sendMessage()">Send</button>

</body>

</html>

Step 3:

run main.py snapshot: snapshot

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

eui-0.0.1.tar.gz (114.0 kB view hashes)

Uploaded Source

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