Code Monkey home page Code Monkey logo

aquaui's Introduction


aquaui

Display native dialogs, alerts, notifications, color pickers, and more with Python

GitHub Workflow Status Version PyPI - Downloads MIT Buy Me A Coffee

๐Ÿ’ฅ This library is still a work in progress.

Useful links

Features

  • Display dialogs
    • Dialog prompts
    • Icon support
  • Alerts
  • Choice dialogs
  • Notifications
    • Customize title, subtitle, and informational text
    • Customize icon
    • Schedulable
    • Callbacks (button pressed, reply text) โ€“ relevant stackoverflow answer
    • Fallback (AppleScript) notifications
  • Color picker
  • File/folder picker

Documentation

Find the documentation in the docs/ folder

Examples

See the examples/ directory. Feel free to make a pull request to add more examples.

Show a dialog with the buttons "Go" (default) and "No" (to cancel) with the caution icon:

from aquaui import Dialog, Buttons, Icon

buttons = Buttons(["Go", "No"], default_button="Go", cancel_button="No")
result = Dialog("Hello!").with_buttons(buttons).with_icon(Icon.CAUTION).show()

Execute functions based on the button clicked:

from aquaui import Dialog, Buttons

button_one = "One"
button_two = "Two"
buttons = Buttons([button_one, button_two])

result = Dialog("Press a button").with_buttons(buttons).show()

if result.button_returned == button_one:
  print("Button One was pressed")
elif result.button_returned == button_two:
  print("Button Two was pressed")

Display a choice dialog with the options "Netflix" and "Prime Video"

from aquaui import Choice

provider = Choice("Choose the streaming platform").with_choices(["Netflix", "Prime Video"]).show()
print(provider)

If this example interests you, check out my other library Flixpy.

Display a notification:

Warning: please read the documentation before using notifications. There are additional dependencies to install.

from aquaui.notification.native_notification import Notification

notification = (
    Notification("Hello!")
    .with_subtitle("This is the subtitle!")
    .with_informative_text("Isn't this informative?")
    .with_identity_image("assets/folder.png")  # the image on the right of the notification
    .send()
)

Schedule a notification:

from aquaui.notification.native_notification import Notification

notification = Notification("Your pizza is here!").with_delay(15).send()
# 15 seconds delay

Build setup

Clone or fork the repository, then run

poetry shell

poetry install
pre-commit install

Make changes, then run tests with

pytest tests

Ensure that all tests pass.

Recommended editor settings
{
  "python.formatting.provider": "black",
  "editor.formatOnSave": true,
  "[python]": {
    "editor.insertSpaces": true,
    "editor.detectIndentation": false,
    "editor.tabSize": 4
  },
  "python.linting.enabled": true,
  "python.linting.flake8Enabled": true,
  "python.linting.pylintEnabled": false,
  "python.pythonPath": "/Users/yourusername/.../aquaui-UIHDsdfS-py3.7"
}

License

MIT

aquaui's People

Contributors

dependabot[bot] avatar ninest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

aquaui's Issues

Escaping double quotes

Single quotes work fine, but double quotes don't.

All double quotes are escaped:

script = script.replace('"', '\\"')

and this causes issues when there are double quotes in the string.

from aquaui import Alert, Buttons

# Works
Alert("How're you?").show()

# Doesn't work
Alert('How"re you?').show()
Alert('How\\"re you?').show()

Change the way an applescript is generated

Currently, an applescript is generated as a string. Nothing too complex to it. The problem is that it's easy to miss out a space here or there

self.applescript = f"display dialog {quotify(text)} "
# Notice the space at the end

It may be better to do something like

self.applescript = ["display dialog", quotify(text)]

...

# Adding title
self.applescript.extend(["with title", quotify(title)])

Then using a loop, create the applescript and appropriately put spaces

Telling and titles for dialog

tell application "Brave Browser" to display dialog "Some Message from Brave" with title "A title"

This will show a dialog with a title at the top, and move focus to Brave Browser.

If you tell application then display an alert, it will show Brave's icon.

But showing a notification after tell will not change the notification's icon, unfortunately.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.