From 23808065484cbc743d139e20f8a4d4455b963749 Mon Sep 17 00:00:00 2001 From: Kazto Kitabatake Date: Sun, 29 Aug 2021 17:08:35 +0900 Subject: [PATCH] =?UTF-8?q?simpleDialog=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simpleDialog.py | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/simpleDialog.py b/simpleDialog.py index 7113dc3..6cd9fe4 100644 --- a/simpleDialog.py +++ b/simpleDialog.py @@ -1,21 +1,23 @@ # -*- coding: utf-8 -*- -# Simple cross-platform dialog -# Copyright (C) 2019 Yukio Nozawa -# Note: The current implementation only supports win32 and OSX. +# Simple dialog -import platform +import wx import ctypes -import subprocess -import re +import sys -def dialog(title, message): - 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) +def dialog(title, message, parent=None): + dialog = wx.MessageDialog(parent, message, title, wx.OK) + dialog.ShowModal() + dialog.Destroy() + return + + +def yesNoDialog(title, message, parent=None): + dialog = wx.MessageDialog(parent, message, title, wx.YES_NO) + result = dialog.ShowModal() + dialog.Destroy() + return result def errorDialog(message, parent=None): @@ -25,6 +27,15 @@ def errorDialog(message, parent=None): return +def debugDialog(message): + if hasattr(sys, "frozen") == False: + import pprint + dialog = wx.MessageDialog(None, pprint.pformat(message), "debug", wx.OK) + dialog.ShowModal() + dialog.Destroy() + return + + def winDialog(title, message): ctypes.windll.user32.MessageBoxW(0, message, title, 0x00000040)