Last active
November 22, 2018 02:40
-
-
Save ladyrick/24b74ce75f624560bd8c8e5348b6259c to your computer and use it in GitHub Desktop.
python的message box
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
class PyMsgBox(): | |
def __init__(self): | |
from tkinter import Tk, messagebox | |
self.msgbox = messagebox | |
self.root = Tk() | |
self.root.wm_attributes('-topmost', 1) | |
self.root.withdraw() | |
def info(self, msg): | |
self.msgbox.showinfo("来自ladyrick的提示", msg) | |
def warning(self, msg): | |
self.msgbox.showwarning("来自ladyrick的警告", msg) | |
def error(self, msg): | |
self.msgbox.showerror("来自ladyrick的报错", msg) | |
def ask(self, msg): | |
return self.msgbox.askokcancel("来自ladyrick的询问", msg) | |
mytk = PyMsgBox() | |
mytk.info("萌高傻了……") | |
mytk.warning("萌高傻了。") | |
mytk.error("萌高傻了!") | |
if mytk.ask("萌高傻了?"): | |
print("萌高真的傻了。") | |
else: | |
print("萌高不傻。") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment