{"id":19745729,"url":"https://github.com/volatile-programming/pyplace","last_synced_at":"2025-02-27T23:47:47.015Z","repository":{"id":49252094,"uuid":"273582741","full_name":"volatile-programming/pyplace","owner":"volatile-programming","description":"A utility to stop remembering tons of numbers and start using percentages for objects size and placement.","archived":false,"fork":false,"pushed_at":"2021-06-21T20:47:18.000Z","size":56,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-11T16:02:53.931Z","etag":null,"topics":["beta","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pyplace/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/volatile-programming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-19T20:41:19.000Z","updated_at":"2021-06-21T20:47:21.000Z","dependencies_parsed_at":"2022-08-20T14:10:35.039Z","dependency_job_id":null,"html_url":"https://github.com/volatile-programming/pyplace","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volatile-programming%2Fpyplace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volatile-programming%2Fpyplace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volatile-programming%2Fpyplace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/volatile-programming%2Fpyplace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/volatile-programming","download_url":"https://codeload.github.com/volatile-programming/pyplace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241077196,"owners_count":19905725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beta","python","python3"],"created_at":"2024-11-12T02:11:04.518Z","updated_at":"2025-02-27T23:47:46.997Z","avatar_url":"https://github.com/volatile-programming.png","language":"Python","readme":"# pyplace (a place by percentage Python package)\r\n\r\n### _Full definition:_\r\n\r\nPyplace is a easy to use package to get the placement and dimensions of a child container base on the percentage given the size of a parent container and/or the relative origin of the child and parent containers.\r\n\r\n### _In a few words definition:_\r\n\r\nA littler utility to stop remembering tons of numbers and start using percentages for containers size and placement.\r\n\r\n## Installation\r\n\r\n### _Using the pip installer_\r\n\r\n```bash\r\n  $ python -m pip install pyplace\r\n```\r\n\r\n### _Using the offline installer or source code_\r\n\r\n-   a. Download the .whl file from one of our release and run:\r\n\r\n```bash\r\n  $ python -m pip install pyplace-file-name.whl\r\n```\r\n\r\n\u003e Been **pyplace-file-name** the name of the file downloaded.\r\n\r\n-   b. If you clone or download the .zip file and then extract it. the repo you just have to go to the repository path and run:\r\n\r\n```bash\r\n  $ python setup.py install\r\n```\r\n\r\n## Usage\r\n\r\n```python\r\nfrom pyplace.pbd import *\r\n```\r\n\r\nIs the main package module it contains two methods _get_container()_ and _get_child_container()_ witch will be described in more details down below:\r\n\r\n**get_container(parent_size: tuple, percentages: tuple, origin: tuple = None)**\r\n\r\n```python\r\n  \"\"\"Gets a new parent container base on the size and percentages given.\r\n\r\n  Args:\r\n                  parent_size: The width and height size reference for the new parent container.\r\n                  percentages: The width and height percentages to get the size for the new parent container.\r\n      (optional)  origin: The x and y coordinates to place the new parent container.\r\n\r\n  Raises:\r\n      TypeError: If an argument variable was not send as a tuple.\r\n\r\n  Returns:\r\n      A Container class with the x, y, width and height values for the new parent container.\r\n  \"\"\"\r\n```\r\n\r\n**get_child_container(parent_container: Container, size_percentages: tuple, place_percentages: tuple = (0,0))**\r\n\r\n```python\r\n  \"\"\"Gets a new child container base on the parent container and size percentages given.\r\n\r\n  Args:\r\n                  parent_container: The x, y, width and height value of the parent container.\r\n                  size_percentages: The width and height percentages to get the size for the new child container.\r\n      (optional)  place_percentages: The x and y percentages to get the placement for the new child container.\r\n\r\n  Raises:\r\n      TypeError: If an argument variable was not send as a tuple.\r\n\r\n  Returns:\r\n      A Container class with the x, y, width and height values for the new child container.\r\n  \"\"\"\r\n```\r\n\r\n### Example:\r\n\r\n```python\r\n  # full screen window with a window container and four child containers.\r\n  from pyplace.pbp import get_container, get_child_container\r\n\r\n  # we assume the display resolution is 1280x720 for this example.\r\n  import pyautogui\r\n  # Returns: tuple(1280, 720)\r\n  screen_width, screen_height = pyautogui.size()\r\n\r\n  window = get_container(parent_size=(screen_with, screen_height), percentages=(1, 1))\r\n  # Returns: tuple(0, 0, 1280, 720)\r\n  window.get_dimensions()\r\n\r\n  upper_left_box = get_child_container(parent_container=window, size_percentages=(0.5, 0.5))\r\n  # Returns: tuple(0, 0, 640, 360)\r\n  upper_left_box.get_dimensions()\r\n\r\n  lower_left_box = get_child_container(parent_container=window, size_percentages=(0.5, 0.5), place_percentages=(0, 0.5))\r\n  # Returns: tuple(0, 360, 640, 360)\r\n  lower_left_box.get_dimensions()\r\n\r\n  upper_right_box = get_child_container(parent_container=window, size_percentages=(0.5, 0.5), place_percentages=(0.5, 0))\r\n  # Returns: tuple(640, 0, 640, 360)\r\n  upper_right_box.get_dimensions()\r\n\r\n  lower_right_box = get_child_container(parent_container=window, size_percentages=(0.5, 0.5), place_percentages=(0.5, 0.5))\r\n  # Returns: tuple(640, 360, 640, 360)\r\n  lower_right_box.get_dimensions()\r\n```\r\n\r\n\u003e This will create one parent (main target) and four children (relative to the main target) containers.\r\n\r\n## Container\r\n\r\nwhen we call the _get_container_ or _get_child_container_ we get a Container instance that we can use for getting a tuple of single variables holding the size and placement information for the container we created.\r\n\r\nhere are the attributes and method we get on this class:\r\n\r\n```python\r\n  # attribute list.\r\n  __x       # the container x position.\r\n  __y       # the container x position.\r\n  __width   # the container width size.\r\n  __height  # the container height size.\r\n\r\n  # method list.\r\n  get_x()                             # returns the x value for the container.\r\n  x(x: int)                       # sets the x value for the container.\r\n\r\n  get_y()                             # returns the y value for the container.\r\n  y(y: int)                       # sets the y value for the container.\r\n\r\n  get_placement()                     # returns a tuple with the x and y of the container.\r\n  placement(x: int, y: int)       # sets the x and y of the container.\r\n\r\n  get_width()                         # returns the width value for the container.\r\n  width(width: int)               # sets the width value for the container.\r\n\r\n  get_height()                        # returns the height value for the container.\r\n  height(height: int)             # sets the height value for the container.\r\n\r\n  get_size()                          # returns a tuple with the width and height of the container.\r\n  size(width: int, height: int)   # sets the width and height of the container.\r\n\r\n  get_dimensions()                    # returns a tuple with the x, y, width and height of the container.\r\n  dimensions(x: int, y: int, width: int, height: int)  # sets the x, y, width and height of the container.\r\n```\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolatile-programming%2Fpyplace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvolatile-programming%2Fpyplace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolatile-programming%2Fpyplace/lists"}