{ "info": { "author": "Joel Hedlund", "author_email": "yohell@ifm.liu.se", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.3", "Programming Language :: Python :: 2.4", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: User Interfaces" ], "description": "================================================================\r\nTUI Textual User Interface - A sane command line user interface.\r\n================================================================\r\n\r\nCopyright (c) 2011 Joel Hedlund.\r\n\r\nContact: Joel Hedlund \r\n\r\nTUI is straightforward to use, both for developers and users. It can parse \r\noptions from multiple config files and command line, and can produce \r\nconstructive error messages given bad input. It can also help keep the \r\nsource code clean by moving help text to a separate documentation file.\r\n\r\nIf you have problems with this package, please contact the author.\r\n\r\n\r\nRequirements\r\n============\r\nPython 2, version 2.3 or later.\r\n\r\n\r\nGetting started\r\n===============\r\n\r\nTypically, you will need to import the tui class and some format classes \r\nfrom the tui.formats module. The tui.docparser module has documentation on how \r\nto write tui-compatible documentation files, but you won't likely need \r\nanything else from there. You probably won't ever have to use anything from \r\nthe TextBlockParser module.\r\n\r\n\r\nHowto\r\n=====\r\n\r\nLet's pretend we're making a moose counter. First, we create the script \r\nfile 'moosecounter.py', a docs file 'moosecounter.docs' and a config file\r\n'moosecounter.cfg' in the same dir. Leave the latter two empty and start \r\nediting the scriptfile.\r\n\r\nInstantiate a textual user interface object and give it the proper name \r\nright from the start and use the magical initprog() feature, like so::\r\n\r\n\t#!/usr/bin/env python\r\n\r\n\tfrom tui import tui, formats\r\n\t\r\n\t__version__ = \"0.1.0\"\r\n\tif __name__ == '__main__':\r\n\t o = tui(progname='MooseCounter', main=__file__)\r\n\t o.initprog()\r\n\r\nSave and execute your moose counter with no arguments, and voila: usage \r\ninstructions! Execute it with the --HELP flag, and voila: verbose program \r\ninformation, including syntax help for the config file! The config files \r\nare meant to be used by your users to configure your program with, by the \r\nway.\r\n\r\nA quick note on using main=__file__:\r\n\r\nDoing this is handy because it enables tui to find any .cfg or .docs files\r\nyou want to distribute with your program, however if you do not supply a \r\nversion str, tui will attempt to import the module and read the __version__\r\nattribute (if present), so if you are planning to use this feature, make \r\nsure your script can be imported without side effects. But as this is \r\nstandard python coding practice, you should probably be doing this already!\r\n\r\nNow you can go on to adding more options to your moose counter. Just stick \r\nsome o.makeoption() and o.makeposarg() clauses between the last two lines \r\nin the example above. You will probably also need to import some formats \r\nfor your options from the formats module in this package. For example you \r\ncan do something like this::\r\n\r\n\t#!/usr/bin/env python\r\n\r\n\tfrom tui import tui, formats\r\n\r\n\t__version__ = \"0.1.0\"\r\n\tif __name__ == '__main__':\r\n\t o = tui(main=__file__, progname='MooseCounter')\r\n\t o.makeoption('horn-points', formats.BoundedInt(lowerbound=1), '13')\r\n\t o.makeoption('weight', formats.Float, '450.0', 'w')\r\n\t o.makeposarg('observation_data', formats.ReadableFile)\r\n\t o.makeposarg('result_file', formats.WritableFile)\r\n\t o.initprog()\r\n\r\nAfter you have saved you can execute your moose counter in same manner as \r\nbefore and see your new options turn up in the help screens. You are highly\r\nencouraged to document the program and its options better, and your docs \r\nfile is the place to do it. Check the help for the tui.docparser module for\r\nthe syntax. \r\n\r\nOK, so that's a handful of lines of code that take care of all the boring \r\nold run of the mill config file and parameter parsing and help screen \r\ngeneration, and now you're free to write code that actally counts mooses. \r\nUse o.options() to return a dict of options and values, and o.posargs() to \r\nget a list of values for all positional arguments.\r\n\r\n\r\nFurther reading\r\n===============\r\n\r\nSee the separate help docs on each individual module, class and method.\r\n\r\n\r\nCopyright\r\n=========\r\n \r\nThe MIT License\r\n\r\nCopyright (c) 2011 Joel Hedlund.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/yohell/python-tui", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yohell/python-tui", "keywords": "", "license": "The MIT License\r\n\r\nCopyright (c) 2011 Joel Hedlund.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.", "maintainer": "", "maintainer_email": "", "name": "tui", "package_url": "https://pypi.org/project/tui/", "platform": "OS Independent", "project_url": "https://pypi.org/project/tui/", "project_urls": { "Download": "https://github.com/yohell/python-tui", "Homepage": "https://github.com/yohell/python-tui" }, "release_url": "https://pypi.org/project/tui/1.1.1/", "requires_dist": null, "requires_python": null, "summary": "Quickly add a competent textual user interface to your python program.", "version": "1.1.1" }, "last_serial": 803421, "releases": { "1.0": [], "1.1.1": [ { "comment_text": "", "digests": { "md5": "9003c5aef9b1c54d51f3445cdefb80ef", "sha256": "f99a79b1f3d37cea6ca5b108a046990e58c90921384cc08af4a16832e2ee6b50" }, "downloads": -1, "filename": "tui-1.1.1.tar.gz", "has_sig": false, "md5_digest": "9003c5aef9b1c54d51f3445cdefb80ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28398, "upload_time": "2011-02-24T16:02:35", "url": "https://files.pythonhosted.org/packages/37/90/a20763354e6d0e4b2bcc88aa5ddfa857e043c405907acc48d1c55221b3d5/tui-1.1.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "45a492660a557d8e7be891315f3e40a8", "sha256": "a21cc628f6c57ad771ab5ad4fced725facadbb91dd6019ea91b15dff646ef163" }, "downloads": -1, "filename": "tui-1.1.1.zip", "has_sig": false, "md5_digest": "45a492660a557d8e7be891315f3e40a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34199, "upload_time": "2011-02-24T16:02:35", "url": "https://files.pythonhosted.org/packages/2e/b0/0df1bd92971f6f6c6d8390ee766b7ba7d1491bf3fb38b78819ad23a0982f/tui-1.1.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9003c5aef9b1c54d51f3445cdefb80ef", "sha256": "f99a79b1f3d37cea6ca5b108a046990e58c90921384cc08af4a16832e2ee6b50" }, "downloads": -1, "filename": "tui-1.1.1.tar.gz", "has_sig": false, "md5_digest": "9003c5aef9b1c54d51f3445cdefb80ef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28398, "upload_time": "2011-02-24T16:02:35", "url": "https://files.pythonhosted.org/packages/37/90/a20763354e6d0e4b2bcc88aa5ddfa857e043c405907acc48d1c55221b3d5/tui-1.1.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "45a492660a557d8e7be891315f3e40a8", "sha256": "a21cc628f6c57ad771ab5ad4fced725facadbb91dd6019ea91b15dff646ef163" }, "downloads": -1, "filename": "tui-1.1.1.zip", "has_sig": false, "md5_digest": "45a492660a557d8e7be891315f3e40a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34199, "upload_time": "2011-02-24T16:02:35", "url": "https://files.pythonhosted.org/packages/2e/b0/0df1bd92971f6f6c6d8390ee766b7ba7d1491bf3fb38b78819ad23a0982f/tui-1.1.1.zip" } ] }