{ "info": { "author": "momojohobo", "author_email": "bandaibandai@rocketship.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Purses3d\n\nThe goal is to keep panda3d in control as much as possible while providing a console of sorts to print to, not to emulate ncurses as closely as possible. It's currently pretty barebones but with some workarounds can be made to do anything ncurses can except beep().\n\n\n* Only works with monospaced fonts that contain the U+2588 \"full block\" unicode character for solid character backgrounds. For this reason hack.ttf is in this repo, which is MIT licensed.\n* Meant to be used to make ascii/text-based games, GUIs, HUDs, etc.\n* Either combine with panda3d's other capabilities or consider this the wrong way to draw text to a screen.\n\nTo see a colorful display of functionality, run\n```\n $ git clone http://github.com/momojohobo/panda3d-purses\n $ cd panda3d-purses\n $ pip install -r requirements.txt\n $ python purses3d/__init__.py \n```\nIt is also avaiable on pypi.\n```\n $ pip install panda3d-purses3d\n```\n\nTODO: \n* Steal more handy functions from ncurses.\n\n### License\nEither MIT or Public Domain (CC0), take your pick.\n\n## How to use:\n\n```\n# Import sys, panda3d and purses\nimport sys\nfrom direct.showbase.ShowBase import ShowBase\nfrom purses3d import Purses, Window\n\n# Run panda3d\nbase = ShowBase()\nbase.accept(\"escape\", sys.exit)\nbase.run()\n\n# Initialize purses with a console size of 40x20 characters\n# It will be automatically scaled to fill the entire screen\npurses = Purses(40, 20)\n\n# Make a window in the center, taking up half the screen\nwindow = Window(x=10, y=5, columns=20, lines=10) \n\n# Move that window's cursor to where we want to write\nwindow.move(3, 0)\n\n# Write something in that window\nwindow.addstr(\"hello world\")\n\n# Or move and print in one go\nwindow.addstr(3, 0, \"hello world\")\n\n# Copy it to the main purses window\npurses.copyfrom(window)\n\n# Because Purses() is also a window, we can write something on it too\npurses.addstr(0, 0, \"purses!\")\n\n# Update the screen\npurses.refresh()\n```\n\n## Colors / Properties\n\nTo add colors (amongst other need things) we'll need panda3d's TextPropertiesManager\n\n```\nfrom panda3d.core import TextProperties, TextPropertiesManager\n\n# Get panda3d's global property manager\nmanager = TextPropertiesManager.getGlobalPtr()\n\n# Make some property, in this case something telling it to print the text red (in rgba)\nred = TextProperties()\nred.setTextColor((1,0,0,1))\n\n# Add it to panda's global mananger\nmanager.addProperties(\"myRedColor\", red) \n\n# And use it to print the characters foreground (with a transparent background)\npurses.addstr(0, 0, \"purses!\", (\"myRedColor\", None))\n\n# ...or to print the characters background in that color\npurses.addstr(0, 0, \"purses!\", (None, \"myRedColor\"))\n\npurses.refresh()\n\n# We can reposition this purses instance too so it doesn't take up the entire screen\npurses.node.setScale(0.5)\npurses.node.setPos(-0.3, 0, 0)\n\n# Or parent it to the world as a 3d object COOOL!\npurses.node.reparentTo(render)\n\n```\nYou can change any properties found in the panda3d TextProperties class, though they're mostly untested. Especially changing text size could screw things up I imagine.\n\n\n## Text input\n\nBecause panda3d is a realtime system and curses is not, text input is handled a little differently.\n\n```\n# Get user input string at (10, 5) from main purses screen\nstring = purses.getstr(10, 5)\n\n# You can also supply a different window to echo the string to\n# Or give it fg and bg attributes\nstring = purses.getstr(10, 5, window=my_window, attr=(\"red\", \"blue\"))\n\n# If the string is closed (with enter), it is returned instead of None.\nif string:\n # If used types hello\n if string == \"hello\":\n # Print this answer\n purses.addstr(\"why hello there buddy!\")\n\n```\n\n\n### Functions so far\n```\npurses.move(x, y) # Place the cursor at position\npurses.increment(n=1) # Increment the cursor location\n\npurses.scrollup() # Scroll everything in window up\npurses.scrolldown() # Scroll everything in window down\n\npurses.fill(character) # Fills the entire window with a char (or empty if none is specified)\npurses.delete(x, y) # Delete a single character\npurses.addch(x, y, char, properties) # Add a single character\npurses.addstr(x, y, string, properties) # Add a string \n\n# Draw horizontal and vertical lines respectively\npurses.linehori(start_x, start_y, length, character, properties)\npurses.linevert(start_x, start_y, length, character, properties)\n\n# Draw a border around the window, left, right, top, bottom and its corners.\n# Each character should be complete with properties (\"c\", (None, None))\npurses.border(ls, rs, ts, bs, tl, tr, bl, br) \npurses.box(horizontal_sides, vertical_sides)\n\n# These calls only work from the main Purses() window.\npurses.refresh() # Refresh screen (place its state to the screen)\n# Return the mouse coordinates in characters, only callable from Purses()\n# If window is specified it will return its relative coordinates\npurses.getmouse(window) \n# Return a string as written by user\npurses.getstr(x, y, window=None, attr=(None, None))\n```\n\n\n", "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/momojohobo/panda3d-purses3d", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "panda3d-purses3d", "package_url": "https://pypi.org/project/panda3d-purses3d/", "platform": "", "project_url": "https://pypi.org/project/panda3d-purses3d/", "project_urls": { "Homepage": "https://github.com/momojohobo/panda3d-purses3d" }, "release_url": "https://pypi.org/project/panda3d-purses3d/0.0.9/", "requires_dist": [ "panda3d" ], "requires_python": "", "summary": "Ncurses-like text printing for Panda3D", "version": "0.0.9" }, "last_serial": 5485346, "releases": { "0.0.8": [ { "comment_text": "", "digests": { "md5": "baefaf7ea2928f4a260481ff83f8e4f6", "sha256": "17967315c7e09785bb6743c5c55ecfd8e44b12e7b93f1cc2527886e493085711" }, "downloads": -1, "filename": "panda3d_purses3d-0.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "baefaf7ea2928f4a260481ff83f8e4f6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 160642, "upload_time": "2019-07-03T18:36:58", "url": "https://files.pythonhosted.org/packages/bd/bc/e81ede86da70e85dbc2846239d449c2b8107ec3fe99e6a0b5f4c67cf51e5/panda3d_purses3d-0.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1f9246941ffeadc595a480a4c9438cf2", "sha256": "23e6214d9e4742dcfacf1927a072ff422341ad89cfbf6de103aa7cd400d7a6dc" }, "downloads": -1, "filename": "panda3d-purses3d-0.0.8.tar.gz", "has_sig": false, "md5_digest": "1f9246941ffeadc595a480a4c9438cf2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 159797, "upload_time": "2019-07-03T18:37:00", "url": "https://files.pythonhosted.org/packages/ce/7a/e58249c6d0f777634b8b51c3a7c0087428dd95276ae1d4a4d22f537b1709/panda3d-purses3d-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "466819b21416b749a641771963dc436a", "sha256": "34839ee6321a8c2c35f4881e91d87e213f027c1b00ce42096923356d1682ca06" }, "downloads": -1, "filename": "panda3d_purses3d-0.0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "466819b21416b749a641771963dc436a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 160655, "upload_time": "2019-07-04T07:38:54", "url": "https://files.pythonhosted.org/packages/3f/0f/135043627e2c601ecab6ccddbae5b671b6da22e3ee7c2a400c0b675f00aa/panda3d_purses3d-0.0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cc9ef0547a565d33eb1c8b1a2f321f82", "sha256": "5431c32ea3d60c8918c2fcf091492636f584a74e241f2c346de770a2594f916b" }, "downloads": -1, "filename": "panda3d-purses3d-0.0.9.tar.gz", "has_sig": false, "md5_digest": "cc9ef0547a565d33eb1c8b1a2f321f82", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 159819, "upload_time": "2019-07-04T07:38:56", "url": "https://files.pythonhosted.org/packages/fd/d1/9a838e3cd77cba549779452e8060e364c1e7483f271d9f9ad7310b2dfa64/panda3d-purses3d-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "466819b21416b749a641771963dc436a", "sha256": "34839ee6321a8c2c35f4881e91d87e213f027c1b00ce42096923356d1682ca06" }, "downloads": -1, "filename": "panda3d_purses3d-0.0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "466819b21416b749a641771963dc436a", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 160655, "upload_time": "2019-07-04T07:38:54", "url": "https://files.pythonhosted.org/packages/3f/0f/135043627e2c601ecab6ccddbae5b671b6da22e3ee7c2a400c0b675f00aa/panda3d_purses3d-0.0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cc9ef0547a565d33eb1c8b1a2f321f82", "sha256": "5431c32ea3d60c8918c2fcf091492636f584a74e241f2c346de770a2594f916b" }, "downloads": -1, "filename": "panda3d-purses3d-0.0.9.tar.gz", "has_sig": false, "md5_digest": "cc9ef0547a565d33eb1c8b1a2f321f82", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 159819, "upload_time": "2019-07-04T07:38:56", "url": "https://files.pythonhosted.org/packages/fd/d1/9a838e3cd77cba549779452e8060e364c1e7483f271d9f9ad7310b2dfa64/panda3d-purses3d-0.0.9.tar.gz" } ] }