main
Last change
on this file was
42bd667,
checked in by David Fuertes <dfuertes@…>, 4 years ago
|
Historial Limpio
|
-
Property mode set to
100755
|
File size:
953 bytes
|
Line | |
---|
1 | import logging |
---|
2 | import os |
---|
3 | import sys |
---|
4 | |
---|
5 | try: |
---|
6 | if sys.version_info[0] == 2: |
---|
7 | import Tkinter as tkinter |
---|
8 | else: |
---|
9 | import tkinter |
---|
10 | except ImportError: |
---|
11 | tkinter = None |
---|
12 | |
---|
13 | |
---|
14 | class MessageBoxHandler(logging.Handler): |
---|
15 | def __init__(self): |
---|
16 | logging.Handler.__init__(self) |
---|
17 | |
---|
18 | def emit(self, record): |
---|
19 | if tkinter: |
---|
20 | msg = self.format(record) |
---|
21 | root = tkinter.Tk() |
---|
22 | root.wm_title("web2py logger message") |
---|
23 | text = tkinter.Text() |
---|
24 | text["height"] = 12 |
---|
25 | text.insert(0.1, msg) |
---|
26 | text.pack() |
---|
27 | button = tkinter.Button(root, text="OK", command=root.destroy) |
---|
28 | button.pack() |
---|
29 | root.mainloop() |
---|
30 | |
---|
31 | |
---|
32 | class NotifySendHandler(logging.Handler): |
---|
33 | def __init__(self): |
---|
34 | logging.Handler.__init__(self) |
---|
35 | |
---|
36 | def emit(self, record): |
---|
37 | if tkinter: |
---|
38 | msg = self.format(record) |
---|
39 | os.system("notify-send '%s'" % msg) |
---|
Note: See
TracBrowser
for help on using the repository browser.