Passed
Push — master ( 729176...d82ab1 )
by Deepak
55s
created

AutoWhatsApp.on_close()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
import tkinter as tk
2
from tkinter import messagebox, StringVar, IntVar, Tk, Entry, \
3
    Label, PhotoImage, Button, Text, Scrollbar, Y, RIGHT, YES, BOTH
4
from tkinter import ttk
5
import pywhatkit
6
import time
7
from PIL import Image, ImageTk
8
9
win = Tk()      # Bg_Col #1B1B19
10
win.geometry("500x400+400+100")
11
win.title("AutoWhatsapp Message")
12
13
cust_font = font = ('Consolas', 12)
14
width = 500
15
height = 400
16
img = Image.open("Assets/whatsapp_bg.png")
17
img = img.resize((width, height), Image.ANTIALIAS)
18
photoImg = ImageTk.PhotoImage(img)
19
wb = Label(win, image=photoImg)
20
wb.pack()
21
22
MobNum = StringVar()
23
Mob2msg = StringVar()
24
hour = IntVar()
25
minutes = IntVar()
26
27
Number = Label(win, text="Enter the Mobile No",
28
                    font=cust_font, bg="#1B1B19", fg="#ffffff")
29
Number.place(x=55, y=70)
30
31
Message = Label(win, text="Enter the Message", 
32
                    font=cust_font, bg="#1B1B19", fg="#ffffff")
33
Message.place(x=55, y=120)
34
35
hourlabel = Label(win, text="Enter the Hours",
36
                    font=cust_font, bg="#1B1B19", fg="#ffffff")
37
hourlabel.place(x=55, y=220)
38
39
minuteslabel = Label(win, text="Enter the minutes", 
40
                    font=cust_font, bg="#1B1B19", fg="#ffffff")
41
minuteslabel.place(x=55, y=270)
42
43
Entrynum = Entry(win, textvariable=MobNum, font=cust_font)
44
Entrynum.place(x=250, y=70)
45
46
Entrymsg = Text(win, font=cust_font)
47
Entrymsg.place(x=250, y=120, width=185, height=70)
48
49
timehour = Entry(win, textvariable=hour, font=cust_font)
50
timehour.place(x=250, y=220)
51
52
timeminutes = Entry(win, textvariable=minutes, font=cust_font)
53
timeminutes.place(x=250, y=270)
54
55
def go():
56
    messagebox.showinfo("AutoWhatsappMessage", 
57
    "Will open web.whatsapp.com at before 1 minute of Scheduled time and message \
58
    will be send Automatically at Scheduled time exactly Given")
59
    try:
60
        num = MobNum.get()
61
        msg = Entrymsg.get("1.0", "end-1c")
62
        hr = hour.get()
63
        mini = minutes.get()
64
        pywhatkit.sendwhatmsg(num, msg, hr, mini)
65
    except pywhatkit.CallTimeException:
66
        messagebox.showalert("AutoWhatsAppMessage",
67
                             "Set Schedule time More than 1 minute from Current Time")
68
    except pywhatkit.CountryCodeException:
69
        messagebox.showalert("AutoWhatsAppMessage",
70
                             "Please Ensure the mobile number & Coutry code.")
71
    except pywhatkit.InternetException:
72
        messagebox.showalert("No Internet",
73
                             "Please Check the Internet Connection.")
74
75
GoCheck = Button(win, text="Start Schedule", command=go, font=cust_font)
76
GoCheck.place(x=160, y=345)
77
78
label = Label(win, 
79
        text="Time must be in 24 hours Format & Country Code is Must.", 
80
        font=cust_font, bg="#1B1B19", fg="#ffffff")
81
import AddOn
82
infinity = 1
83
while infinity == 1:
84
    for i in range(500):
85
        xpos = i
86
        label.place(x=xpos, y=20)
87
        time.sleep(0.01)
88
        if (xpos == 500):
89
            xpos = 0
90
        win.update()
91
92
        
93
def on_close():
94
    win.destroy()
95
    #import AddOn
96
    sys.exit()
97
98
win.protocol("WM_DELETE_WINDOW", on_close)
99
import AddOn
100
win.mainloop()
101