-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPHONE_PARAMETERS_v1.0.py
359 lines (343 loc) · 8.1 KB
/
PHONE_PARAMETERS_v1.0.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#----------------------------------------------------------------------------
# Created By : TheDataHunter - https://github.com/TheDataHunter
# Created Date : 10/08/2022
# version ='1.0'
# status : RFU (ready for use)
# license : GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
# copyrights :
# ---------------------------------------------------------------------------
""" A simple Python script that looks up your Country Phone Codes """
# ---------------------------------------------------------------------------
# Imports
# ---------------------------------------------------------------------------
from tkinter import *
from tkinter import ttk
# ---------------------------------------------------------------------------
# Dictionaries
# ---------------------------------------------------------------------------
country_dct = {
'AFG':'93',
'AFG':'93',
'ALA':'358',
'ALB':'355',
'DZA':'213',
'ASM':'1',
'AND':'376',
'ANG':'244',
'AIA':'1',
'ATG':'1',
'ARG':'54',
'ARM':'374',
'ABW':'297',
'AUS':'61',
'AUT':'43',
'AZE':'994',
'BHS':'1',
'BHR':'973',
'BGD':'880',
'BRB':'1',
'BLR':'375',
'BEL':'32',
'BLZ':'501',
'BEN':'229',
'BMU':'1',
'BTN':'975',
'BOL':'591',
'BES':'599',
'BIH':'387',
'BWA':'267',
'BRA':'55',
'IOT':'246',
'VIR':'1',
'BRN':'673',
'BGR':'359',
'BFA':'226',
'MMR':'95',
'BDI':'257',
'KHM':'855',
'CMR':'237',
'CAN':'1',
'CPV':'238',
'CYM':'1',
'CAF':'236',
'TCD':'235',
'CHL':'56',
'CHN':'86',
'CXR':'61',
'CCK':'61',
'COL':'57',
'COM':'269',
'COG':'242',
'COD':'243',
'COK':'682',
'CRI':'506',
'HRV':'385',
'CUB':'53',
'CUW':'599',
'CYP':'357',
'CZE':'420',
'DNK':'45',
'DJI':'253',
'DMA':'1',
'DOM':'1',
'TLS':'670',
'ECU':'593',
'EGY':'20',
'SLV':'503',
'GBR':'44',
'GNQ':'240',
'ERI':'291',
'EST':'372',
'EST':'251',
'SWZ':'268',
'FLK':'500',
'FRO':'298',
'FSM':'691',
'FJI':'679',
'FIN':'358',
'FRA':'33',
'PYF':'262',
'PYF':'508',
'PYF':'590',
'PYF':'594',
'PYF':'596',
'GUF':'594',
'PYF':'689',
'GAB':'241',
'GMB':'220',
'GEO':'995',
'DEU':'49',
'GHA':'233',
'GIB':'350',
'GRC':'30',
'GRL':'299',
'GRD':'1',
'GLP':'590',
'GUM':'1',
'GTM':'502',
'GGY':'44',
'GIN':'224',
'GNB':'245',
'GUY':'592',
'HTI':'509',
'HND':'504',
'HKG':'852',
'HUN':'36',
'ISL':'354',
'IND':'91',
'IDN':'62',
'IRN':'98',
'IRQ':'964',
'IRL':'353',
'IMN':'44',
'ISR':'972',
'ITA':'39',
'CIV':'225',
'JAM':'1',
'JPN':'81',
'JEY':'44',
'JOR':'962',
'KAZ':'7',
'KEN':'254',
'KIR':'686',
'KWT':'965',
'KGZ':'996',
'LAO':'856',
'LVA':'371',
'LBN':'961',
'LSO':'266',
'LBR':'231',
'LBY':'218',
'LIE':'423',
'LTU':'370',
'LUX':'352',
'MAC':'853',
'MDG':'261',
'MWI':'265',
'MYS':'60',
'MDV':'960',
'MLI':'223',
'MLT':'356',
'MHL':'692',
'MTQ':'596',
'MRT':'222',
'MUS':'230',
'MYT':'262',
'MEX':'52',
'MDA':'373',
'MCO':'377',
'MNG':'976',
'MNE':'382',
'MSR':'1',
'MAR':'212',
'MOZ':'258',
'NAM':'264',
'NRU':'674',
'NPL':'977',
'NLD':'31',
'NCL':'687',
'NZL':'64',
'NIC':'505',
'NER':'227',
'NGA':'234',
'NIU':'683',
'NFK':'672',
'PRK':'850',
'MKD':'389',
'NOR':'47',
'OMN':'968',
'PAK':'92',
'PLW':'680',
'PSE':'970',
'PSE':'972',
'PAN':'507',
'PNG':'675',
'PRY':'595',
'PER':'51',
'PHL':'63',
'PCN':'64',
'POL':'48',
'PRT':'351',
'PRT':'239',
'PRI':'1',
'QAT':'974',
'REU':'262',
'ROU':'40',
'RUS':'7',
'RWA':'250',
'BLM':'590',
'SHN':'290',
'KAN':'1',
'LCA':'1',
'MAF':'590',
'SPM':'508',
'VCT':'1',
'WSM':'685',
'SMR':'378',
'STP':'239',
'SAU':'966',
'SEN':'221',
'SRB':'381',
'SYC':'248',
'SLE':'232',
'SGP':'65',
'SXM':'1',
'SVK':'421',
'SVN':'386',
'SLB':'677',
'SOM':'252',
'ZAF':'27',
'SGS':'500',
'KOR':'82',
'SSD':'211',
'ESP':'34',
'LKA':'94',
'SDN':'249',
'SUR':'597',
'SJM':'47',
'SWE':'46',
'CHE':'41',
'SYR':'963',
'TWN':'886',
'TJK':'992',
'TZA':'255',
'THA':'66',
'TGO':'228',
'TKL':'690',
'TON':'676',
'TTO':'1',
'TUN':'216',
'TUR':'90',
'TKM':'993',
'TCA':'1',
'TUV':'688',
'UGA':'256',
'UKR':'380',
'ARE':'971',
'USA':'1',
'VGB':'1',
'URY':'598',
'UZB':'998',
'VUT':'678',
'VAT':'39',
'VEN':'58',
'VNM':'84',
'WLF':'681',
'ESH':'212',
'YEM':'967',
'ZMB':'260',
'ZWE':'263'
}
# ---------------------------------------------------------------------------
# CODE
# ---------------------------------------------------------------------------
# function to set iso3_code_entry
def run_query(*args):
if iso3_code_entry.get() != '' :
# store entries
iso3 = iso3_code_entry.get()
# insert new Entry from Dictionary
phone_dct = country_dct.get(iso3)
print(phone_dct)
phone_code_entry.delete(0,END)
phone_code_entry.insert(0,str(phone_dct))
phone_code_entry.config(state= "disabled")
iso3_code_entry.config(state= "disabled")
elif iso3_code_entry.get() != '' :
phone_code_entry.delete(0,END)
iso3_code_entry.delete(0,END)
elif phone_code_entry.get() != '' :
# store entries
phone = phone_code_entry.get()
# insert new Entry from Dictionary
for key, value in country_dct.items():
if value == phone:
iso3_dct = key
# iso3_dct = country_dct.get(phone)
print(iso3_dct)
iso3_code_entry.delete(0,END)
iso3_code_entry.insert(0,iso3_dct)
phone_code_entry.config(state= "disabled")
iso3_code_entry.config(state= "disabled")
elif iso3_code_entry.get() == '' and phone_code_entry.get() =='':
reset_entries()
# RESET function to clean all entries
def reset_entries():
phone_code_entry.config(state= "enabled")
iso3_code_entry.config(state= "enabled")
iso3_code_entry.delete(0,END)
phone_code_entry.delete(0,END)
return
# Create object
root = Tk()
root.bind('<Return>', run_query)
root.bind('<KP_Enter>', run_query)
# Set Title of App
root.title("PHONE")
# General Adjustments
root.geometry("250x150")
mainframe = ttk.Frame(root, padding="4 4 15 15")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S), columnspan=3)
# Interface Labels
ttk.Label(mainframe, text="").grid(column=1, row=1, sticky=W)
ttk.Label(mainframe, text="Country Name (ISO-3)").grid(column=1, row=2, sticky=W)
ttk.Label(mainframe, text="").grid(column=1, row=3, sticky=W)
ttk.Label(mainframe, text="Country Number Prefix").grid(column=1, row=4, sticky=W)
ttk.Label(mainframe, text="").grid(column=1, row=5, sticky=W)
# Buttons
ttk.Button(mainframe, text="RESET", command=reset_entries).grid(column=1, row=6, sticky=W)
ttk.Button(mainframe, text="RUN", command=run_query).grid(column=2, row=6, sticky=W)
# Entry Country in ISO-3
iso3_code = StringVar()
iso3_code_entry = ttk.Entry(mainframe, width=5, textvariable=iso3_code)
iso3_code_entry.grid(column=2, row=2, sticky=(E))
ttk.Label(mainframe, text=" ").grid(column=2, row=2, sticky=W)
# Entry Country Phone Code
phone_code = StringVar()
phone_code_entry = ttk.Entry(mainframe, width=5, textvariable=phone_code)
phone_code_entry.grid(column=2, row=4, sticky=(E))
ttk.Label(mainframe, text=" +").grid(column=2, row=4, sticky=W)
# Execute tkinter
root.mainloop()