-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariable_container.py
70 lines (60 loc) · 1.58 KB
/
variable_container.py
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
65
66
67
68
69
70
'''
Created this extra file to store variables used by both files
so that circular import won't happen
'''
import tkinter as tk
import tinify as tf
def update_compression_counter():
try:
compression_status_container.delete(0.0, tk.END)
compression_counter_data['Current API:'] = var_api_key
for key, i in compression_counter_data.items():
compression_status_container.insert(0.0, key + '\t' + str(i) + '\n')
compression_status_container.update_idletasks()
except:
compression_status_container.insert(tk.END, "No API key")
# Values of these keys are the row and column information
extension_list = {
'png' : [0,0],
'jpg':[0,1],
'jpeg':[1,0],
'webp':[1,1]
}
# Data Required for Image Compression
current_directory = ''
destination_directory = ''
var_height = None
var_width = None
var_extension = None
var_copyright = None
var_creation = None
var_location = None
var_output_path = 'Current path'
# Values are the row information and respective checkbox variables
metadata_list = {
'copyright': [0, var_copyright],
'location': [1, var_location],
'creation': [2,var_creation]
}
# To Avoid Circular Import
files_log_dialog = None
api_entry = None
optimization_number_entry = None
compression_status_counter = None
# List of File Types Supported
filetypes = [
("PNG File",".png"),
("JPG File",".jpg"),
("JPEG File",".jpeg"),
('WEBP File', '.webp')
]
try:
tf.key = var_api_key
tf.validate()
compression_counter_data = {
'Current API:\n': api_entry,
'Compressions Done:': tf.compression_count,
'Compressions Remaining:': 500-tf.compression_count
}
except:
print("No key")