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):
    # The add_button method creates a button that will close the popup
    # after the callback function is called, by default.
    popup.add_button('Do something', callback=do_something)
    popup.add_button("Do something (Keep window open)",
                        callback=do_something,
                        close=False)

    # The add_keybind method is a convenience method that adds a keybind
    # to the popup window
    popup.add_keybind('tab', lambda: print('Tabbing'))

    # 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)
    with popup as gui:
        gui.add_checkbox(label='Box', callback=do_something)

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

popup = Popup('^space', # Control + Space will toggle the popup
              build,
              width=1000,
              height=300,
              decorated=False, # Removes the title bar and close/minimize buttons
              anchor=Popup.ON_MOUSE)

popup.block()

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

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('^space', # Control + Space will toggle the popup
              build,
              width=200,
              height=200,
              anchor=Popup.ON_APP,
              application='ahk_exe notepad.exe')

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.2.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

popui-0.0.2-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

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