fixed tkMessageBox problem, thanks Bruno
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
try:
|
||||
import tkMessageBox
|
||||
import Tkinter
|
||||
except:
|
||||
tkMessageBox = None
|
||||
Tkinter = None
|
||||
|
||||
|
||||
class MessageBoxHandler(logging.Handler):
|
||||
@@ -11,6 +12,24 @@ class MessageBoxHandler(logging.Handler):
|
||||
logging.Handler.__init__(self)
|
||||
|
||||
def emit(self, record):
|
||||
if tkMessageBox:
|
||||
if Tkinter:
|
||||
msg = self.format(record)
|
||||
tkMessageBox.showinfo('info1', msg)
|
||||
root = Tkinter.Tk()
|
||||
root.wm_title("web2py logger message")
|
||||
text = Tkinter.Text()
|
||||
text["height"] = 12
|
||||
text.insert(0.1, msg)
|
||||
text.pack()
|
||||
button = Tkinter.Button(root, text="OK", command=root.destroy)
|
||||
button.pack()
|
||||
root.mainloop()
|
||||
|
||||
|
||||
class NotifySendHandler(logging.Handler):
|
||||
def __init__(self):
|
||||
logging.Handler.__init__(self)
|
||||
|
||||
def emit(self, record):
|
||||
if Tkinter:
|
||||
msg = self.format(record)
|
||||
os.system("notify-send '%s'" % msg)
|
||||
|
||||
Reference in New Issue
Block a user