Skip to content

A Flask extension for Spectrum javascript color picker

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

mrf345/flask_colorpicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flask_colorpicker

A Flask extension to add Spectrum jQuery color picker into the template, it makes adding and configuring multiple color pickers at a time much easier and less time consuming.

Install :

- With pip:

  • pip install Flask-Colorpicker

- From the source:

  • git clone https://github.com/mrf345/flask_colorpicker.git
  • cd flask_colorpicker
  • python setup.py install

Setup :

- Inside the Flask app:

from flask import Flask, render_template
from flask_bootstrap import Bootstrap
from flask_colorpicker import colorpicker
app = Flask(__name__)
Bootstrap(app)
colorpicker(app)

- inside the jinja template

{% extends 'bootstrap/base.html'}
{% block scripts %}
  {{ super() }}
  {{ colorpicker.loader() }}
  {{ colorpicker.picker(ids=[".cp"]) }}
{% endblock %}
{% block content %}
  <form class="verticalform">
    <input type="text" class="form-control cp" />
  </form>
{% endblock %}

Settings:

- Customize:

The accepted arguments to be passed to the colorpicker.picker() function are as follow:

def picker(self, ids=[".colorpicker"], # list of ids of element to assign colorpicker to
            default_color='rgb(0,0,255,0.5)', # default color to start with
            color_format='rgb', # color format to use
            showAlpha='true', # enable or disable transparency
            showInput='false', # display or hide color picker
            showButtons='false', # display or hide buttons
            allowEmpty='true'): # allow empty input

- Local source:

by default the extension will load spectrum plugin from a remote CDN. Although you can configure that to be locally through passing a list of two files .js and .css into the colorpicker module like such:

colorpicker(app=app, local=['static/js/spectrum.js', 'static/css/spectrum.css'])

The order in-which the items of list are passed is not of importance, it will be auto detected via file extension

Credit:

About

A Flask extension for Spectrum javascript color picker

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Stars

Watchers

Forks

Packages

No packages published