|
| 1 | +from tkinter import * |
| 2 | +from tkinter.scrolledtext import ScrolledText |
| 3 | +from tkinter import ttk |
| 4 | + |
| 5 | +import tkinter.messagebox as mb |
| 6 | +import tkinter as tk |
| 7 | +import datetime |
| 8 | +import time |
| 9 | +import random |
| 10 | + |
| 11 | +app = Tk() |
| 12 | +app.title("Windows 10 Update Center") |
| 13 | +app.geometry("500x550") |
| 14 | +app.resizable(False, False) |
| 15 | +app.iconbitmap("icon.ico") |
| 16 | + |
| 17 | +iconwindows10 = PhotoImage(master=app, file="icon-png.png") |
| 18 | +output_iconwindows10 = Label(app, image=iconwindows10, bg="#FFFFFF") |
| 19 | +output_iconwindows10.image = iconwindows10 |
| 20 | +output_iconwindows10.place(relx=0.05, rely=0.05) |
| 21 | + |
| 22 | +Label(app, text="Windows 10", font=("Segoe UI", 25), fg="#01A6F0", bg="#FFFFFF").place(relx=0.16, rely=0.05) |
| 23 | +Label(app, text="Update Center", font=("Segoe UI", 13), fg="#01A6F0", bg="#FFFFFF").place(relx=0.26, rely=0.13) |
| 24 | + |
| 25 | +Label(app, text="Description:", font=("Segoe UI", 10, "bold"), bg="#FFFFFF").place(relx=0.04, rely=0.20) |
| 26 | + |
| 27 | +description = ScrolledText(app, wrap=WORD, undo=True, width=62, height=15, font=("Segoe UI", 10)) |
| 28 | +description.pack(expand=True) |
| 29 | +description.place(relx=0.05, rely=0.25) |
| 30 | + |
| 31 | +current_month = datetime.date.today().month |
| 32 | +current_year = datetime.date.today().year |
| 33 | + |
| 34 | +description.configure(state='normal') |
| 35 | +description.insert('end', f'Critical {current_month}/{current_year} -- KB5390699\n\n• Highlights\nUpdate to improve your PC security against malwares, ransomwares and PUP.\n\n• Improvements and fixes\nThe security update includes quality improvements.\n\n - Security updates to Microsoft Edge and Internet Explorer.\n - Small bug fixes.\n\nIf you installed earlier updates, only the new fixes contained in this package will be downloaded and installed on your device.') |
| 36 | +description.configure(state='disabled') |
| 37 | + |
| 38 | +# def update_progress_label(): |
| 39 | +# # return f"{pb['value']}%" |
| 40 | + |
| 41 | +def progress(): |
| 42 | + randnum = random.randint(1, 5) |
| 43 | + start_button.place(relx=1, rely=1) |
| 44 | + value_label.place(relx=0.40, rely=0.85) |
| 45 | + if pb['value'] < 100: |
| 46 | + pb['value'] += randnum |
| 47 | + # value_label['text'] = update_progress_label() |
| 48 | + randtime = random.randint(1000, 3000) |
| 49 | + pb.after(800, progress) |
| 50 | + else: |
| 51 | + value_label.place(relx=1, rely=1) |
| 52 | + start_button.place(relx=0.40, rely=0.85) |
| 53 | + mb.showerror(message='Windows 10 can\'t finish the update, please don\'t shutdown or restart your computer and retry later.', title="Windows 10 Update Center") |
| 54 | + pb['value'] = 0 |
| 55 | + |
| 56 | + |
| 57 | +def stop(): |
| 58 | + pb.stop() |
| 59 | + value_label['text'] = update_progress_label() |
| 60 | + |
| 61 | + |
| 62 | +# progressbar |
| 63 | +pb = ttk.Progressbar( |
| 64 | + app, |
| 65 | + orient='horizontal', |
| 66 | + mode='determinate', |
| 67 | + length=280, |
| 68 | + maximum=100 |
| 69 | +) |
| 70 | +# place the progressbar |
| 71 | +pb.place(relx=0.20, rely=0.80) |
| 72 | + |
| 73 | +# label |
| 74 | +value_label = Label(app, text="Downloading...", font=("Segoe UI", 10), bg="#FFFFFF") |
| 75 | +value_label.place(relx=1, rely=1) |
| 76 | + |
| 77 | +# start button |
| 78 | +start_button = Button( |
| 79 | + app, |
| 80 | + text='Download', |
| 81 | + command=progress, |
| 82 | + font=("Segoe UI", 10), |
| 83 | + bg="#FFFFFF" |
| 84 | +) |
| 85 | +start_button.place(relx=0.40, rely=0.85) |
| 86 | + |
| 87 | +app.config(bg="#FFFFFF") |
| 88 | +app.mainloop() |
0 commit comments