Commit b06eba20 authored by sumpfralle's avatar sumpfralle

fixed an exception in case of a missing Tkinter module


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@313 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent b0a5e647
...@@ -33,6 +33,9 @@ DEPENDENCY_DESCRIPTION = { ...@@ -33,6 +33,9 @@ DEPENDENCY_DESCRIPTION = {
"togl": ("Tk for OpenGL", "togl": ("Tk for OpenGL",
"see http://downloads.sourceforge.net/togl/", "see http://downloads.sourceforge.net/togl/",
"see http://downloads.sourceforge.net/togl/"), "see http://downloads.sourceforge.net/togl/"),
"tkinter": ("Tk interface for Python",
"Install the package 'python-tk'",
"see http://tkinter.unpythonic.net/wiki/"),
} }
REQUIREMENTS_LINK = "https://sourceforge.net/apps/mediawiki/pycam/index.php?title=Requirements" REQUIREMENTS_LINK = "https://sourceforge.net/apps/mediawiki/pycam/index.php?title=Requirements"
...@@ -80,19 +83,30 @@ def dependency_details_tk(): ...@@ -80,19 +83,30 @@ def dependency_details_tk():
except ImportError: except ImportError:
result["opengl"] = False result["opengl"] = False
try: try:
import logging import Tkinter
result["tkinter"] = True
except ImportError:
result["tkinter"] = False
# Don't try to import OpenGL.Tk if Tkinter itself is missing.
# Otherwise the "except" statement below fails due to the unknown
# Tkinter.TclError exception.
if result["tkinter"]:
try: try:
# temporarily disable debug output of the logging module import logging
# the error message is: No handlers could be found for logger "OpenGL.Tk" try:
previous = logging.raiseExceptions # temporarily disable debug output of the logging module
logging.raiseExceptions = 0 # the error message is: No handlers could be found for logger "OpenGL.Tk"
except AttributeError: previous = logging.raiseExceptions
previous = None logging.raiseExceptions = 0
import OpenGL.Tk except AttributeError:
if not previous is None: previous = None
logging.raiseExceptions = previous import OpenGL.Tk
result["togl"] = True if not previous is None:
except (ImportError, Tkinter.TclError): logging.raiseExceptions = previous
result["togl"] = True
except (ImportError, Tkinter.TclError):
result["togl"] = False
else:
result["togl"] = False result["togl"] = False
return result return result
...@@ -170,7 +184,7 @@ class ToolPathList(list): ...@@ -170,7 +184,7 @@ class ToolPathList(list):
class ToolPathInfo: class ToolPathInfo:
def __init__(self, toolpath, name, cutter, drill_id, speed, feedrate, def __init__(self, toolpath, name, cutter, drill_id, speed, feedrate,
material_allowance, safety_height, unit, start_x, start_y, start_z): material_allowance, safety_height, unit, start_x, start_y, start_z, bounding_box):
self.toolpath = toolpath self.toolpath = toolpath
self.name = name self.name = name
self.visible = True self.visible = True
...@@ -185,6 +199,7 @@ class ToolPathInfo: ...@@ -185,6 +199,7 @@ class ToolPathInfo:
self.start_x = start_x self.start_x = start_x
self.start_y = start_y self.start_y = start_y
self.start_z = start_z self.start_z = start_z
self.bounding_box = bounding_box
self.color = None self.color = None
# generate random color # generate random color
self.set_color() self.set_color()
......
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