| 16 | from Tkinter import * |
| 17 | |
| 18 | class SplashScreen(Frame): |
| 19 | def __init__(self, master=None, width=0.8, height=0.6, useFactor=True): |
| 20 | Frame.__init__(self, master) |
| 21 | self.pack(side=TOP, fill=BOTH, expand=YES) |
| 22 | |
| 23 | # get screen width and height |
| 24 | ws = self.master.winfo_screenwidth() |
| 25 | hs = self.master.winfo_screenheight() |
| 26 | w = (useFactor and ws*width) or width |
| 27 | h = (useFactor and ws*height) or height |
| 28 | # calculate position x, y |
| 29 | x = (ws/2) - (w/2) |
| 30 | y = (hs/2) - (h/2) |
| 31 | self.master.geometry('%dx%d+%d+%d' % (w, h, x, y)) |
| 32 | |
| 33 | self.master.overrideredirect(True) |
| 34 | self.lift() |
| 35 | |
| 36 | if __name__ == '__main__': |
| 37 | root = Tk() |