-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowLoading.py
More file actions
64 lines (49 loc) · 1.58 KB
/
Copy pathWindowLoading.py
File metadata and controls
64 lines (49 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#import config module for environmental variability
import config
#import my utility class and function
import MyUtility
#import my multi threading function to upload and download file
from MyMultiThreading import *
#tkinter import
import tkinter as tk
from tkinter import *
from tkinter import ttk
class LoadingWindow(tk.Toplevel):
def __init__(self, loading_text="Loading..."):
super().__init__()
#change icon
img = PhotoImage(file=resource_path(config.icon))
self.iconphoto(False, img)
# configure the root window
self.title('Loading')
# move window center
winWidth = self.winfo_reqwidth()
winwHeight = self.winfo_reqheight()
posRight = int(self.winfo_screenwidth() / 2 - winWidth / 2)
posDown = int(self.winfo_screenheight() / 2 - winwHeight / 2)
self.geometry("+{}+{}".format(posRight, posDown))
#title label
self.lbl_loadFile = tk.Label(self, text=loading_text, width=30,font=config.font_title)
self.lbl_loadFile.grid(row=0, column=0, padx=10, pady=10)
#create a progressbar
pb = ttk.Progressbar(
self,
orient='horizontal',
mode='indeterminate',
length=200
)
pb.grid(row=1, column=0, padx=10, pady=(10,30))
pb.start(18) #value in ms (default is 50ms)
#put window in front
self.lift()
#prevent touch in other windows
self.grab_set()
#Disable exit button and other
#self.attributes("-disabled", True)
def change_label(self, text):
self.lbl_loadFile['text'] = text
self.update()
self.lift()
if __name__ == "__main__":
app = LoadingWindow()
app.mainloop()