popui


Namepopui JSON
Version 0.0.12 PyPI version JSON
download
home_pagehttps://github.com/KyleTheScientist/popui
SummaryA Python module for creating GUI popups with Dear PyGui and AutoHotkey on Windows
upload_time2024-10-01 19:08:47
maintainerNone
docs_urlNone
authorKyleTheScientist
requires_pythonNone
licenseNone
keywords gui popup dearpygui autohotkey
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # popui

A Python module for creating GUI popups with Dear PyGui and AutoHotkey on Windows

## Installation

```bash
pip install popui
```

## Usage

To create a popup, first define a function that builds the GUI.

```python
from popui import Popup

def build(popup: Popup):
    popup.add_button('Do something', callback=lambda: print('Doing something'))
    popup.add_button("Do Nothing (Keep window open)", popup.no_op, close=False)
    popup.add_keybind('tab', lambda: print('Tabbing'))
```
The `popup.add_button()` method is a convenience method that creates a button that will close the popup window after the callback function is called by default.
The `add_keybind()` method is a convenience method that causes the provided callback to be called when the specified keybind is pressed while the window is active.


Then, create a `Popup` object with the function and any additional options that
you would typically pass to as arguments to a dearpygui viewport.

```python
if __name__ == '__main__':
    popup = Popup('^space', build, width=200, height=200) # Control + Space will toggle the popup
    popup.block()
```

The `block` method will block the current thread indefinitely. Pressing the hotkey
will toggle the popup window.


## Dear PyGui elements

