forked from yncat/screamingstrike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdialog.py
25 lines (21 loc) · 813 Bytes
/
dialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
# Simple crossplatform dialog
# Copyright (C) 2019 Yukio Nozawa <[email protected]>
# License: GPL V2.0 (See copying.txt for details)
import platform
import ctypes
import subprocess
import re
def dialog(title, message):
"""Shows messageBox on win and mac.
:param title: Title.
:type title: str
:paramessage: Message body.
:type message: str
"""
if platform.system() == "Windows":
ctypes.windll.user32.MessageBoxW(0, message, title, 0x00000040)
else:
str = "display dialog \"%s\" with title \"%s\" with icon note buttons {\"OK\"}" % (
re.sub(r'"\'', " ", message), re.sub(r'"\'', " ", title)) # escaping ' and " on mac
subprocess.call("osascript -e '{}'".format(str), shell=True)