Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 976 Categories, Downloaded 29.973.815 Times

nmevent 0.3.2

Company: Jan Mil?“A­k
Date Added: October 24, 2013  |  Visits: 176

nmevent

Report Broken Link
Printer Friendly Version


Product Homepage
Download (16 downloads)



This is a Python module :mod:`nmevent`, simple C#-like implementation of<br />the Observer pattern (http://en.wikipedia.org/wiki/Observer_pattern).<br />It's main purpose and goal is to allow developers to use events<br />with C#-like syntax in their Python classes.<br /><br />=============<br />Usage example<br />=============<br /><br />The most straightfoward way to use :mod:`nmevent` is this:<br /><br />>>> import nmevent<br />>>> class ExampleClass(object):<br />... def __init__(self):<br />... self.event = nmevent.Event()<br />...<br />... def do_something(self):<br />... self.event(self)<br />...<br />>>> def handler(sender, **keywords):<br />... print "event occured"<br />...<br />>>> example = ExampleClass()<br />>>> example.event += handler<br />>>> example.do_something()<br />event occured<br /><br />It should be noted, that event doesn't necessarily need to be an object<br />attribute. :class:`Event` instance is basically just a callable object that<br />works as a sort of "dispatch demultiplexer".<br /><br />This usage, however, isn't very C#-like. In C#, events are declared in class<br />scope and that's why the :class:`Event` class also supports the descriptor<br />protocol (you can use the same way you use the built-in ``property`` object).<br /><br />>>> from nmevent import Event<br />>>> class ExampleClass(object):<br />... event = Event()<br />...<br />... def _do_something(self):<br />... self.event()<br />...<br />>>> def handler(sender, **keywords):<br />... pass<br />...<br />>>> example = ExampleClass()<br />>>> example.event += handler<br /><br />Perhaps this looks even more straightfoward than instantiating :class:`Event`<br />in object's constructor, but there's actually lot more going on under hood this<br />time.<br /><br />Finally, there is the :class:`Property` descriptor and the associated<br />:func:`nmproperty` function decorator, which work very much like the built-in<br />``property`` object and decorator, except it can optionally call a callback<br />function if the property's value changes after calling the setter function. It<br />can work in tandem with the :func:`with_events` class decorator, which<br />decorates the class with property change events and connects them to the<br />instances of :class:`Property` class. It also creates events for the built-in<br />``property`` objects, but you have to raise the events yourself in the setter<br />function or elsewhere.<br /><br />>>> @nmevent.with_events<br />... class ExampleClass(object):<br />... @nmevent.nmproperty<br />... def x(self):<br />... return self._x<br />...<br />... @x.setter<br />... def x(self, value):<br />... self._x = value<br />...<br />... @property<br />... def y(self):<br />... return self._y<br />...<br />... @y.setter<br />... def y(self, value):<br />... old_value, self._y = self._y, value<br />... self.y_changed(old_value = old_value)<br />...<br />... def __init__(self):<br />... self._x = None<br />... self._y = None<br />...<br />>>> def handler(sender, **keywords):<br />... print "x changed"<br />...<br />>>> example = ExampleClass()<br />>>> example.x_changed += handler<br />>>> example.x = 10 # handler gets called<br />x changed

Requirements: No special requirements
Platforms: *nix, Linux
Keyword: Builtinproperty Class Classevent Classproperty Clike Decorator Events Exampleclassgtgtgt Exampleclassobject Function Handlersender Init Keywords Print Property Python Self X Self Y
Users rating: 0/10

License: Freeware Size: 81.92 KB
USER REVIEWS
More Reviews or Write Review


NMEVENT RELATED
Miscellaneous  -  Property decorator for python 2.4
Defining a property involves the definition of nested functions for one or more of fget,fset,fdel. The decorator probes the decorated function, captures its locals() just before it returns and looks for the names "fget", "fset" and "fdel". The...
 
Business  -  Clara 3.0
Clara is a help-documentation tool for C++ or java developers. Basically she paints a diagram - a clara diagram - from a class. With clara you can visualize your class as if it were a chip with pins for input - representing the input parameters...
194.56 KB  
Miscellaneous  -  Indent Python code, giving block-closing comments 1.0
This script contains a class and a main program that perform three related (though complimentary) formatting operations on Python programs. When called as "pindent -c", it takes a valid Python program as input and outputs a version augmented with...
 
