{ "info": { "author": "Joe Cross", "author_email": "joe.mcross@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "===================\nGritty\n===================\n\n*( Gritty is based on Jordan Zanatta's* |pyGrid|_ *)*\n\nGritty is designed to provide an easy-to-use grid component, with\nreasonable performance for small grids (~ 100x100).\n\nGritty supports custom cell attributes, including default values and coercion functions,\nand tries to provide an easy interface for manipulating multiple cells at once.\n\nTry it out!\n----------------------------\n\nImport the multi-sect module and click and drag::\n\n import gritty.demos.multi_select\n\nSimply import any of the other demos to see what gritty can do for you.\n\n\nUsage\n----------------------------\nTypical Grid setup often looks like this::\n\n #!/usr/bin/env python\n\n import pygame\n from gritty import grid\n\n # Set up args and kwargs\n\n pygame.init()\n grid = Grid(*args, **kwargs)\n grid_pos = (0, 0)\n screen = pygame.display.set_mode(grid.render_dimensions)\n\n while True:\n # Do stuff to the grid\n screen.blit(grid.surface, grid_pos)\n\n\nNote the ``grid.surface`` in the while loop - gritty caches the grid surface,\nand only redraws cells that have changed since the last time it was rendered.\n\n\nGrid Initialization\n===================\n\n\nGrid has 4 required arguments - number of rows, number of columns, and cell width in pixels, and cell height in pixels. Beyond that, you can specify values for cell color, cell border color, cell border size, and cell radius. All of these are optional, and will use default settings as specified in ``Grid.__init__()``. Note that these are a mix of grid properties and cell attribute defaults - see the following sections for more info on how to use each.\n\nFrom the previous section, \"set up args and kwargs\" may look something like this::\n\n rows = 20\n columns = 20\n cell_width = 25\n cell_height = 25\n COLOR_OFF = (000, 000, 255)\n COLOR_ON = (255, 255, 51)\n\n args = [\n rows,\n columns,\n cell_width,\n cell_height\n ]\n\n kwargs = {\n 'cell_color_default': COLOR_OFF,\n 'cell_border_color': (000, 000, 000),\n 'cell_border_size': 3,\n 'cell_radius': 5,\n }\n\n pygame.init()\n grid = Grid(*args, **kwargs)\n\nMost of the above can be found in the ``basic_grid`` function in the demos folder, which sets up a basic grid for each demo.\n\nCell Attributes\n===================\n\nAttribute Defaults\n----------------------------\n\ngrid.cell_attr holds the list of default values for cell attributes.\nNote that you can still adjust arbitrary attributes of cells without adding a default ot grid.cell_attr. However, empty cells will not have a value for that attribute.\n\nAdding, removing, or updating defaults will trigger a full redraw the next time the surface is rendered.\n\nTo change the default color::\n\n grid = Grid(10, 10, 2, 2)\n grid.cel_attr['color'] = [255, 0, 0] # Set default color to red\n\nTo add an 'alive' attribute, such as for the Game of Life::\n\n grid = Grid(10, 10, 2, 2)\n grid.cell_attr['alive'] = False # By default, cells are dead\n\n\nAttribute Coercion Functions\n----------------------------\n\nColor values can be specified as (R,G,B) or (R,G,B,A). Instead of manually checking the length each time we get or set the value, we can add an intercepting coercion function. The color coercion function below is included by default::\n\n def coerce_alpha(input):\n '''Default to full opacity'''\n if len(input) == 3:\n input = list(input)\n input.append(255)\n return input\n \n grid = Grid(10, 10, 2, 2)\n grid.cell_attr_coercion_funcs['color'] = coerce_alpha\n grid[1,1].color = (0, 1, 2)\n print grid[1,1]\n\nCurrently, one coercion function is used for both set and get, so a function which doubled the red value of a color would double it when set, and double the return value of get. This feature hasn't been fully designed out yet, so it could change significantly (or be cut altogether).\n\nGrid Properties\n===================\n\nChanging a grid property will trigger a full redraw the next time the surface is rendered. Be aware that ``grid.hit_check`` will use the new values immediately - be sure to check input **after** drawing the grid so that the mouse interaction you are testing is against the correct dimensions.\n\nGrid properties are:\n\n* ``rows`` - number of rows of cells in the grid\n\n* ``columns`` - number of columns of cells in the grid\n\n* ``cell_width`` - width in pixels of a cell (interior, without border)\n\n* ``cell_height`` - height in pixels of a cell (interior, without border)\n\n* ``cell_border_size`` - thickness in pixels of the border between cells and around the grid\n\n.. _pyGrid: https://github.com/GordonZed/pyGrid\n\n.. |pyGrid| replace:: *pyGrid*", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/numberoverzero/gritty", "keywords": null, "license": "LGPL.txt", "maintainer": null, "maintainer_email": null, "name": "Gritty", "package_url": "https://pypi.org/project/Gritty/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Gritty/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/numberoverzero/gritty" }, "release_url": "https://pypi.org/project/Gritty/0.1.3/", "requires_dist": null, "requires_python": null, "summary": "A basic module for rendering a grid using pygame", "version": "0.1.3" }, "last_serial": 668778, "releases": { "0.1.0": [], "0.1.2": [ { "comment_text": "", "digests": { "md5": "5ff7f1b96845ac8f39d90ad00368a9e1", "sha256": "eef1a7d2f7cbd5bcbd899d11e66c4e33837f037d25f5549b49e1c7f286f90c29" }, "downloads": -1, "filename": "Gritty-0.1.2.zip", "has_sig": false, "md5_digest": "5ff7f1b96845ac8f39d90ad00368a9e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28766, "upload_time": "2013-03-31T03:54:29", "url": "https://files.pythonhosted.org/packages/ee/65/bb2a2dde98b141640a38f596b44f6bc7ec13529206d59f50753e02898b2e/Gritty-0.1.2.zip" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "c2ebdc7364e0b2ae9e3308c4389b08aa", "sha256": "c0651fe5f6bc5aa56e6a55ba2ce667ce12cf7ba20482ac4a00bcfb912f979e34" }, "downloads": -1, "filename": "Gritty-0.1.3.zip", "has_sig": false, "md5_digest": "c2ebdc7364e0b2ae9e3308c4389b08aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30637, "upload_time": "2013-03-31T23:46:19", "url": "https://files.pythonhosted.org/packages/9e/06/e8631daf25e0386a225710781e4da350cabbf34cc83038751fb120cd1f27/Gritty-0.1.3.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c2ebdc7364e0b2ae9e3308c4389b08aa", "sha256": "c0651fe5f6bc5aa56e6a55ba2ce667ce12cf7ba20482ac4a00bcfb912f979e34" }, "downloads": -1, "filename": "Gritty-0.1.3.zip", "has_sig": false, "md5_digest": "c2ebdc7364e0b2ae9e3308c4389b08aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30637, "upload_time": "2013-03-31T23:46:19", "url": "https://files.pythonhosted.org/packages/9e/06/e8631daf25e0386a225710781e4da350cabbf34cc83038751fb120cd1f27/Gritty-0.1.3.zip" } ] }