"""splash.py: Display PyRAF splash screen R. White, 2001 Dec 15 """ import os, sys, Tkinter import irafglobals, wutil logo = "pyraflogo_rgb_web.gif" class SplashScreen(Tkinter.Toplevel): """Base class for splash screen Subclass and override createWidgets(). In constructor of main window/application call - S = SplashScreen(main=self) (if caller is Toplevel) - S = SplashScreen(main=self.master) (if caller is Frame) - S.Destroy() after you are done creating your widgets etc. Based closely on news posting by Alexander Schliep, 07 Apr 1999 """ def __init__(self, master=None, borderwidth=4, relief=Tkinter.RAISED, **kw): Tkinter.Toplevel.__init__(self, master, relief=relief, borderwidth=borderwidth, **kw) if self.master.master != None: # Why? self.master.master.withdraw() self.master.withdraw() self.overrideredirect(1) self.createWidgets() self.after_idle(self.centerOnScreen) self.update() def centerOnScreen(self): self.update_idletasks() xmax = self.winfo_screenwidth() ymax = self.winfo_screenheight() x0 = (xmax - self.winfo_reqwidth()) / 2 y0 = (ymax - self.winfo_reqheight()) / 2 self.geometry("+%d+%d" % (x0, y0)) def createWidgets(self): # Implement in derived class pass def Destroy(self): self.master.update() self.master.deiconify() self.withdraw() class PyrafSplash(SplashScreen): """PyRAF splash screen Contains an image and one or more text lines underneath. The number of lines is determined by the value of the text argument, which may be a string (for a single line or, with embedded newlines, multiple lines) or a list of strings. The text line(s) can be changed using the write() method. """ def __init__(self, filename=logo, text=None, textcolor="blue", **kw): # look for file in both local directory and this script's directory if not os.path.exists(filename): tfilename = os.path.join(os.path.dirname(__file__),filename) if not os.path.exists(tfilename): raise ValueError("Splash image `%s' not found" % filename) filename = tfilename self.filename = filename self.nlines = 1 self.textcolor = textcolor if text: if isinstance(text, type("")): text = text.split("\n") self.nlines = len(text) self.initialText = text else: self.initialText = [None] SplashScreen.__init__(self, **kw) self.defaultCursor = self['cursor'] self.bind("