from tkinter import *
from tkinter.ttk import *
import time
class SplashFile(Frame):
def __init__(self, master=None, width=0.8, height=0.6, useFactor=True):
Frame.__init__(self, master)
self.pack(side=TOP, fill=BOTH, expand=NO)
'''x=10
y=10
w=230
h=200'''
# Gets the requested values of the height and widht.
windowWidth = root.winfo_reqwidth()
windowHeight = root.winfo_reqheight()
print("Width",300,"Height",300)
# Gets both half the screen width/height and window width/height
positionRight = int(root.winfo_screenwidth()/2 - windowWidth/2)
positionDown = int(root.winfo_screenheight()/2 - windowHeight/2)
# Positions the window in the center of the page.
root.geometry("+{}+{}".format(positionRight, positionDown))
#self.master.geometry('%dx%d+%d+%d' % (w, h, x, y))
self.master.overrideredirect(True)
self.lift()
if __name__ == '__main__':
root = Tk()
sp = SplashFile(root)
#sp.config(bg="#3366ff")
photo = PhotoImage(file =r"attendance_image_splash.png")
photoimage = photo.subsample(2, 2)
m = Label(sp,image = photoimage)
m.pack(side=TOP, expand=YES)
#m.config(bg="#3366ff", justify=CENTER, font=("calibri", 29))
#Button(sp, text="Press this button to kill the program",
#fg='white', bg='red', command=root.destroy).pack(side=TOP, fill=X)
progress = Progressbar(root, orient = HORIZONTAL,
length = 100, mode = 'determinate')
progress.pack(side=TOP, fill=X)
#progress['maximum']=100
for i in range(101):
time.sleep(0.05)
progress['value'] = i
progress.update()
if progress['value']==100:
print("close window")
root.destroy()
root.mainloop()
No comments:
Post a Comment