Commit 43d1994c authored by sumpfralle's avatar sumpfralle

r1062@erker: lars | 2010-07-06 20:12:20 +0200

 use the general logging facility instead of "show_error_dialog"


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@433 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent c1857cf3
...@@ -22,6 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -22,6 +22,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
from pycam.Geometry.Point import Point from pycam.Geometry.Point import Point
import pycam.Geometry.Matrix as Matrix import pycam.Geometry.Matrix as Matrix
import pycam.Utils.log
import OpenGL.GL as GL import OpenGL.GL as GL
import OpenGL.GLU as GLU import OpenGL.GLU as GLU
import OpenGL.GLUT as GLUT import OpenGL.GLUT as GLUT
...@@ -47,6 +48,9 @@ VIEWS = { ...@@ -47,6 +48,9 @@ VIEWS = {
} }
log = pycam.Utils.log.get_logger()
class Camera: class Camera:
def __init__(self, settings, get_dim_func, view=None): def __init__(self, settings, get_dim_func, view=None):
...@@ -208,8 +212,8 @@ class ModelViewWindowGL: ...@@ -208,8 +212,8 @@ class ModelViewWindowGL:
try: try:
import gtk.gtkgl import gtk.gtkgl
self.enabled = True self.enabled = True
except ImportError: except (ImportError, RuntimeError):
show_error_dialog(self.window, "Failed to initialize the interactive 3D model view." log.error("Failed to initialize the interactive 3D model view."
+ "\nPlease install 'python-gtkglext1' to enable it.") + "\nPlease install 'python-gtkglext1' to enable it.")
self.enabled = False self.enabled = False
return return
......
...@@ -41,8 +41,42 @@ def init_logger(log, logfilename=None): ...@@ -41,8 +41,42 @@ def init_logger(log, logfilename=None):
log.addHandler(console_output) log.addHandler(console_output)
log.setLevel(logging.INFO) log.setLevel(logging.INFO)
def add_stream(stream): def add_stream(stream, level=None):
log = get_logger() log = get_logger()
logstream = logging.StreamHandler(stream) logstream = logging.StreamHandler(stream)
if not level is None:
logstream.setLevel(level)
log.addHandler(logstream) log.addHandler(logstream)
def add_gtk_gui(parent_window, level=None):
log = get_logger()
loggui = GTKHandler(parent_window)
if not level is None:
loggui.setLevel(level)
log.addHandler(loggui)
class GTKHandler(logging.Handler):
def __init__(self, parent_window=None, **kwargs):
logging.Handler.__init__(self, **kwargs)
self.parent_window = parent_window
def emit(self, record):
message = self.format(record)
import gtk
if record.levelno <= 20:
message_type = gtk.MESSAGE_INFO
message_title = "Information"
elif record.levelno <= 30:
message_type = gtk.MESSAGE_WARNING
message_title = "Warning"
else:
message_type = gtk.MESSAGE_ERROR
message_title = "Error"
window = gtk.MessageDialog(self.parent_window, type=message_type,
buttons=gtk.BUTTONS_OK, message_format=str(message))
window.set_title(message_title)
window.run()
window.destroy()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment