- Fixed that PIL is only used under Linux
This commit is contained in:
parent
3efdeb48a7
commit
6b3ab79c43
@ -5,19 +5,17 @@
|
|||||||
""" Import externals """
|
""" Import externals """
|
||||||
import wx
|
import wx
|
||||||
import time
|
import time
|
||||||
# Python Imaging library?
|
|
||||||
usePIL = True
|
|
||||||
try:
|
|
||||||
import Image
|
|
||||||
except ImportError:
|
|
||||||
usePIL = False
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Import scyther-gui components """
|
""" Import scyther-gui components """
|
||||||
import Icon
|
import Icon
|
||||||
|
import Preference
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
if Preference.usePIL():
|
||||||
|
import Image
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
class AttackDisplay(wx.ScrolledWindow):
|
class AttackDisplay(wx.ScrolledWindow):
|
||||||
def __init__(self, daddy, parent, attack):
|
def __init__(self, daddy, parent, attack):
|
||||||
@ -117,8 +115,6 @@ class AttackDisplay(wx.ScrolledWindow):
|
|||||||
|
|
||||||
class AttackWindow(wx.Frame):
|
class AttackWindow(wx.Frame):
|
||||||
def __init__(self,cl):
|
def __init__(self,cl):
|
||||||
global usePIL
|
|
||||||
|
|
||||||
super(AttackWindow, self).__init__(None, size=(400,800))
|
super(AttackWindow, self).__init__(None, size=(400,800))
|
||||||
self.SetBackgroundColour('Default')
|
self.SetBackgroundColour('Default')
|
||||||
self.claim = cl
|
self.claim = cl
|
||||||
@ -126,7 +122,7 @@ class AttackWindow(wx.Frame):
|
|||||||
# TODO maybe fitting defaults should come from Preferences.
|
# TODO maybe fitting defaults should come from Preferences.
|
||||||
# Now, it is default yes if it looks nice (i.e. we are using
|
# Now, it is default yes if it looks nice (i.e. we are using
|
||||||
# PIL)
|
# PIL)
|
||||||
if usePIL:
|
if Preference.usePIL():
|
||||||
self.fit = True
|
self.fit = True
|
||||||
else:
|
else:
|
||||||
self.fit = False
|
self.fit = False
|
||||||
|
@ -34,6 +34,12 @@ from time import localtime,strftime
|
|||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Globals """
|
""" 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. """
|
""" Locations of preferences. The last one is supposedly writable. """
|
||||||
prefname = "scythergui-config"
|
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):
|
class Preferences(dict):
|
||||||
|
|
||||||
def parse(self,line):
|
def parse(self,line):
|
||||||
|
@ -10,13 +10,6 @@ import re
|
|||||||
import threading
|
import threading
|
||||||
import StringIO
|
import StringIO
|
||||||
|
|
||||||
# Python Imaging library?
|
|
||||||
usePIL = True
|
|
||||||
try:
|
|
||||||
import Image
|
|
||||||
except ImportError:
|
|
||||||
usePIL = False
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
""" Import scyther components """
|
""" Import scyther components """
|
||||||
@ -31,7 +24,8 @@ import Attackwindow
|
|||||||
import Icon
|
import Icon
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
if Preference.usePIL():
|
||||||
|
import Image
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
class ScytherThread(threading.Thread):
|
class ScytherThread(threading.Thread):
|
||||||
@ -117,9 +111,7 @@ class AttackThread(threading.Thread):
|
|||||||
|
|
||||||
def makeImage(self,attack):
|
def makeImage(self,attack):
|
||||||
""" create image for this particular attack """
|
""" create image for this particular attack """
|
||||||
global usePIL
|
if Preference.usePIL():
|
||||||
|
|
||||||
if usePIL:
|
|
||||||
# If we have the PIL library, we can do postscript! great
|
# If we have the PIL library, we can do postscript! great
|
||||||
# stuff.
|
# stuff.
|
||||||
type = "ps"
|
type = "ps"
|
||||||
|
Loading…
Reference in New Issue
Block a user