Skip to content

Commit d63b18c

Browse files
authored
Merge pull request #81 from CopyrightC/master
New python script - SMS sender
2 parents fccb841 + 4a1d109 commit d63b18c

20 files changed

+228
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ This is a collection of short Python scripts to solve and automate tasks and sim
5252
31 | [**Folder-Automater**](https://github.com/decipher07/Useful-Python-scripts-collection/blob/master/Folder-Automater/automateall.py) | A Python script which compiles all the different formats of files present in the respective folder to a new folder containing only the Specified files . | None |
5353
32 | [**JSON-YAML**](https://github.com/decipher07/Useful-Python-scripts-collection/blob/master/JSON-YAML) | A Python script which converts JSON To YAML and Vice-Versa | JSON, YAML |
5454
33 | [**CSV_to_JSON**](https://github.com/TechBoyy6/Python-scripts-collection/tree/master/CSV_to_JSON) | A script that converts the csv file into json file. | None |
55+
34 | [**SMS-SENDER**](https://github.com/CopyrightC/Python-scripts-collection/blob/master/SMS_SENDER/main.py) | A python script that uses Tkinter and Twilio to send SMS. | twilio|

SMS_SENDER/API.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from twilio.rest import Client
2+
3+
def Send_msg(body,to,from_num):
4+
account_sid = "your_account_sid_here"
5+
auth_token = "your_auth_token_here"
6+
client = Client(account_sid, auth_token)
7+
8+
message = client.messages.create(
9+
body=body, to=to, from_=from_num
10+
)

SMS_SENDER/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# SMS sender
2+
3+
A simple Tkinter app that uses the Twilio api internally to send messages
4+
5+
# Dependencies
6+
twilio 7.0.0
7+
PyPi [here](https://pypi.org/project/twilio/)
8+
9+
# Setup
10+
11+
Open up your terminal and paste the following -
12+
13+
```
14+
git clone https://github.com/fnplus/Python-scripts-collection
15+
cd "Python-scripts-collection/SMS_SENDER"
16+
pip install twilio
17+
```
18+
19+
Now before proceeding any further head to [Twilio](https://www.twilio.com/) and sign up and follow the steps below
20+
21+
- Navigate to twilio's [console](https://console.twilio.com/)
22+
- Copy your **ACCOUNT SID** and **AUTH_TOKEN**
23+
- In API.py paste them like this
24+
25+
```py
26+
#[...]
27+
def Send_msg(body,to,from_num):
28+
account_sid = "your_account_sid_here"
29+
auth_token = "your_auth_token_here"
30+
#[...]
31+
```
32+
33+
- Open up **main.py**
34+
- Copy your trial number from twilio's console
35+
- In the *to* entry box paste the number which you had copied
36+
- In the *from* entry box enter the number to which you wanna send the message
37+
- Note - **Make sure you write country code before the numbers - Ex : +1218400xxxx**
38+
- You're all set now, type the message and press the sent button

SMS_SENDER/main.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from tkinter import *
2+
from tkinter import ttk
3+
from API import Send_msg
4+
from tkinter import messagebox
5+
6+
class Window:
7+
def __init__(self):
8+
self.root = Tk()
9+
self.root.geometry("1000x800")
10+
self.root.title("Sms sender")
11+
self.root.resizable(0,0)
12+
self.root.tk.call("source", "sun-valley.tcl")
13+
self.root.tk.call("set_theme", "dark")
14+
self.main()
15+
self.root.mainloop()
16+
17+
def main(self):
18+
head = Label(text="SMS sender")
19+
head.pack()
20+
body_lbl = Label(text="BODY")
21+
body_lbl.place(x=10, y=50)
22+
self.body = Text(width=141,height=10)
23+
self.body.place(x=3, y=90)
24+
to_lbl = Label(text="To")
25+
to_lbl.place(x=10,y=290)
26+
self.to_ent = ttk.Entry(width=40)
27+
self.to_ent.place(x=10,y=340)
28+
from_lbl = Label(text="From")
29+
from_lbl.place(x=10,y=390)
30+
self.from_ent =ttk.Entry(width=40)
31+
self.from_ent.place(x=10,y=420)
32+
send = ttk.Button(text="Send",style="Accent.TButton", width=20,command=self.send)
33+
send.place(x=800,y=700)
34+
35+
def send(self):
36+
try:
37+
Send_msg(self.body.get('1.0','end'),self.to_ent.get(),self.from_ent.get())
38+
messagebox.showinfo("Success","Message sent successfully")
39+
except:
40+
messagebox.showerror("Error","Error occured in API.py")
41+
42+
window = Window()

SMS_SENDER/sun-valley.tcl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright © 2021 rdbende <rdbende@gmail.com>
2+
3+
source [file join [file dirname [info script]] theme dark.tcl]
4+
5+
option add *tearOff 0
6+
7+
proc set_theme {mode} {
8+
if {$mode == "dark"} {
9+
ttk::style theme use "sun-valley-dark"
10+
11+
array set colors {
12+
-fg "#ffffff"
13+
-bg "#1c1c1c"
14+
-disabledfg "#595959"
15+
-selectfg "#ffffff"
16+
-selectbg "#2f60d8"
17+
}
18+
19+
ttk::style configure . \
20+
-background $colors(-bg) \
21+
-foreground $colors(-fg) \
22+
-troughcolor $colors(-bg) \
23+
-focuscolor $colors(-selectbg) \
24+
-selectbackground $colors(-selectbg) \
25+
-selectforeground $colors(-selectfg) \
26+
-insertwidth 1 \
27+
-insertcolor $colors(-fg) \
28+
-fieldbackground $colors(-selectbg) \
29+
-font {"Segoe Ui" 10} \
30+
-borderwidth 1 \
31+
-relief flat
32+
33+
tk_setPalette \
34+
background [ttk::style lookup . -background] \
35+
foreground [ttk::style lookup . -foreground] \
36+
highlightColor [ttk::style lookup . -focuscolor] \
37+
selectBackground [ttk::style lookup . -selectbackground] \
38+
selectForeground [ttk::style lookup . -selectforeground] \
39+
activeBackground [ttk::style lookup . -selectbackground] \
40+
activeForeground [ttk::style lookup . -selectforeground]
41+
42+
ttk::style map . -foreground [list disabled $colors(-disabledfg)]
43+
44+
option add *font [ttk::style lookup . -font]
45+
option add *Menu.selectcolor $colors(-fg)
46+
option add *Menu.background #2f2f2f
47+
}
48+
}

SMS_SENDER/theme/dark.tcl

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright © 2021 rdbende <rdbende@gmail.com>
2+
3+
# A stunning dark theme for ttk based on Microsoft's Sun Valley visual style
4+
5+
package require Tk 8.6
6+
7+
namespace eval ttk::theme::sun-valley-dark {
8+
variable version 1.0
9+
package provide ttk::theme::sun-valley-dark $version
10+
11+
ttk::style theme create sun-valley-dark -parent clam -settings {
12+
proc load_images {imgdir} {
13+
variable images
14+
foreach file [glob -directory $imgdir *.png] {
15+
set images([file tail [file rootname $file]]) \
16+
[image create photo -file $file -format png]
17+
}
18+
}
19+
20+
load_images [file join [file dirname [info script]] dark]
21+
22+
array set colors {
23+
-fg "#ffffff"
24+
-bg "#1c1c1c"
25+
-disabledfg "#595959"
26+
-selectfg "#ffffff"
27+
-selectbg "#2f60d8"
28+
}
29+
30+
ttk::style layout Accent.TButton {
31+
AccentButton.button -children {
32+
AccentButton.padding -children {
33+
AccentButton.label -side left -expand 1
34+
}
35+
}
36+
}
37+
38+
# Button
39+
ttk::style configure TButton -padding {8 4} -anchor center -foreground $colors(-fg)
40+
41+
ttk::style map TButton -foreground \
42+
[list disabled #7a7a7a \
43+
pressed #d0d0d0]
44+
45+
ttk::style element create Button.button image \
46+
[list $images(button-rest) \
47+
{selected disabled} $images(button-disabled) \
48+
disabled $images(button-disabled) \
49+
selected $images(button-rest) \
50+
pressed $images(button-pressed) \
51+
active $images(button-hover) \
52+
] -border 4 -sticky nsew
53+
54+
55+
# Accent.TButton
56+
ttk::style configure Accent.TButton -padding {8 4} -anchor center -foreground #000000
57+
58+
ttk::style map Accent.TButton -foreground \
59+
[list pressed #25536a \
60+
disabled #a5a5a5]
61+
62+
ttk::style element create AccentButton.button image \
63+
[list $images(button-accent-rest) \
64+
{selected disabled} $images(button-accent-disabled) \
65+
disabled $images(button-accent-disabled) \
66+
selected $images(button-accent-rest) \
67+
pressed $images(button-accent-pressed) \
68+
active $images(button-accent-hover) \
69+
] -border 4 -sticky nsew
70+
71+
# Entry
72+
ttk::style configure TEntry -foreground $colors(-fg)
73+
74+
ttk::style map TEntry -foreground \
75+
[list disabled #757575 \
76+
pressed #cfcfcf
77+
]
78+
79+
ttk::style element create Entry.field \
80+
image [list $images(entry-rest) \
81+
{focus hover !invalid} $images(entry-focus) \
82+
invalid $images(entry-invalid) \
83+
disabled $images(entry-disabled) \
84+
{focus !invalid} $images(entry-focus) \
85+
hover $images(entry-hover) \
86+
] -border 5 -padding 8 -sticky nsew
87+
88+
}
89+
}
262 Bytes
Loading
373 Bytes
Loading
363 Bytes
Loading
377 Bytes
Loading
301 Bytes
Loading
276 Bytes
Loading
288 Bytes
Loading

SMS_SENDER/theme/dark/button-rest.png

301 Bytes
Loading

SMS_SENDER/theme/dark/empty.png

129 Bytes
Loading
273 Bytes
Loading

SMS_SENDER/theme/dark/entry-focus.png

335 Bytes
Loading

SMS_SENDER/theme/dark/entry-hover.png

269 Bytes
Loading
324 Bytes
Loading

SMS_SENDER/theme/dark/entry-rest.png

297 Bytes
Loading

0 commit comments

Comments
 (0)