Coder Social home page Coder Social logo

blink's Introduction

Build Status

Blink

Blink allows you to easily bind jQuery-like events to your Python apps.

Dependencies

Python 2.6+ and tested on Python 3+

  • nose 1.1.2
  • yanc 0.2.3

Make Targets

  1. make install installs Blink locally in development mode.
  2. make uninstall removes Blink locally
  3. make test runs the unit test suite
  4. make clean removes any garbage files that usage and installation generates

Installing From Github

$: pip install git+git://github.com/wilhelm-murdoch/blink.git

Or, add the following line to a requirements.txt file:

-e git+ssh://[email protected]/wilhelm-murdoch/blink.git#egg=blink

Example

  from blink import blink

  @blink.bind('blink:event')
  def blinker_event(message):
    print message

  blink.trigger('blink:event', message='This is a message.')
  >>> 'This is a message.'

Or, create your own blink.Blink instance to pass throughout your application:

  import blink

  blinker = blink.Blink()

Methods

blink.bind

Bind a callback to the specified event.

  def callback(message):
    print message

  blink.bind('blink:event', callback)
  blink.trigger('blink:event', message='This is a message.')
  >>> 'This is a message.'

You can also use the blink.bind() method as a decorator:

  @blink.bind('blink:event')
  def callback(message):
    print message

  blink.trigger('blink:event', message='This is a message.')
  >>> 'This is a message.'

blink.unbind

Unbinds the specified callback from the specified event:

  blink.unbind('blink:event', callback)

However, if you wish to unbind all callbacks from a specified event, just leave out the callback parameter:

  blink.unbind('blink:event')

blink.trigger

Invokes all callbacks associated with the specified event name. You may pass arbitrary arguments through and they will be appear as *args and or **kwargs within each associated callback.

  from blink import blink

  @blink.bind('blink:event')
  def blinker_event(*args, **kwargs):
    print args, kwargs

  blink.trigger('blink:event', 1, 2, 3, 4, foo=True, bar=False)
  >>> (1, 2, 3, 4) {'foo': True, 'bar': False}

blink's People

Stargazers

Trevor Joynson avatar

Watchers

 avatar

Forkers

dagoof

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.