Passed
Push — master ( 0e330d...56ea18 )
by Deepak
01:14 queued 26s
created

AddOn.on_close()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
import tkinter as tk
2
from tkinter import Frame, Label, Button, X, LEFT
3
from tkinter import messagebox
4
import os
5
import pywhatkit
6
from PIL import Image, ImageTk
7
import Main
8
9
#Main.top.withdraw()
10
window = tk.Tk()
11
window.overrideredirect(True)
12
window.geometry("150x400+908+130")
13
14
title_bar = Frame(window, bg='#4682b4', relief='ridge', bd=1, highlightcolor='#4682b4',highlightthickness=0)
15
title_name = Label(title_bar, text="FYIT ADDON", bg='#4682b4', fg="white")
16
17
width = 150
18
height = 400
19
imgs = Image.open("Assets/addon_bg.png")
20
imgs = imgs.resize((width, height), Image.ANTIALIAS)
21
photoImg = ImageTk.PhotoImage(imgs)
22
ws = Label(window, image=photoImg)
23
ws.pack()
24
25
def WhatsApp():
26
	try:
27
		Main.top.destroy()
28
		import AutoWhatsApp
29
30
	except pywhatkit.InternetException:
31
		messagebox.showerror("No Internet", "Please Check the Internet Connection.")
32
33
def YSearchcall():
34
	import youtubesearch
35
	Main.top.destroy()
36
	'''
37
	try:
38
		import youtubesearch
39
	except pywhatkit.InternetException:
40
		messagebox.showerror("No Internet","Please Check the Internet Connection.")'''
41
42
def closer():
43
	window.destroy()
44
	#window.protocol("WM_DELETE_WINDOW")
45
46
def call_main():
47
	import Main
48
	window.destroy()
49
50
def cancel_shutdown():
51
	try:
52
		pywhatkit.cancelShutdown()
53
		messagebox.showinfo("Shutdown Cancelled.", "Shutdown Scheduled time cancelled Successfully.")
54
	except NameError:
55
		messagebox.showwarning("No Schedule.", "Shutdown is not been Scheduled.")
56
57
def show_hist():
58
	import WA_history
59
60
MainScreen_call = Button(window, text="Video Downloader",
61
                        cursor='hand2', command=call_main)
62
AppButton = Button(window, text="WhatsApp", cursor='hand2', command=WhatsApp)
63
AppButton1 = Button(window, text="FastYoutubeSearch",
64
                    cursor='hand2', command=YSearchcall)
65
closeButton = Button(window, text="Close", cursor='hand2', command=closer)
66
clr_shutdown = Button(window, text="Cancel Shutdown",
67
                      cursor='hand2', command=cancel_shutdown)
68
wb_hist = Button(window, text="View WhatsApp History",
69
                      cursor='hand2', command=show_hist)
70
71
title_bar.pack(fill=X)
72
title_name.pack(side=LEFT)
73
74
AppButton.place(x=10,y=100)
75
AppButton1.place(x=10,y=150)
76
#MainScreen_call.place(x=10,y=200)
77
wb_hist.place(x=10, y=250)
78
clr_shutdown.place(x=10, y=300)
79
closeButton.place(x=10,y=350)
80
81
window.config(bg="green")
82
window.update()
83
Main.top.mainloop()
84
window.mainloop()
85
86
def on_close():
87
    window.destroy()
88
    #sys.exit()
89
90
window.protocol("WM_DELETE_WINDOW", on_close)
91