Advertisement
xample

Python Loading GUI

Dec 26th, 2018
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.63 KB | None | 0 0
  1. from tkinter import *
  2. import random
  3. root = Tk()
  4. color_list = ['#FF3333', '#6CD720' , '#20D2D7', '#202CD7', '#D720D6', '#D72025'] # u can add more later idk xd
  5. number = 1
  6. dot_value = 0
  7. w = root.winfo_reqwidth()
  8. h = root.winfo_reqheight()
  9. ws = root.winfo_screenwidth()
  10. hs = root.winfo_screenheight()
  11. x = (ws/2) - (w/2)
  12. y = (hs/2) - (h/2)
  13. #root.geometry('400x250+%d+%d' % (x, y))
  14. root.geometry('%dx%d' % (ws,hs))
  15. root.resizable(height = False, width = False)
  16. root.attributes('-topmost', True)
  17. root.attributes('-alpha', 0)
  18. root.overrideredirect(1)
  19. root.config(background='black')
  20. import time
  21. wait = time.sleep
  22.  
  23. ## // Fade Out Function \\ ##
  24. def fade_away():
  25.     alpha = root.attributes("-alpha")
  26.     print (alpha)
  27.     if alpha > 0:
  28.         alpha -= .01
  29.         root.attributes("-alpha", alpha)
  30.         root.after(100,fade_away)
  31.            
  32.     else:
  33.         root.destroy()
  34. def pack_msg():
  35.     global Main_message,text
  36.     try:
  37.         Main_message.destroy()
  38.     except:
  39.         print ("Passed Function.")
  40.         pass
  41.     text = StringVar()
  42.     color_picker = (''.join(random.choice(color_list)))
  43.     Main_message = Label(root, textvariable = text)
  44.     Main_message.config(fg = color_picker, bg = 'black', font=('Times', 35))
  45.     Main_message.place(relx=0.5, rely=0.5,anchor='center')
  46.  
  47.  
  48.  
  49. ## // Fade In Function \\ ##
  50. def fade_in():
  51.     alpha = root.attributes('-alpha')
  52.     print (alpha) # Check numbers
  53.     if 0 <= alpha <= 0.9900000000000007: # if between (exact number)
  54.         alpha += .01
  55.         make_the_eyes_blind_lul = (''.join(random.choice(color_list))) # mah eyes hurt...
  56.         Main_message.config(fg = make_the_eyes_blind_lul, bg = 'black', font=('Times', 35))
  57.         root.attributes("-alpha", alpha)
  58.         root.after(100, fade_in) # refresh
  59.     elif alpha == 1.0:
  60.         print ("Dots Function...")
  61.         root.after(5000, lambda:text.set("LOADING"))
  62.         """ FIRST SCRIPT YOU WANT TO LOAD """
  63.         Main_message.update()
  64.         wait(5)
  65.         root.after(5000, lambda:text.set("LOADING."))
  66.         Main_message.update()
  67.         """ SECOND SCRIPT """
  68.         wait(5)
  69.         root.after(5000, lambda:text.set("LOADING.."))
  70.         """ THIRD SCRIPT """
  71.         Main_message.update()
  72.         wait(5)
  73.         root.after(5000, lambda:text.set("LOADING..."))
  74.         """ FINAL SCRIPT """
  75.         Main_message.update()
  76.         wait(2)
  77.         root.after(5000, lambda:text.set("LOADING IS DONE!"))
  78.         root.after(10000,fade_away)
  79.        
  80.     else:
  81.         print ("Function started.")
  82.         root.destroy()
  83.  
  84.  
  85. pack_msg()
  86. text.set("Welcome, please wait!")
  87. fade_in()
  88. root.mainloop()
  89. # hi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement