Skip to main content

pysimpleapp

https://img.shields.io/pypi/v/pysimpleapp.svg https://img.shields.io/travis/MagpieEmbedded/pysimpleapp.svg Documentation Status

Simple framework for applications in python

Aims

This package is intended to provide the basic components for applications in Python. It provides a white box implementation of multi threaded applications.

pysimpleapp welcomes additional base classes and implementations of application methodologies.

There is often more than one way to do something and pysimpleapp tries to support that by providing building blocks rather than solutions.

It is intended to be GUI framework agnostic, although some common frameworks have been included for demonstration and ease of use.

There should also be a relatively thorough set of tutorials alongside the main code. This will teach how to use the software and explain why the software is this way.

Installation

pysimpleapp is hosted on PyPi so can be installed with:

Simple Examples

Below are some simple examples which have been prepared.

To understand how they work and how to build more complex applications, please visit the tutorials section of the documentation.

Threads

Open a python session with pysimpleapp installed.

Import libraries and classes:

from pysimpleapp.message import Message
from pysimpleapp.threads.examples import ExampleSingleRunThread, ExampleMultiRunThread
from queue import Queue
from threading import Thread

Threads take a name as the first argument, owner name as the second argument and an input and output queue for communication. Their use will be demonstrated shortly but you can confirm that they inherit from the threading.Thread class.

Let’s create the input and output queues and an instance of the ExampleSingleRunThread class:

in_queue = Queue()
out_queue = Queue()
single_run = ExampleSingleRunThread('Name', 'Owner', in_queue, out_queue)
isinstance(single_run, Thread) # returns True

Now, send the singe_run thread a start command. Threads in pysimpleapp often have some built in commands, but it is very easy to override these and add your own later.

It is also essential to define how you want a thread to behave through it’s main function. The ExampleSingleRunThread has been defined to print that it has run.

Put a start message in the input queue:

# Note the order of owner and name because we are sending from the owner
in_queue.put(Message('Owner', 'Name', 'THREAD_START', None))

This should print:

Running single run thread...

demonstrating that the thread has run!

You will also notice that if you send another start command, nothing happens. Single Run Threads execute once and then stop.

Next, make an instance of ExampleMultiRunThread:

multi_run = ExampleMultiRunThread('Name2', 'Owner', in_queue, out_queue)

Multi Run Threads will run until they are told to end. Test that functionality by providing several messages:

in_queue.put(Message('Owner', 'Name2', 'THREAD_START', None))
in_queue.put(Message('Owner', 'Name2', 'THREAD_START', None))
in_queue.put(Message('Owner', 'Name2', 'THREAD_START', None))

You will see that the thread has been counting how many times you asked it to run!

End the thread with another built in command:

in_queue.put(Message('Owner', 'Name2', 'THREAD_END', None))

After this, the thread has stopped and will no longer respond to messages.

This has been a very short introduction to some example threds but there is much more to come! Continue learning with the tutorials and soon you will be making your own threads for specific requirements.

Features

  • TODO

  • Attempt to implement best practices

  • Documentation and tutorials

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2019-07-06)

  • First release on PyPI.

Release files for pysimpleapp 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysimpleapp 0.1.3
File Size Uploaded
pysimpleapp-0.1.3.tar.gz 22.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysimpleapp 0.1.3
File Interpreter ABI Platform
pysimpleapp-0.1.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 34.5 kB

Release files / pysimpleapp-0.1.3.tar.gz

Download URL pysimpleapp-0.1.3.tar.gz
Size 22.9 kB
Tags Source
SHA-256 checksum
How to use checksums
77d35383bbf20fe972064094235cfc11abe8500cc163f98bf82afa451f19bf5d
BLAKE2b-256 checksum
How to use checksums
ba656cc6c8985802dc8595c9456e107353b9a2eb53f91de301d39ea6da264a1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / pysimpleapp-0.1.3-py2.py3-none-any.whl

Download URL pysimpleapp-0.1.3-py2.py3-none-any.whl
Size 11.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8b37139f070ed599bf97baca9a0b0296422889c1ef3e31482fd5af1630df6601
BLAKE2b-256 checksum
How to use checksums
89541c41934062a7817f355102d2e9302630eee62c03a4dba2b7ffb56fb7589b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page