For more complex GUIs, you can use the `gui` attribute of the popup to create a GUI with the same syntax as Dear PyGui. (See more at https://dearpygui.readthedocs.io/en/latest/index.html). If used as a context manager, any elements created within the context will be parented to the popup window automatically.

```python

popup.gui.add_text(label='Hello, world!', parent=popup.root)

with popup as gui:
    gui.add_checkbox(label='Box', callback=lambda: print('Box checked'))
    with gui.tab_bar():
        gui.add_tab(label='Tab 1')
        gui.add_tab(label='Tab 2')
```


## Application specific popups

You can create a popup that is specific to an application by using the `application`
parameter of the `Popup` class. This will ensure that the popup is only shown when
the specified application is in focus.

The application argument should be in autohotkey title format. For example, to create
a popup that is only shown when Notepad is in focus, you would use the following:


```python
popup = Popup('~!e',
              build,
              anchor=Popup.ON_APP,
              application='ahk_exe notepad.exe',
              decorated=False, # Removes the title bar and border from the viewport (much better looking imo)
              width=200,
              height=200).build()
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/KyleTheScientist/popui",
    "name": "popui",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "gui, popup, dearpygui, autohotkey",
    "author": "KyleTheScientist",
    "author_email": "kylethescientist@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d5/cc/c8117df508be56d5677dd818b196eb70cf3cd0564cc7373bc44d7ae72f60/popui-0.0.12.tar.gz",
    "platform": null,
    "description": "# popui\r\n\r\nA Python module for creating GUI popups with Dear PyGui and AutoHotkey on Windows\r\n\r\n## Installation\r\n\r\n```bash\r\npip install popui\r\n```\r\n\r\n## Usage\r\n\r\nTo create a popup, first define a function that builds the GUI.\r\n\r\n```python\r\nfrom popui import Popup\r\n\r\ndef build(popup: Popup):\r\n    popup.add_button('Do something', callback=lambda: print('Doing something'))\r\n    popup.add_button(\"Do Nothing (Keep window open)\", popup.no_op, close=False)\r\n    popup.add_keybind('tab', lambda: print('Tabbing'))\r\n```\r\nThe `popup.add_button()` method is a convenience method that creates a button that will close the popup window after the callback function is called by default.\r\nThe `add_keybind()` method is a convenience method that causes the provided callback to be called when the specified keybind is pressed while the window is active.\r\n\r\n\r\nThen, create a `Popup` object with the function and any additional options that\r\nyou would typically pass to as arguments to a dearpygui viewport.\r\n\r\n```python\r\nif __name__ == '__main__':\r\n    popup = Popup('^space', build, width=200, height=200) # Control + Space will toggle the popup\r\n    popup.block()\r\n```\r\n\r\nThe `block` method will block the current thread indefinitely. Pressing the hotkey\r\nwill toggle the popup window.\r\n\r\n\r\n## Dear PyGui elements\r\n\r\nFor more complex GUIs, you can use the `gui` attribute of the popup to create a GUI with the same syntax as Dear PyGui. (See more at https://dearpygui.readthedocs.io/en/latest/index.html). If used as a context manager, any elements created within the context will be parented to the popup window automatically.\r\n\r\n```python\r\n\r\npopup.gui.add_text(label='Hello, world!', parent=popup.root)\r\n\r\nwith popup as gui:\r\n    gui.add_checkbox(label='Box', callback=lambda: print('Box checked'))\r\n    with gui.tab_bar():\r\n        gui.add_tab(label='Tab 1')\r\n        gui.add_tab(label='Tab 2')\r\n```\r\n\r\n\r\n## Application specific popups\r\n\r\nYou can create a popup that is specific to an application by using the `application`\r\nparameter of the `Popup` class. This will ensure that the popup is only shown when\r\nthe specified application is in focus.\r\n\r\nThe application argument should be in autohotkey title format. For example, to create\r\na popup that is only shown when Notepad is in focus, you would use the following:\r\n\r\n\r\n```python\r\npopup = Popup('~!e',\r\n              build,\r\n              anchor=Popup.ON_APP,\r\n              application='ahk_exe notepad.exe',\r\n              decorated=False, # Removes the title bar and border from the viewport (much better looking imo)\r\n              width=200,\r\n              height=200).build()\r\n```\r\n\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python module for creating GUI popups with Dear PyGui and AutoHotkey on Windows",
    "version": "0.0.12",
    "project_urls": {
        "Homepage": "https://github.com/KyleTheScientist/popui"
    },
    "split_keywords": [
        "gui",
        " popup",
        " dearpygui",
        " autohotkey"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d7a5c86def9252ea824421289fc26afcdf5eafca5cf29ce597a75fc56cfd6824",
                "md5": "7ffdcd430a3837f5563f6a4d7341def7",
                "sha256": "ab7a785465b935fdf2b8edcb2b4c01780ae88d8377282a87fbe025414daa25b1"
            },
            "downloads": -1,
            "filename": "popui-0.0.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7ffdcd430a3837f5563f6a4d7341def7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10915,
            "upload_time": "2024-10-01T19:08:46",
            "upload_time_iso_8601": "2024-10-01T19:08:46.559035Z",
            "url": "https://files.pythonhosted.org/packages/d7/a5/c86def9252ea824421289fc26afcdf5eafca5cf29ce597a75fc56cfd6824/popui-0.0.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d5ccc8117df508be56d5677dd818b196eb70cf3cd0564cc7373bc44d7ae72f60",
                "md5": "9870b2a443833218e731060b7ba86329",
                "sha256": "6c27af00463ae84b51e5a61db133270c843b8995176d948da61626c6705ba852"
            },
            "downloads": -1,
            "filename": "popui-0.0.12.tar.gz",
            "has_sig": false,
            "md5_digest": "9870b2a443833218e731060b7ba86329",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11636,
            "upload_time": "2024-10-01T19:08:47",
            "upload_time_iso_8601": "2024-10-01T19:08:47.920270Z",
            "url": "https://files.pythonhosted.org/packages/d5/cc/c8117df508be56d5677dd818b196eb70cf3cd0564cc7373bc44d7ae72f60/popui-0.0.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-01 19:08:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "KyleTheScientist",
    "github_project": "popui",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "popui"
}
        
Elapsed time: 0.33858s