-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
105 lines (75 loc) · 2.49 KB
/
main.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
import csv
import json
import tkinter as tk
from tkinter import filedialog as fd
import os
from twilio.rest import Client
from PIL import Image, ImageTk
def send_message(file, text):
""" send a message """
# verification
f = open("secret.json", 'r')
secret = json.load(f)
auth_token = secret['auth_token']
account_sid = secret['account_sid']
f.close()
client = Client(account_sid, auth_token)
names = []
numbers = []
# parse the csv file
f = open(file)
reader = csv.reader(f)
for row in reader:
names.append(row[0])
numbers.append(row[1])
# iterate through names and numbers
for name, number in zip(names, numbers):
# text the message
client.messages.create(to=number, from_="+1 (469) 754-9682", body=text.format(name))
f.close()
def gui():
""" render the Gui, obviously"""
# declare the globals
global csv_file_ask
global message
window = tk.Tk()
window.geometry('400x400')
# create frame title
window.title('ACC TextMessages')
# make the window not resizable
window.resizable(False, False)
# make the background black
window.config(background="white")
# ACC icon
window.iconbitmap("C:/Users/bilal/Downloads/acc_logo_icon.ico")
# insert the message
message = tk.Text(master=window, width=40, height=10, font=("Ariel", 12))
message.place(relx=0.5, rely=0.5, anchor="center")
# open file button
csv_file_ask = tk.Button(master=window, text="choose a file", command=open_file)
csv_file_ask.place(relx=0.5, rely=0.8, anchor="center")
# send button
button = tk.Button(text="send", command=lambda: send_message(csv_file, message.get("1.0", "end")))
button.place(relx=0.5, rely=0.9, anchor="center")
# ACC logo
image = Image.open("C:/Users/bilal/OneDrive/Pictures/acc_logo.png")
image.thumbnail((150, 200), Image.ANTIALIAS)
photo = ImageTk.PhotoImage(image)
label_image = tk.Label(image=photo)
label_image.place(relx=0.5, rely=0.14, anchor="center")
window.mainloop()
def open_file():
"""open the file"""
global csv_file
csv_file = fd.askopenfilename()
csv_file_ask['state'] = 'disabled'
if os.path.splitext(csv_file)[1] == ".csv":
return csv_file
else:
message.insert(tk.END, "\nOops, thats not a CSV file")
csv_file_ask['state'] = 'normal'
def main():
"""it's the main function, duuh"""
gui()
if __name__ == '__main__':
main()