Advertisement
Guest User

Class Splash

a guest
Nov 22nd, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. class SplashScreen(Frame):
  2. def __init__(self, master=None, width=0.8, height=0.6, useFactor=True):
  3. Frame.__init__(self, master)
  4. self.pack(side=TOP, fill=BOTH, expand=YES)
  5.  
  6. # get screen width and height
  7. ws = self.master.winfo_screenwidth()
  8. hs = self.master.winfo_screenheight()
  9. w = (useFactor and ws*width) or width
  10. h = (useFactor and ws*height) or height
  11. # calculate position x, y
  12. x = (ws/2) - (w/2)
  13. y = (hs/2) - (h/2)
  14. self.master.geometry('%dx%d+%d+%d' % (w, h, x, y))
  15.  
  16. self.master.overrideredirect(True)
  17. self.lift()
  18.  
  19. if __name__ == '__main__':
  20. root = Tk()
  21.  
  22. sp = SplashScreen(root)
  23. sp.config(bg="#3366ff")
  24.  
  25. m = Label(sp, text="This is a test of the splash screen\n\n\nThis is only a test.\nwww.sunjay-varma.com")
  26. m.pack(side=TOP, expand=YES)
  27. m.config(bg="#3366ff", justify=CENTER, font=("calibri", 29))
  28.  
  29. Button(sp, text="Press this button to kill the program", bg='red', command=root.destroy).pack(side=BOTTOM, fill=X)
  30. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement