-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51898fa
commit 2380806
Showing
1 changed file
with
24 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# Simple cross-platform dialog | ||
# Copyright (C) 2019 Yukio Nozawa <[email protected]> | ||
# 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) | ||
|
||
|