- Fixed that PIL is only used under Linux

This commit is contained in:
ccremers 2006-08-10 11:50:57 +00:00
parent 3efdeb48a7
commit 6b3ab79c43
3 changed files with 29 additions and 20 deletions

View File

@ -5,19 +5,17 @@
""" Import externals """
import wx
import time
# Python Imaging library?
usePIL = True
try:
import Image
except ImportError:
usePIL = False
#---------------------------------------------------------------------------
""" Import scyther-gui components """
import Icon
import Preference
#---------------------------------------------------------------------------
if Preference.usePIL():
import Image
#---------------------------------------------------------------------------
class AttackDisplay(wx.ScrolledWindow):
def __init__(self, daddy, parent, attack):
@ -117,8 +115,6 @@ class AttackDisplay(wx.ScrolledWindow):
class AttackWindow(wx.Frame):
def __init__(self,cl):
global usePIL
super(AttackWindow, self).__init__(None, size=(400,800))
self.SetBackgroundColour('Default')
self.claim = cl
@ -126,7 +122,7 @@ class AttackWindow(wx.Frame):
# TODO maybe fitting defaults should come from Preferences.
# Now, it is default yes if it looks nice (i.e. we are using
# PIL)
if usePIL:
if Preference.usePIL():
self.fit = True
else:
self.fit = False

View File

@ -34,6 +34,12 @@ from time import localtime,strftime
#---------------------------------------------------------------------------
""" Globals """
# Do we have the Python Imaging library?
havePIL = True
try:
import Image
except ImportError:
havePIL = False
""" Locations of preferences. The last one is supposedly writable. """
prefname = "scythergui-config"
@ -41,6 +47,21 @@ preflocs = []
#---------------------------------------------------------------------------
def usePIL():
"""
Determine whether or not we should use the PIL library
"""
global havePIL
# Only if we have it, and it is windows.
if havePIL:
if sys.platform.startswith("lin"):
return True
return False
#---------------------------------------------------------------------------
class Preferences(dict):
def parse(self,line):

View File

@ -10,13 +10,6 @@ import re
import threading
import StringIO
# Python Imaging library?
usePIL = True
try:
import Image
except ImportError:
usePIL = False
#---------------------------------------------------------------------------
""" Import scyther components """
@ -31,7 +24,8 @@ import Attackwindow
import Icon
#---------------------------------------------------------------------------
if Preference.usePIL():
import Image
#---------------------------------------------------------------------------
class ScytherThread(threading.Thread):
@ -117,9 +111,7 @@ class AttackThread(threading.Thread):
def makeImage(self,attack):
""" create image for this particular attack """
global usePIL
if usePIL:
if Preference.usePIL():
# If we have the PIL library, we can do postscript! great
# stuff.
type = "ps"