Code Monkey home page Code Monkey logo

bootwrap's Introduction

Python Bootwrap

Continuous Integration Status Code Coverage Percentage Codacy Badge Project License Project Documentation

Bootwrap is a Python library for rapid developing of web-based user interfaces (WebUI). It helps creating WebUI using Python code only and can be used in conjunction with different web-development frameworks such as Flask. Under the hood, this library wraps one of the most popular front-end toolkit Bootstrap.

This library would be useful for developers and data scientists who wish to build interactive web-application without crafting HTML, CSS and Javascript.

As a showcase of what this library is capable of please check the documentation. The entire documentation web interface is created using the Bootwrap.

Installing

Install and update using pip:

~$ pip install -i https://test.pypi.org/simple/ bootwrap

Please note, The Bootwrap is currently deployed using TestPyPI โ€“ which is a separate instance of the Python Package Index. This allows us to test distribution before moving this package to the real index

A Simple Example

The following code will care three pages application with the top-level menu bar for navigations.

from flask import Flask, Markup
from bootwrap import Page, Menu, Image, Anchor, Button, Text

# Both 'logo.png' and 'favicon.ico' are stored in 'docs' folder
app = Flask(__name__, static_folder='docs', static_url_path='')

class MyMenu(Menu):
    def __init__(self):
        super().__init__(
            logo=Image('logo.png', width=32, alt='Logo'),
            brand=Text('Bootwrap').as_strong().as_light().add_classes('ml-2'),
            anchors=[
                Anchor('Home').link('/'),
                Anchor('About').link('/about')
            ], 
            actions=[
                Button('Sign In').as_outline().as_light().link('/signin')
            ]
        )

class MyPage(Page):
    def __init__(self, content):
        super().__init__(
            favicon = 'favicon.ico',
            title='Hello World Application',
            menu=MyMenu(),
            content=content
        )

@app.route('/')
def home():
    return Markup(MyPage(content=[Text('Home').as_heading(1)]))

@app.route('/about')
def about():
    return Markup(MyPage(content=[Text('About').as_heading(1)]))

@app.route('/signin')
def signin():
    return Markup(MyPage(content=[Text('Sign In').as_heading(1)]))

if __name__ == '__main__':
    app.run(debug=True)

Use the following command to launch the application.

$ flask run
  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

The result should look like.

Contributing

For information on how to set up a development environment and how to make a contribution to Bootwrap, see the contributing guidelines.

Links

bootwrap's People

Contributors

aitorres avatar codacy-badger avatar mmgalushka avatar

Watchers

 avatar

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.