{ "info": { "author": "James Draper", "author_email": "james.draper@duke.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Build Tools", "Topic :: System :: Systems Administration" ], "description": "# sneakers\nA TkInter wrapper for python inspired by the GUI library Shoes for Ruby.\n\nThis is intended to make it easier to create simple GUI interfaces quickly. All these classes inheret from their TkInter counterparts so you can use them just as you would their original TkInter counterparts if need be.\n\nTo use this library you can star import to get access to all classes and functions;\n```python\nfrom sneakers import *\n```\nHow to create windows\n--\n\nContext managers are used to create windows, stacks (columns) and flows (rows).\n\nFor example, this is how a context manager is used to make a window;\n\n\n\n\n\n\n\n\n\n
\nCODE\n\nGUI\n
\n
\nfrom sandals import *\n\nwith window(\"My window\"):\n  label(\"Hello world\")\n
\n
\n\n
\n\nThe way stacks and flows work was intended to be the same as with the Ruby library Shoes, but it's not quite there yet.\nInfo on how they're meant to work can be found on the Ruby Shoes website: http://shoesrb.com/\n\nAs mentioned below, the library needs to be ideally be rewritten to use TkInter grids, rather than just packing elements in different ways, which is something I'm working on at the moment.\nThe @button and other GUI decorators\n--\n\nAdding the decorator\n```python\n@button\n```\nto a function adds a button that triggers that function. The button is located in whatever context manager the function is defined in.\n\n\nFor example, this code will create a window with a button, which when clicked will create a popup;\n\n\n\n\n\n\n\n\n\n
\nCODE\n\nGUI\n
\n
\nfrom sandals import *\n\nwith window():\n\n  @button(\"Create a popup box\")\n  def makePopupBox():\n    showInfo(message = \"You clicked the button\")\n
\n
\n\n
\n\nCheckboxes, radio buttons, spin boxes, scale bars, and option menus can all be applied as decorators in a similar way. They are also located in whatever context manager (window, stack or flow) the function is defined in.\nFor example, here is a simple implementation of a check box to change a boolean;\n\n```python\n@checkBox(\"Is the oven on?\", checked = True)\ndef ovenOn(checked):\n\ttheOvenIsOn = checked\n```\n\nAnd here is a simple example of how to implement an options menu;\n\n```python\nlabel(\"How's the oven?\")\n@optionMenu(\"clean\", \"dirty\", \"broken\")\ndef ovenState(option):\n\tprint \"The oven is\", option\n```\n\nAll these decorators can also be used as classes where this is more convenient.\nManipulating buttons\n---\nBecause these decorators inherit from their TkInter classes, they can be used as normal (i.e. not as decorators) and then configured using e.g. ```my_button.config(**kwargs)```.\n\nButtons can be altered even when created as a decorator, as they are added as a function attribute of the function they are applied to, so can be accessed via e.g. ```my_function.button```.\n\nAll the TkInter adjectives used to modify buttons - such as ```DISABLE``` and ```NORMAL``` which describe the state of a disabled and enabled button respectively - are imported as well.\n\nHere is an example where this method is used to disable a button created using a decorator;\n\n\n\n\n\n\n\n\n\n
\nCODE\n\nGUI\n
\n
\nfrom sandals import *\n\nwith window():\n\n\t@button(\"This button does nothing\")\n\tdef doNothing():\n\t\tpass\n\n\t@button(\"Disable button\")\n\tdef disableButton():\n\t\tdoNothing.button.config(state = DISABLED)\n
\n
\n\n
\n\nThe @repeat and @loop decorators\n---\nTwo new decorators are included which you might not necessarily associate with a GUI library;\nThe ``@repeat`` and ``@loop`` decorators.\n\nThese create a thread that repeats or loops the function the decorator is applied to. Once the context the decorated function is defined in is destroyed (e.g. closing a window) then that thread is stopped and the function will stop repeating or looping. As an example, here is a function that repeats once a minute;\n\n```python\n@repeat(60)\ndef clock():\n\tprint \"A minute has passed\"\n```\n\nThe repeat and loop decorators are inspired by similar methods in Shoes, which turn out to be more useful than you might expect when designing a GUI.\n\nChanging and reading text in GUI elements\n--\n\nHow the text in labels and other GUI elements is changed to try and make them easier to work with.\n\nA slightly more complex example that demonstrates this;\n\n\n\n\n\n\n\n\n\n
\nCODE\n\nGUI\n
\n
\nfrom sandals import *\nwith window(\"This is a window\"):\n    label(\"This is a label\",\n    font = \"Verdana 24 bold underline\")\n    with stack(padx=10):\n        myLabel = label(\"This text changes\")\n        @button(\"Change the above text\",\n            font = \"Veranda 12 italic\")\n        def change_that_text():\n            myLabel.text = \"OMG it changed\"\n        with flow(pady=10):\n            edit = editBox(\"edit me\")\n            @button(\"<-read edit box\")\n            def read_edit_box():\n                showInfo(message\n\t\t\t\t= \"Edit box says: \"\n\t\t\t\t+ edit.text)\n
\n
\n\n
\nComplete example\n--\n\n`example.py` has a more complete example of how to use the different methods, context managers, etc. which should look like this;\n\n\n\n\n\n\n\n\n
\nGUI\n
\n\n
\n\n\n# TO DO LIST\n- Add to pip.\n- Add support for ttk\n- Rewrite to use tkinter grids as well as pack.\n- Retools this readme.\n- Add attribution from previous repositories.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/draperjames/sneakers", "keywords": "gui,shoes,tkinter", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "sneakers", "package_url": "https://pypi.org/project/sneakers/", "platform": "POSIX", "project_url": "https://pypi.org/project/sneakers/", "project_urls": { "Homepage": "https://github.com/draperjames/sneakers" }, "release_url": "https://pypi.org/project/sneakers/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Ruby shoes flavored tkinter.", "version": "0.0.1" }, "last_serial": 3338980, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "a5e7e9a3057a3b56d871d8b2efec041c", "sha256": "4e61eb4dade4807308746246a21fd10f2c16c0e785567667f0caa893651507cf" }, "downloads": -1, "filename": "sneakers-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a5e7e9a3057a3b56d871d8b2efec041c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17752, "upload_time": "2017-11-16T15:37:29", "url": "https://files.pythonhosted.org/packages/ab/cc/d686595862f11bb60bf3f54e8035fa0f6b9a69a78202e7a9e837d212289c/sneakers-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4671689ec129e28edb39aef74709b3a4", "sha256": "e1b715c8595c492816d64979ac3b4347d58c228b96eb822455bfc23b8a4eff8e" }, "downloads": -1, "filename": "sneakers-0.0.1.tar.gz", "has_sig": false, "md5_digest": "4671689ec129e28edb39aef74709b3a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11444, "upload_time": "2017-11-16T15:37:30", "url": "https://files.pythonhosted.org/packages/00/27/1d970b72bb4ef829990ae741b4de2702f52a86af3ed669a103a3c1196d19/sneakers-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a5e7e9a3057a3b56d871d8b2efec041c", "sha256": "4e61eb4dade4807308746246a21fd10f2c16c0e785567667f0caa893651507cf" }, "downloads": -1, "filename": "sneakers-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a5e7e9a3057a3b56d871d8b2efec041c", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 17752, "upload_time": "2017-11-16T15:37:29", "url": "https://files.pythonhosted.org/packages/ab/cc/d686595862f11bb60bf3f54e8035fa0f6b9a69a78202e7a9e837d212289c/sneakers-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4671689ec129e28edb39aef74709b3a4", "sha256": "e1b715c8595c492816d64979ac3b4347d58c228b96eb822455bfc23b8a4eff8e" }, "downloads": -1, "filename": "sneakers-0.0.1.tar.gz", "has_sig": false, "md5_digest": "4671689ec129e28edb39aef74709b3a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11444, "upload_time": "2017-11-16T15:37:30", "url": "https://files.pythonhosted.org/packages/00/27/1d970b72bb4ef829990ae741b4de2702f52a86af3ed669a103a3c1196d19/sneakers-0.0.1.tar.gz" } ] }