{ "info": { "author": "justaboredkid", "author_email": "29010153+justaboredkid@users.noreply.github.com", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: User Interfaces" ], "description": "# sacred-tui ![travis-ci](https://api.travis-ci.org/justaboredkid/sacred-tui.svg?branch=development)\nASCII art import and terminal graphics made simple. \n\n \n\n Let's say you want something like this in your script:\n```\n _____________________________,----,__\n|==============================<| /___\\ ____,-------------.____\n `------------------.-----.---.___.--' __.--'-----------------------`--.__\n `._ `. =======================================\n ____`.___`._____,----' `--------,----------------'\n /_|___________-----< ========,'\n `-. ,'\n `----.______,--'\n```\nASCII \u1d00\u0280\u1d1b \u1d0d\u1d00\u1d05\u1d07 \u0299\u028f J\u1d0fs\u029c\u1d1c\u1d00 B\u1d07\u029f\u029f \n \nAnd what if you wanted it at *exactly*, *precisely* 10 spaces to the right?\nYou can do this:\n```\nprint(\" _____________________________,----,__\")\nprint(\" |==============================<| /___\\\\ ____,-------------.____\")\nprint(\" `------------------.-----.---.___.--' __.--'-----------------------`--.__\")\nprint(\" `._ `. =======================================\")\nprint(\" ____`.___`._____,----' `--------,----------------'\")\nprint(\" /_|___________-----< ========,'\")\nprint(\" `-. ,'\")\nprint(\" `----.______,--'\")\n```\nAnd add more spaces and backslashes and lose track of which line you added and then restart. **Eww no.**\n \n\nOr maybe this:\n```\nfrom blessed import Terminal # pip install blessed\n\nterm = Terminal()\n\nprint(term.clear)\n\nwith open(\"ent_e.txt\", \"r\") as f: # ent_e.txt contains the ASCII art itself\n ent = f.readlines()\n\nwith term.location(10, 0):\n for line in ent:\n print(line)\n```\nWait a minute:\n```\n _____________________________,----,__\n\n|==============================<| /___\\ ____,-------------.____\n\n `------------------.-----.---.___.--' __.--'-----------------------`--.__\n\n `._ `. =======================================\n\n ____`.___`._____,----' `--------,----------------'\n\n /_|___________-----< ========,'\n\n `-. ,'\n\n `----.______,--'\n``` \n*AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA the ship is falling apart!!!!*\n \n\n## **Behold, sacred-tui.**\n```\nimport sacred\n\nscene = sacred.Scene()\ncam = sacred.Camera()\nsacred.clear()\n\nscene.obj(\"ent_e.json\", 10, 0) # asciigen ent_e.txt ent_e\ncam.render()\n```\nand voil\u00e0!\n```\n _____________________________,----,__\n |==============================<| /___\\ ____,-------------.____\n `------------------.-----.---.___.--' __.--'-----------------------`--.__\n `._ `. =======================================\n ____`.___`._____,----' `--------,----------------'\n /_|___________-----< ========,'\n `-. ,'\n `----.______,--'\n``` \nThough you have to convert the ASCII art from text to the json format that my script uses (asciigen), there is no hassle for just putting the spaceship a little bit more to the right. Or a bit toward the bottom. Anywhere on the terminal.\n\n***ANYWHERE.*** \n \n \n[*Maniacal laughter*](https://www.youtube.com/watch?v=gY2k8_sSTsE) \n\nDid I also mention that it supports ANSI Color?\n```\nimport sacred\nimport blessed\n\nscene = sacred.Scene()\ncam = sacred.Camera()\nt = blessed.Terminal()\nsacred.clear()\n\nscene.obj(\"testassets/spacedock.json\", 5, 0)\nscene.obj(\"testassets/ent_e.json\", 10, 3)\nscene.box(0, 15, sacred.width, sacred.height - 15)\nscene.txt(t.bright_red_on_bright_yellow(\"tests are inevitable\"), 5, 30)\ncam.render()\ninput()\n```\n \n``` \n ---------------------------------------------------------------------------------------------------- \n || || || || || || || || || || \n ---------- ---------- ---------- ---------- ---------- \n | _____________________________,----,__ | | | | \n | |==============================<| /___\\ ____,-------------.____ \n | `------------------.-----.---.___.--' __.--'-----------------------`--.__ \n | | | |`._ `. ======================================= \n | | | |____`.___`._____,----' `--------,----------------' \n | | | /_|___________-----< ========,' | | \n | | | | | `-. ,' | | \n | | | | | | `----.______,--' | | \n ---------- ---------- ---------- ---------- ---------- \n || || || || || || || || || || \n ---------------------------------------------------------------------------------------------------- \n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2502 tests are inevitable \u2502\n\u2502 \u2502\n\u2502 \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n```\n \n \n## *Wait a minute, I have bigger ASCII art, but `scene.render()` won't allow objects to exceed terminal size. EXPLAIN*\n\nThat's where `Camera()` and `create_stage()` comes in. \n\n`Camera.move()` allows you to move around the stage. Using `create_stage()` you can define an area that is bigger than the terminal size. \n\nThis means you can move around your camera instead of creating individual frames just to view a different part of the large model.\n\n\n \n\n# Terminology\n\n*Camera*: V-Cam. Something like the [Virtual Camera in Adobe Animate](https://helpx.adobe.com/ca/animate/how-to/virtual-camera.html). \n*Scene*: Layer of objects. \n*Screen/Stage*: The work area. It can be larger than the terminal size. \n*Objects*: Text, Boxes, ASCII art etc.\n\n\n\n# Installation\nClone repo and install:\n```\npython3 setup.py install\n```\nor use pip:\n```\npip install sacred-tui\n```\n\nNote: If you want to develop this, use the develop mode\n```\npython3 setup.py develop\n```\nThis will recognize your changes for your workspace. \n\n*Note: does not support Python 2*\n\n# Documentation\n### [asciigen.py](https://github.com/justaboredkid/sacred-tui/blob/master/asciigen.py)\nPython script for generating ASCII json files. All you need to do is to grab some ASCII art (from the web or somewhere else), type `asciigen` in the terminal to covert it into json, and:\n```\nimport sacred\n\nscene = sacred.Scene()\n\nsacred.clear()\nscene.obj(\"test.json\", 5, 10)\nscene.render()\n```\nUsage:\n```\nasciigen.py \n```\n\nThe data is in this format:\n```\n{\"line#\":[\"text\", SpaceBeforeText]}\n```\nWhere `line#` means which line it is, `text` being what is printed on the line, and `SpaceBeforeText` means the, well, space before the line. Note that this tool isn't perfect, so you might have to edit the `SpaceBeforeText` part.\n### sacred.width, sacred.height\nThese output the values of shutil.get_terminal_size() separately.\n### sacred.create_stage(w=width, h=height)\nThis (by default) creates a stage that is the size of the terminal. By manipulating the `w` and `h` values, you can set the stage size to whatever you want. \n\nWant a epic long chase? Increase the width and move the camera around by using `sacred.Camera()`. \n\n*Note: The camera always starts at the top left corner of the stage*\n\nArgs:\n```\nw (int): width of the stage\nh (int): height to the stage\n```\n## *sacred.Scene(object)*\nClass for all objects in render. It has the following objects:\n### Scene.reset()\nThis function clears everything in the scene, kind of like a 'Erase everything on the scene' function. It keeps the original stage size as well.\n\n\n### Scene.obj(file, x=0, y=0)\nImports ASCII json files. Those are generated by `asciigen`. It adds the ASCII art to the scene as well as returning the json.\n\nArgs:\n```\nfile (str): path to the .json file\nx (int): position on the x axis\ny (int): position on the y axis\n```\n### Scene.txt(txt, x=0, y=0)\nAdds text to the position (x, y). Similar to `print()`, but you can put it wherever you want on the scene. Sacred also supports ANSI escape sequences after V0.2.1\n\n\nArgs:\n```\ntxt (str): content to print at (x,y)\nx (int): position on the x axis\ny (int): position on the y axis\n```\n### Scene.box(x=0, y=0, w=t.width - 1, h=t.height - 1, style='reg', fill=\" \")\nAdds a box on terminal. Creates a box around the terminal by default. (Note that a character on the terminal is a tall rectangle, which means that having the same height and width does not create a square.)\n \nV0.2.1 adds Unicode box characters. You can set the styles of the lines. \n\nHere are the possible values for style:\n * reg (regular)\n * heavy\n * dashed\n * dashedTight (Tight dash)\n * dashedTighter (Tightest dash)\n \n*Example:*\n```\nimport sacred\n\nscene = sacred.Scene()\ncam = sacred.Camera() \n\nscene.box(5, 5, 10, 10, fill=\"*\")\ncam.render()\n```\n*Output:*\n```\n\n\n \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502********\u2502\n \u2502********\u2502\n \u2502********\u2502\n \u2502********\u2502\n \u2502********\u2502\n \u2502********\u2502\n \u2502********\u2502\n \u2502********\u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n\n \n```\n \nArgs:\n```\nx (int): position on x axis\ny (int): position on y axis\nw (int): width (by char)\nh (int): height (by char)\nstyle (str): sets style of the line that draws the box.\nfill (str): content that fills inside box. (Will return ValueError if fill is more than one char.)\n```\n### Scene.fill(x=0, y=0, w=width, h=height, fill=\"#\"):\nThis fills a designated area with `fill`. Like `box()` but without the lines.\n\n*Example:*\n```\nimport sacred\n\nscene = sacred.Scene()\ncam = sacred.Camera() \n\nscene.fill(5, 5, 10, 10)\ncam.render()\n```\n*Output:*\n```\n \n \n \n \n \n ##########\n ##########\n ##########\n ##########\n ##########\n ##########\n ##########\n ##########\n ##########\n ##########\n\n\n\n```\n\n### ~~Scene.render()~~ (deprecated)\n\n**`this has been deprecated. Will remove soon.`**\n\n### Scene.export()\nThis function takes the stage, converts it into string, and return the stage. You could do whatever you want with it, it is a large nested list. That includes but not limited to storing it as a variable.\n\n### Scene.restore(scr)\nThis takes the output of `Scene.export()` and restore it. You can restore the scene from the aforementioned variable.\n\n\n## sacred.Camera(object)\nClass for moving around the camera, using the terminal like a viewport.\n\n### Camera.move(x=0, y=0)\n\nMoves the the camera inside stage. This way you can have objects that are bigger than the terminal and it will still be able to render.\n\n### Camera.render()\n\nRenders (or print, if you prefer) all the objects added. Note that it prints in the order of the added objects, so each object goes on top of other objects in the order of the objects added.\n\n~~The `multi` argument allows multi-thread rendering. *This is still work in progress.*~~ \n`multi` has been removed since V0.2.1\n\n\n## sacred.TooLarge(Exception)\nError raised when the objects that are added are bigger than the width of the Stage itself.\n\nSo if you do this in a 80x24 stage:\n```\nscene.box(0, 0, 500, 500)\nscene.render()\n```\nthen this happens:\n```\nScene exceeds terminal width\nUser: If possible, maximize the terminal window.\nDev: Make sure your x values are in check.\nTraceback (most recent call last):\n File \"test.py\", line 7, in \n scene.render()\n File \"/home/henry/Github/sacred/sacred.py\", line 47, in render\n printobj(obj, self.pos[i][0], self.pos[i][1])\n File \"/home/henry/Github/sacred/sacred.py\", line 83, in printobj\n raise TooLarge\nsacred.TooLarge\n```\n## sacred.txtbox(txt, x=0, y=t.height - 1)\nWhen `input()` is not enough. This is basically a moveable version of that, where you can set the position of it at anywhere.\n\nBy default, it prints from the bottom of the terminal.\n\n\n## sacred.clear()\nClears screen.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/justaboredkid/sacred", "keywords": "", "license": "GNU GPLv3", "maintainer": "", "maintainer_email": "", "name": "sacred-tui", "package_url": "https://pypi.org/project/sacred-tui/", "platform": "", "project_url": "https://pypi.org/project/sacred-tui/", "project_urls": { "Homepage": "https://github.com/justaboredkid/sacred" }, "release_url": "https://pypi.org/project/sacred-tui/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Python library for ASCII art import and TUI development", "version": "0.2.1" }, "last_serial": 5489589, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "68e6658b70cbb31b440ea1c10e62578d", "sha256": "e2bbe3ef5d36e57245cf6419af1bdede8f38811af8dfb63c4bebab171d7e9512" }, "downloads": -1, "filename": "sacred_tui-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "68e6658b70cbb31b440ea1c10e62578d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 2288, "upload_time": "2018-12-30T03:00:35", "url": "https://files.pythonhosted.org/packages/2a/fc/1bfbe16df11004901b478bc43e8c383224c7cfb728ec2c4ded45fef34c71/sacred_tui-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "78b8a46471c4b86471dfb423d601a8c7", "sha256": "9bedd86633a815091c1b7374c0b29c8f066fbc3d84390aa2c46eb02871f8a036" }, "downloads": -1, "filename": "sacred_tui-0.1.0.tar.gz", "has_sig": false, "md5_digest": "78b8a46471c4b86471dfb423d601a8c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3472, "upload_time": "2018-12-30T03:00:37", "url": "https://files.pythonhosted.org/packages/25/2a/7435a1e2da4065beadb9dfe35428c0a4f3145c6619d96479a8ae1c6c7a2d/sacred_tui-0.1.0.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "cc223f7ec17fe429404e804cda01cf25", "sha256": "a4a95efe1d237f8a5b82141c81053fa53e43862aed2d8010da3118d9eead3865" }, "downloads": -1, "filename": "sacred_tui-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "cc223f7ec17fe429404e804cda01cf25", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 3145, "upload_time": "2019-01-23T21:03:33", "url": "https://files.pythonhosted.org/packages/8f/45/57d6d8eca6bccc9904ad3405c3043eb96dbd0983bca05e5a4753db260574/sacred_tui-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fe1dc306b234040a1da2fa73d08778a1", "sha256": "483b02c2fa1eaca3771f324401d8cdbc7d3d595471da81ddfef97711a71176ba" }, "downloads": -1, "filename": "sacred_tui-0.2.tar.gz", "has_sig": false, "md5_digest": "fe1dc306b234040a1da2fa73d08778a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5667, "upload_time": "2019-01-23T21:03:35", "url": "https://files.pythonhosted.org/packages/94/fa/b7a25ecdc3458bf69b108f2ae4f4961a307d8a824fc7ec67227ea7ee002f/sacred_tui-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "08d178cd8a48c9192ee38dca97bcf78f", "sha256": "f366590628ca2187068c538b0222700cde40db5c0efed6ecbc2c3a7e9fbf9ac9" }, "downloads": -1, "filename": "sacred_tui-0.2.1.tar.gz", "has_sig": false, "md5_digest": "08d178cd8a48c9192ee38dca97bcf78f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9415, "upload_time": "2019-07-05T05:09:19", "url": "https://files.pythonhosted.org/packages/13/83/59722635f9b233387966aad8228d79df7b17fe366dca63553402e77b4b8d/sacred_tui-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "08d178cd8a48c9192ee38dca97bcf78f", "sha256": "f366590628ca2187068c538b0222700cde40db5c0efed6ecbc2c3a7e9fbf9ac9" }, "downloads": -1, "filename": "sacred_tui-0.2.1.tar.gz", "has_sig": false, "md5_digest": "08d178cd8a48c9192ee38dca97bcf78f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9415, "upload_time": "2019-07-05T05:09:19", "url": "https://files.pythonhosted.org/packages/13/83/59722635f9b233387966aad8228d79df7b17fe366dca63553402e77b4b8d/sacred_tui-0.2.1.tar.gz" } ] }