Miscellaneous  -  Finding the value passed to a function by name 1.2
Sometimes inside a decorator that creates a function with a generic (*args, **kwargs) signature, you want to access a value passed for a particular parameter name to a wrapped function, but don't know whether that value will be passed as a...
 
Libraries  -  Class::Observable 1.04
Class::Observable is a Perl module that allows other classes and objects to respond to events in yours. SYNOPSIS # Define an observable class package My::Object; use base qw( Class::Observable ); # Tell all classes/objects observing this...
10.24 KB  
Libraries  -  App::Session 0.962
App::Session can represents a sequence of multiple events perhaps executed in separate processes. SYNOPSIS # ... official way to get a Session object ... use App; $session = App->context(); $context = $session->session(); # get the session...
73.73 KB  
Libraries  -  App::Modular::Module::Events 0.1.2
App::Modular::Module::Events is a Perl module with event handling for App::Modular compatible applications. SYNOPSIS #################################################################### package App::Modular::Module::Me; use base...
16.38 KB  
Libraries  -  Class::Meta 0.53
Class::Meta is a Perl class automation, introspection, and data validation. SYNOPSIS Generate a class: package MyApp::Thingy; use strict; use Class::Meta; use Class::Meta::Types::String; use Class::Meta::Types::Numeric; BEGIN { #...
61.44 KB  
Libraries  -  dtRdr::Traits::Class 0.0.11
dtRdr::Traits::Class is a Perl module with shared OO stuff. Methods to Break Things NOT_IMPLEMENTED Imported into base class. Gives a nicer message than the standard "Cant locate method...", indicating that you did not typo the method name,...
2.8 MB  
Libraries  -  Class::Container 0.12
Class::Container is a Perl module with Glues object frameworks together transparently. SYNOPSIS package Car; use Class::Container; @ISA = qw(Class::Container); __PACKAGE__->valid_params ( paint => {default => burgundy}, style =>...
19.46 KB  
NEW DOWNLOADS IN LINUX SOFTWARE, PROGRAMMING
Linux Software  -  Polling Autodialer Software 3.4
ICTBroadcast Auto Dialer software has a survey campaign for telephone surveys and polls. This auto dialer software automatically dials a list of numbers and asks them a set of questions that they can respond to, by using their telephone keypad....
488 B  
Linux Software  -  Total Video Converter Mac Free 3.5.5
Total Video Converter Mac Free developed by EffectMatrix Ltd is the official legal version of Total Video Converter which was a globally recognized brand since 2006. Total Video Converter Mac Free is a free but powerful all-in-one video...
17.7 MB  
Linux Software  -  Skeith mod_log_sql Analyzer 2.10beta2
Skeith is a php based front end for analyzing logs for Apache using mod_log_sql.
47.5 KB  
Linux Software  -  SLAX 6.0+
Slax is a modern, portable, small and fast Linux operating system with a modular approach and outstanding design. Despite its small size, Slax provides a wide collection of pre-installed software for daily use, including a well organized graphical...
190 KB  
Linux Software  -  GTK+ 2.5
GTK+, which stands for the GIMP Toolkit, is a library for creating graphical user interfaces for the X Window System. It is designed to be small, efficient, and flexible. GTK+ is written in C with a very object-oriented approach. Language bindings...
60 MB  
Programming  -  FLEX-db Digital Asset Manager 3.0.9
FLEX-db - an enterprise Digital Asset Manager (DAM). It ingests and links metadata with files, creates thumbnails, and processes files using business rules. FLEX-db has a JSP client, Java app server for file input and output and an EJB metadata...
21.57 MB  
Programming  -  Libicom 0.9.0
The libicom library is a character based dynamicly linked library for Linux. It is used to remotely control the Icom IC-R8500 wide band receiver via an RS232 link. All call and return parameters to the control functions are character string based....
20.48 KB  
Programming  -  dotdesktop 0.3
Dotdesktop library provides ability to parse desktop entry file and access the information in a convenient way. Desktop entry file format is defined by freedesktop.org, it is used to describe information about an application such as the name and...
327.68 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  libyasl 0.2
Libyasl is a C++ class library to easily realize TCP/UDP/Multicast clientsand servers in IPv4 and IPv6 environments under GNU/Linux systems.
143.36 KB