{ "info": { "author": "Harold Bradley III", "author_email": "harold@bradleystudio.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 1 - Planning", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Build Tools" ], "description": "nwid\n####\nA terminal widgets framework for humans.\n===========================================================\n.. image:: https://www.quantifiedcode.com/api/v1/project/d817599b176740e49b42d1f8402d4d3e/badge.svg\n :target: https://www.quantifiedcode.com/app/project/d817599b176740e49b42d1f8402d4d3e\n :alt: Code issues\n----\n\nPlease note that this is a work in progress. The API will likely change many\ntimes before it becomes stable. Use at your own risk.\n\nNwid is a terminal widgets framework for humans.\n\nIt is designed to be an easy-to-use, light-weight (no dependencies), terminal\nwidget library and application framework for building terminal GUIs. It has\nintuitive widgets, a simple and recognizable event loop, and a container\n``App`` that can be extended or used as-is. Its design and components take some\ninspiration from the well-known web browser DOM as well as the python packages\n`urwid `_ and\n`npyscreen `_.\n\nAlthough there already are a handful of terminal user-interface libraries in\npython, I have found them to be either cumbersome to use or difficult to extend\nbecause of their design. The python curses module is itself unweildly and\ndesperately needs a layer of abstraction to hide its unique details and oddly\nnamed functions. Nwid aims to be this intuitive, easy to extend abstraction\nlayer. The nwid philosophy is to let you create and describe the widgets with\nintuitive attributes and methods, and the framework will take care of the\ncumbersome terminal details. The code is pythonic and easy to read, which makes\nit easy to extend.\n\nA low-level knowledge of terminals and tty is not necessary to using this\nframework. To get started, check out the examples in the examples directory.\nNwid is designed to be conceptually easy to understand, and the examples are\nintended to exhibit the basic concepts in order to give a helpful overview of\nthe capabilities and structure of the framework. After looking at the examples,\nyou can read `Modules and Components`_ for more specific details about the\nframework.\n\nIf you have any questions, comments, or suggestions I'd love to hear them:\nharold (a) bradleystudio.net\n\n\nInstalling and including in projects\n====================================\n\nInstalling nwid\n---------------\n\n.. code:: bash\n\n $ git clone git@github.com:hbradleyiii/nwid.git\n $ cd \n $ pip install -e .\n\nRunning Tests\n-------------\n\n.. code:: bash\n\n $ cd \n $ py.test\n\nImporting and Basic Usage\n-------------------------\n\n.. code:: python\n\n >>> import nwid\n\n >>> app = nwid.App()\n >>> app.window.add( {\n nwid.Title : { 'text' : 'An nwid App!' },\n nwid.LabeledTextBox : {\n 'text' : 'Your input:',\n 'validator' : App.validate_function,\n 'name' :\n }\n nwid.Button : {\n 'text' : 'Click me!',\n 'click' : App.callback_function,\n }\n })\n\n >>> app.run()\n\n\nModules and Components\n======================\n\nOverview\n--------\n\nThe nwid framework is made of three major components, the ``App`` class for\nmanaging windows and running the event loop, the ``Window`` class for\ncontaining and managing widgets, and the widget module for creating the user\ninteractive widgets (such as, textfields, labels, and dropdown boxes).\n\nThe ``App`` is the base controller for the application. Besides controling the\nevent loop, it is responsible for initializing the curses environment and\nhandling the screen object. This class can be used as-is or may be extended by\na custom class with application-specific controller methods. The ``App`` class\nhas a special property, the ``App.window_stack``, that keeps track of the\ncurrent window and any open window that has not yet been closed but is covered\nup (partly or completely) by the current window.\n\nFor instance, the first window may be a form that has a button that opens a\nsecond window with a select box containing a list of options to choose from.\nThe first window hasn't yet closed but is waiting for the second window to\nprovide the user selected choice. At this point, the second window is the\nsecond and top-most window on the stack. Any events that are triggered are now\ngiven to this window. It may completely cover the first window or might only\ncover a portion of it being centered on the screen with the edges revealing the\nfirst window behind it. This second window may contain a select box with a list\nof several objects or strings to pass back to the first window. One of these\noptions might be 'new', indicating that the user wishes to create a new string\nor object. Selecting this item, might open a third window for this task,\nputting this third window on top of the stack. This stacking could go on\nindefinitely with each window appending to the ``App.window_stack``. When the\ntopmost window is closed, this window is 'popped' from the stack and the next\nwindow down in the stack is given back the focus. When an ``App`` no longer has\nany windows, the application is closed.\n\nThe ``Window`` class is the container class for the widgets. It sets the bounds\nfor where a widget can be drawn. It may have a border and title set. Note that\nthis is not the same thing as the curses window object. Although it should have\na reference to this object in ``Window.screen``.\n\nA widget is a user interface object that can be displayed in a window. It is\ndefined by its height and width, its location on the window, and its foreground\nand background colors. It has contents such as a string of text or a more\ncomplicated widget may contain other widgets. In fact, a ``Window`` class is\nactually a special kind of top-level widget. You can create your own custom\nwidgets by extending ``widget.Base``, although nwid comes with a number of\nuseful generic widgets such as ``TextBox``, ``LabledTextBox``, ``CheckBox``,\n``String``, ``Button``, ``Label``, and ``SelectBox``. Widgets can register\nevents to callback functions in order to handle keyboard or mouse events.\n\n\nThe App Module\n--------------\n\nThe ``nwid.app`` module comprises\n\n\nThe ``App`` controller is also responsible for the event loop that catches\nkeyboard and mouse events. It passes these events to the window in focus\n(``App.window``) for the window to handle.\n\nLastly, the ``App`` is responsible for setting up and tearing down the curses\nenvironment. It initializes the curses screen and binds this object to any\nwindow that is put in the window stack. This is done using a ``CursesManager``\nobject, which is both a context manager and a wrapper for the curses library.\nThis object is part of the nwid internals and generally doesn't need to be\naccessed directly. It takes care of the nitty-gritty details.\n\nThe App Class\n~~~~~~~~~~~~~\n\nThe ``nwid.App`` class is the primary\n\nYou can either use it as is or you can inherit from ``App``.\n\n.. code:: python\n\n >>>\n\nThe current window or top-most window is always the window with the focus,\nmeaning that any events that are triggered are given only to that window. The\n``App.window`` attribute always points to this window. Setting this attribute\nto a new window will automatically make this new window the window with the\nfocus and put it on top of the 'window stack'.\n\n\n\nAttributes\n``````````\n\nMethods\n```````\n\nThe CursesManager Context Manager\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nTODO\n\nThe Event Loop\n~~~~~~~~~~~~~~\n\nThe event loop is inspired by the design of an Internet browser's event loop.\n\nRegistering Events\n``````````````````\n\nA widget can register an event with a callback function by\n\nExample:\n\n.. code:: python\n\n >>> def widget.callback_function(self):\n >>> print 'Event triggered!'\n\n >>> widget.register_event('x', widget.callback_function)\n\nEvent Propagation\n`````````````````\n\nWhen an event is fired, the main window's trigger function is called with the\nevent name. It then calls the trigger function of its child that has focus. If\nthis child has a child widget, the process continues down until it gets to the\nlowest widget in focus that has no children. This widget attempts to run any\nregistered callback functions. The function may return as normal and the parent\nregains control and attempts to run any registered callback function that it\nmay have. This process continues until the main window regains control or if\nthe exception ``PreventDefault`` is raised. A callback function may choose to\nraise ``PreventDefault`` in order to prevent other callback functions from\ninterferring. This is very similar to JavaScript's ``Event.preventDefault()``\nmethod.\n\n\n\nWidget Module\n-------------\n\nA Widget is a reusable modular component that is displayed on the screen as a\nbutton, a text field, or other graphical interface. It can be combined to make\na more complex widget component. The widgets that make up this more comlpex\ncomponent are the ``children`` widgets to the ``parent`` widget.\n\nThe ``parent`` widget is responsible for the layout of its ``children``. The\n``parent`` controls the vertical and horizontal alignment as well as whether or\nnot it has the ability to scroll.\n\nBase Widget\n~~~~~~~~~~~\n\nThe ``nwid.widget.Base`` class is the foundation for all other widgets. If you\nwish to create your own widget, you should inherit from ``Base``.\n\nFor example:\n\n.. code:: python\n\n >>>\n\nString Widget\n~~~~~~~~~~~\n\nThe ``nwid.widget.String`` class is a basic string widget. This widget is used\nfor displaying strings.\n\nTextBox Widget\n~~~~~~~~~~~~~~\n\nThe ``nwid.widget.TextBox`` class is a textbox widget for accepting user input.\n\nComboBox Widget\n~~~~~~~~~~~~~~~\n\nThe ``nwid.widget.ComboBox`` class is a textbox widget for accepting user input.\n\n----\n\nSoli Deo gloria.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/hbradleyiii/nwid/archive/v0.1-planning.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hbradleyiii/nwid", "keywords": "server development,terminal programming,terminal,terminal widgets", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "nwid", "package_url": "https://pypi.org/project/nwid/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/nwid/", "project_urls": { "Download": "https://github.com/hbradleyiii/nwid/archive/v0.1-planning.tar.gz", "Homepage": "https://github.com/hbradleyiii/nwid" }, "release_url": "https://pypi.org/project/nwid/0.1/", "requires_dist": null, "requires_python": null, "summary": "A terminal widget framework for humans.", "version": "0.1" }, "last_serial": 2009200, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "1b9acecc320f247e9712721f19118cd7", "sha256": "1ea9e7f0d0b7e7699f4564884f3955310b14dcae91d67527bdd1a1f82a2c634e" }, "downloads": -1, "filename": "nwid-0.1.tar.gz", "has_sig": false, "md5_digest": "1b9acecc320f247e9712721f19118cd7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8536, "upload_time": "2016-03-16T01:31:48", "url": "https://files.pythonhosted.org/packages/35/e9/c6663b16fd8c54284e7e5088de548952d26a802d13380727a0f348e74ea4/nwid-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1b9acecc320f247e9712721f19118cd7", "sha256": "1ea9e7f0d0b7e7699f4564884f3955310b14dcae91d67527bdd1a1f82a2c634e" }, "downloads": -1, "filename": "nwid-0.1.tar.gz", "has_sig": false, "md5_digest": "1b9acecc320f247e9712721f19118cd7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8536, "upload_time": "2016-03-16T01:31:48", "url": "https://files.pythonhosted.org/packages/35/e9/c6663b16fd8c54284e7e5088de548952d26a802d13380727a0f348e74ea4/nwid-0.1.tar.gz" } ] }