[Pythonmac-SIG] PIL for Python 2.4x? (Mac OS 2.4.x)

Schollnick, Benjamin Benjamin.Schollnick at xerox.com
Thu Jan 5 17:29:03 CET 2006


> Don't do that. Instead:
> 
> - install Python 2.4.1 from http://undefined.org/python
> - install PIL from http://www.pythonmac.org/packages

I did that....

But it still didn't seem to work....

Then I remembered that 2.41 is /usr/local/bin/python2.4 ...  The default
is v2.3...
So it was mostly user error....

But I don't think that PIL will help at this point...  I'm attempting to
add a splashscreen to an cross-platform (Windows / Mac) application...
PIL appears to use Tkinter?

Or at least the code that I found as a starting point is using Tkinter /
PIL....

Since my application is using PythonCard / wxPython, I don't think that
it would be a great idea to use anything that involves Tkinter.....

Just as a lark... Here's the code that I was thinking of modeling
from...

"""SplashScreen 
A splash screen that displays an image for a predefined 
number of milliseconds. 
usage 
tk = Tk() 
s = SplashScreen(tk, timeout=2000, image="python.jpg") 
mainloop() 
The main window will be shown after the timeout. 
requires: PIL imaging library 
""" 
from Tkinter import * 
try: 
    from PIL import Image, ImageTk 
except ImportError: 
    import Image, ImageTk 

class SplashScreen(Toplevel): 
     def __init__(self, master, image=None, timeout=1000): 
         """(master, image, timeout=1000) -> create a splash screen 
         from specified image file.  Keep splashscreen up for timeout 
         milliseconds""" 
         Toplevel.__init__(self, master, relief=RAISED, borderwidth=5) 
         self.main = master 
         if self.main.master != None: # Why ? 
             self.main.master.withdraw() 
         self.main.withdraw() 
         self.overrideredirect(1) 
         im = Image.open(image) 
         self.image = ImageTk.PhotoImage(im) 
         self.after_idle(self.centerOnScreen) 
         self.update() 
         self.after(timeout, self.destroy) 
     def centerOnScreen(self): 
         self.update_idletasks() 
         width, height = self.width, self.height = self.image.width(),
self.image.height() 
         xmax = self.winfo_screenwidth() 
         ymax = self.winfo_screenheight() 
         x0 = self.x0 = (xmax - self.winfo_reqwidth()) / 2 - width/2 
         y0 = self.y0 = (ymax - self.winfo_reqheight()) / 2 - height/2 
         self.geometry("+%d+%d" % (x0, y0)) 
         self.createWidgets() 
     def createWidgets(self): 
        # Need to fill in here 
         self.canvas = Canvas(self, height=self.width,
width=self.height) 
         self.canvas.create_image(0,0, anchor=NW, image=self.image) 
         self.canvas.pack() 
     def destroy(self): 
         self.main.update() 
         self.main.deiconify() 
         self.withdraw() 
if __name__ == "__main__": 
     import os 
     tk = Tk() 
     l = Label(tk, text="main window") 
     l.pack() 
     #assert os.path.exists("python.jpg") 
     s = SplashScreen(tk, timeout=20000, image="python.jpg") 
     mainloop() 

-- Benjamin


More information about the Pythonmac-SIG mailing list