Update Python 3 compatibility

This commit is contained in:
Vinyl Darkscratch
2019-02-09 00:01:11 -08:00
parent fcea326855
commit f434ebec8a
29 changed files with 112 additions and 152 deletions
+11 -7
View File
@@ -1,9 +1,13 @@
import logging
import os
import sys
try:
import Tkinter
except:
if sys.version_info[0] == 2:
import Tkinter as tkinter
else:
import tkinter
except ImportError:
Tkinter = None
@@ -12,15 +16,15 @@ class MessageBoxHandler(logging.Handler):
logging.Handler.__init__(self)
def emit(self, record):
if Tkinter:
if tkinter:
msg = self.format(record)
root = Tkinter.Tk()
root = tkinter.Tk()
root.wm_title("web2py logger message")
text = Tkinter.Text()
text = tkinter.Text()
text["height"] = 12
text.insert(0.1, msg)
text.pack()
button = Tkinter.Button(root, text="OK", command=root.destroy)
button = tkinter.Button(root, text="OK", command=root.destroy)
button.pack()
root.mainloop()
@@ -30,6 +34,6 @@ class NotifySendHandler(logging.Handler):
logging.Handler.__init__(self)
def emit(self, record):
if Tkinter:
if tkinter:
msg = self.format(record)
os.system("notify-send '%s'" % msg)