Skip to content

New python script - SMS sender #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ This is a collection of short Python scripts to solve and automate tasks and sim
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 |
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 |
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 |
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|
10 changes: 10 additions & 0 deletions SMS_SENDER/API.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from twilio.rest import Client

def Send_msg(body,to,from_num):
account_sid = "your_account_sid_here"
auth_token = "your_auth_token_here"
client = Client(account_sid, auth_token)

message = client.messages.create(
body=body, to=to, from_=from_num
)
38 changes: 38 additions & 0 deletions SMS_SENDER/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SMS sender

A simple Tkinter app that uses the Twilio api internally to send messages

# Dependencies
twilio 7.0.0
PyPi [here](https://pypi.org/project/twilio/)

# Setup

Open up your terminal and paste the following -

```
git clone https://github.com/fnplus/Python-scripts-collection
cd "Python-scripts-collection/SMS_SENDER"
pip install twilio
```

Now before proceeding any further head to [Twilio](https://www.twilio.com/) and sign up and follow the steps below

- Navigate to twilio's [console](https://console.twilio.com/)
- Copy your **ACCOUNT SID** and **AUTH_TOKEN**
- In API.py paste them like this

```py
#[...]
def Send_msg(body,to,from_num):
account_sid = "your_account_sid_here"
auth_token = "your_auth_token_here"
#[...]
```

- Open up **main.py**
- Copy your trial number from twilio's console
- In the *to* entry box paste the number which you had copied
- In the *from* entry box enter the number to which you wanna send the message
- Note - **Make sure you write country code before the numbers - Ex : +1218400xxxx**
- You're all set now, type the message and press the sent button
42 changes: 42 additions & 0 deletions SMS_SENDER/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from tkinter import *
from tkinter import ttk
from API import Send_msg
from tkinter import messagebox

class Window:
def __init__(self):
self.root = Tk()
self.root.geometry("1000x800")
self.root.title("Sms sender")
self.root.resizable(0,0)
self.root.tk.call("source", "sun-valley.tcl")
self.root.tk.call("set_theme", "dark")
self.main()
self.root.mainloop()

def main(self):
head = Label(text="SMS sender")
head.pack()
body_lbl = Label(text="BODY")
body_lbl.place(x=10, y=50)
self.body = Text(width=141,height=10)
self.body.place(x=3, y=90)
to_lbl = Label(text="To")
to_lbl.place(x=10,y=290)
self.to_ent = ttk.Entry(width=40)
self.to_ent.place(x=10,y=340)
from_lbl = Label(text="From")
from_lbl.place(x=10,y=390)
self.from_ent =ttk.Entry(width=40)
self.from_ent.place(x=10,y=420)
send = ttk.Button(text="Send",style="Accent.TButton", width=20,command=self.send)
send.place(x=800,y=700)

def send(self):
try:
Send_msg(self.body.get('1.0','end'),self.to_ent.get(),self.from_ent.get())
messagebox.showinfo("Success","Message sent successfully")
except:
messagebox.showerror("Error","Error occured in API.py")

window = Window()
48 changes: 48 additions & 0 deletions SMS_SENDER/sun-valley.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright © 2021 rdbende <rdbende@gmail.com>

source [file join [file dirname [info script]] theme dark.tcl]

option add *tearOff 0

proc set_theme {mode} {
if {$mode == "dark"} {
ttk::style theme use "sun-valley-dark"

array set colors {
-fg "#ffffff"
-bg "#1c1c1c"
-disabledfg "#595959"
-selectfg "#ffffff"
-selectbg "#2f60d8"
}

ttk::style configure . \
-background $colors(-bg) \
-foreground $colors(-fg) \
-troughcolor $colors(-bg) \
-focuscolor $colors(-selectbg) \
-selectbackground $colors(-selectbg) \
-selectforeground $colors(-selectfg) \
-insertwidth 1 \
-insertcolor $colors(-fg) \
-fieldbackground $colors(-selectbg) \
-font {"Segoe Ui" 10} \
-borderwidth 1 \
-relief flat

tk_setPalette \
background [ttk::style lookup . -background] \
foreground [ttk::style lookup . -foreground] \
highlightColor [ttk::style lookup . -focuscolor] \
selectBackground [ttk::style lookup . -selectbackground] \
selectForeground [ttk::style lookup . -selectforeground] \
activeBackground [ttk::style lookup . -selectbackground] \
activeForeground [ttk::style lookup . -selectforeground]

ttk::style map . -foreground [list disabled $colors(-disabledfg)]

option add *font [ttk::style lookup . -font]
option add *Menu.selectcolor $colors(-fg)
option add *Menu.background #2f2f2f
}
}
89 changes: 89 additions & 0 deletions SMS_SENDER/theme/dark.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright © 2021 rdbende <rdbende@gmail.com>

# A stunning dark theme for ttk based on Microsoft's Sun Valley visual style

package require Tk 8.6

namespace eval ttk::theme::sun-valley-dark {
variable version 1.0
package provide ttk::theme::sun-valley-dark $version

ttk::style theme create sun-valley-dark -parent clam -settings {
proc load_images {imgdir} {
variable images
foreach file [glob -directory $imgdir *.png] {
set images([file tail [file rootname $file]]) \
[image create photo -file $file -format png]
}
}

load_images [file join [file dirname [info script]] dark]

array set colors {
-fg "#ffffff"
-bg "#1c1c1c"
-disabledfg "#595959"
-selectfg "#ffffff"
-selectbg "#2f60d8"
}

ttk::style layout Accent.TButton {
AccentButton.button -children {
AccentButton.padding -children {
AccentButton.label -side left -expand 1
}
}
}

# Button
ttk::style configure TButton -padding {8 4} -anchor center -foreground $colors(-fg)

ttk::style map TButton -foreground \
[list disabled #7a7a7a \
pressed #d0d0d0]

ttk::style element create Button.button image \
[list $images(button-rest) \
{selected disabled} $images(button-disabled) \
disabled $images(button-disabled) \
selected $images(button-rest) \
pressed $images(button-pressed) \
active $images(button-hover) \
] -border 4 -sticky nsew


# Accent.TButton
ttk::style configure Accent.TButton -padding {8 4} -anchor center -foreground #000000

ttk::style map Accent.TButton -foreground \
[list pressed #25536a \
disabled #a5a5a5]

ttk::style element create AccentButton.button image \
[list $images(button-accent-rest) \
{selected disabled} $images(button-accent-disabled) \
disabled $images(button-accent-disabled) \
selected $images(button-accent-rest) \
pressed $images(button-accent-pressed) \
active $images(button-accent-hover) \
] -border 4 -sticky nsew

# Entry
ttk::style configure TEntry -foreground $colors(-fg)

ttk::style map TEntry -foreground \
[list disabled #757575 \
pressed #cfcfcf
]

ttk::style element create Entry.field \
image [list $images(entry-rest) \
{focus hover !invalid} $images(entry-focus) \
invalid $images(entry-invalid) \
disabled $images(entry-disabled) \
{focus !invalid} $images(entry-focus) \
hover $images(entry-hover) \
] -border 5 -padding 8 -sticky nsew

}
}
Binary file added SMS_SENDER/theme/dark/button-accent-disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/button-accent-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/button-accent-pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/button-accent-rest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/button-disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/button-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/button-pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/button-rest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/entry-disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/entry-focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/entry-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/entry-invalid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SMS_SENDER/theme/dark/entry-rest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.