Added GUI error message if wxPython is not present.

If wxPython is not present, there would be a command-line message only.
Some users may not notice that. We now fall back to Tkinter to report
such messages.
This commit is contained in:
Cas Cremers 2010-05-15 22:56:48 +02:00
parent f8ad858d87
commit feb400c610

View File

@ -21,12 +21,34 @@
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
def panic(text):
"""
Errors that occur before we even are sure about wxPython etc. are dumped
on the command line and reported using Tkinter.
"""
import Tkinter
print text
root = Tkinter.Tk()
w = Tkinter.Label(root, text=text)
w.pack()
root.mainloop()
sys.exit(-1)
#---------------------------------------------------------------------------
""" Import externals """ """ Import externals """
import sys import sys
try: try:
import wx import wx
except ImportError: except ImportError:
print """
panic("""
ERROR: ERROR:
Could not find the required [wxPython] package. Could not find the required [wxPython] package.
@ -34,9 +56,12 @@ Please install this package in order to use the graphical user
interface of Scyther. interface of Scyther.
The [wxPython] packages can be found at http://www.wxpython.org/ The [wxPython] packages can be found at http://www.wxpython.org/
Ubuntu users: the wxPython packages are called 'python-wxgtk' followed by the
version number.
Note that you can still use the Scyther binaries in the 'Scyther' directory. Note that you can still use the Scyther binaries in the 'Scyther' directory.
""" """)
sys.exit(1)
import os import os
from optparse import OptionParser, SUPPRESS_HELP from optparse import OptionParser, SUPPRESS_HELP