Skip to main content

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

Project description

popui

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

Installation

pip install popui

Usage

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

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.

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.

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:

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

popui-0.0.15.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

popui-0.0.15-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file popui-0.0.15.tar.gz.

File metadata

  • Download URL: popui-0.0.15.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for popui-0.0.15.tar.gz
Algorithm Hash digest
SHA256 55ab8e247a7c3a81cab61d6c5f2dd9e1baaada9e58e44d51e19b91c027dc0013
MD5 178ac31a601874de9d231fa4f488ce3a
BLAKE2b-256 1e3af2eaa016a0208d93f67602bce5c7161a2485568397bda7d85c74b072227f

See more details on using hashes here.

File details

Details for the file popui-0.0.15-py3-none-any.whl.

File metadata

  • Download URL: popui-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for popui-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 8889446337d5c7c66034f3943d9b1f2151c8b262f87f9eb5b7ebc1a2a252c8f3
MD5 28e170a88e66d843b9ec44c6c01aba30
BLAKE2b-256 c1e59ab08527aea30b59e33be0eccd7408f78e18b3f0aedbda8bd5c378f63c39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page