1
\$\begingroup\$

I am new to Python and tkinter and I made software which checks Windows computer's usage of: CPU, RAM, Storage, Upload Speed, Download Speed, Latency and Ping. If the output exceeds the input, an automated email will be sent. All tasks are scheduled in minute(s).

Actually, the software is running and doing its job but once I clicked Start Task the GUI will be unresponsive and it's showing Not Responding because of schedule while loop, while the code is perfectly running in the background. I know it because during the test, I am receiving warning emails as expected. I even tested it using one button which should print Hello World each 1 minute , again schedule while loop is freezing the GUI while its outputting Hello World.

Any hints and suggestions would be very kind and precious.

Thank you very much.

Code

This uses Python 3.8.5.

The GUI was generated using PAGE RAD with a few modifications I made.

To send an automated email, you should not use 2-Factor Authentication or it will fail to send.

Usage : Simply input 1 in all fields of System Preferences and in Email Preferences input your SMTP, email address, password and again your email address or any other one to receive alert or warning emails.

import sys
import tkinter as tk
from tkinter import DoubleVar, IntVar, StringVar
import tkinter.ttk as ttk
import schedule  
import time 
import psutil, shutil
from win10toast import ToastNotifier 
import speedtest
from pythonping import ping
import email.message
import smtplib
import webbrowser



def vp_start_gui():
    global val, w, root
    root = tk.Tk()
    top = Toplevel1 (root)
    init(root, top)
    root.mainloop()

w = None

def init(top, gui, *args, **kwargs):
    global w, top_level, root
    w = gui
    top_level = top
    root = top

def destroy_window():
  
    global top_level
    top_level.destroy()
    top_level = None

def create_Toplevel1(rt, *args, **kwargs):
    global w, w_win, root
    root = rt
    w = tk.Toplevel(root)
    top = Toplevel1(w)
    init(w, top, *args, **kwargs)
    return (w, top)

def destroy_Toplevel1():
    global w
    w.destroy()
    w = None

class Toplevel1:
    def __init__(self, top=None):
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85'
        _ana2color = '#ececec' # Closest X11 color: 'gray92'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.',background=_bgcolor)
        self.style.configure('.',foreground=_fgcolor)
        self.style.configure('.',font="TkDefaultFont")
        self.style.map('.',background=
            [('selected', _compcolor), ('active',_ana2color)])

        top.geometry("500x620+359+59")
        top.minsize(120, 1)
        top.maxsize(1370, 749)
        top.resizable(0,  0)
        top.title("System Watchdog")
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        cpu = IntVar()
        ram = DoubleVar()
        storage = IntVar()
        Ping = StringVar()
        upload_sp = DoubleVar()
        download_sp = DoubleVar()
        latency = DoubleVar()
        task_timer = IntVar()
        smtp = StringVar()
        sender_email = StringVar()
        sender_pwd = StringVar()
        receiver_email = StringVar()

        n = ToastNotifier()

        def cpu_check():
            cpu_usage = psutil.cpu_percent() 
            return cpu_usage < cpu.get()
        

        def disc_space_check():  
            disk_usage = shutil.disk_usage("/")
            disk_total = disk_usage.total
            disk_free = disk_usage.used
            threshold = disk_free / disk_total * 100
            return threshold > storage.get()
        


        def available_memory_check():
            available = psutil.virtual_memory().available
            available_in_GB = available / 1000000000
            return available_in_GB >= ram.get()
        

        def upload_speed():
            st = speedtest.Speedtest()
            upload_s = round(st.upload()/1000000, 2)
            return upload_s >= upload_sp.get()
        


        def download_speed():
            st = speedtest.Speedtest() 
            download_s = round(st.download()/1000000, 2)
            return download_s >= download_sp.get()
        

        def latency_check():
            st = speedtest.Speedtest() 
            st.get_best_server()
            return st.results.ping <= latency.get()
        

        def ping_ip():

            p = Ping.get()

            l = list(ping(p))

            return str(l[0]).startswith('Reply')
           

        def generate_email(sender, receiver, subject, body):
        
        
            message = email.message.EmailMessage()
            message['Subject'] = subject
            message['From'] = sender
            message['To'] = receiver
            message.set_content(body)

            return message
        
        def send_email(package):
        
            mail_server = smtplib.SMTP(smtp.get())
            mail_server.starttls() 
            mail_server.login(sender_email.get(), sender_pwd.get()) 
            mail_server.send_message(package)
            mail_server.quit()


        def email_warning(warning):
            sender = sender_email.get()
            receiver = receiver_email.get()
            subject = warning
            body = "Alert! Check Your System ASAP!"
            message = generate_email(sender, receiver, subject, body)
            send_email(message)

        def mailing():

            if not cpu_check():
                n.show_toast("Warning!", "CPU Usage is greater than " + " " + str(cpu.get()), duration = 10) 
                subject = 'Alert! - CPU Usage is greater than ' + ' ' + str(cpu.get())
                email_warning(subject)

            if not disc_space_check():
                n.show_toast("Warning!", "Available disk space is less than " + ' ' + str(storage.get()) + '!', duration = 10)
                subject = "Alert! - Available disk space is less than " + ' ' + str(storage.get()) + '!'
                email_warning(subject)

            if not available_memory_check():
                n.show_toast("Warning!", "Available memory is less than " + ' ' + str(ram.get()) + '!', duration = 10)
                subject = "Alert! - Available memory is less than " + ' ' + str(ram.get()) + '!'
                email_warning(subject)

            if not upload_speed():
                n.show_toast("Warning!", "Low upload speed! Upload speed is less than " + ' ' + str(upload_sp.get()))
                subject = "Alert! - Low upload speed! Upload speed is less than " + ' ' + str(upload_sp.get())
                email_warning(subject)

            if not download_speed():
                n.show_toast("Warning!", "Low download speed! Download speed is less than " + ' ' + str(download_sp.get()))
                subject = "Alert! - Low download speed! Download speed is less than " + ' ' + str(download_sp.get())
                email_warning(subject)


            if not latency_check():
                n.show_toast("Warning!", "High Latency! Latency is higher than " + ' ' + str(latency.get()))
                subject = "Alert! - High Latency! Latency is higher than " + ' ' + str(latency.get())
                email_warning(subject)

            if not ping_ip():
                n.show_toast("Warning!", "Unreachable IP, Request timed out!")
                subject = "Alert! - Unreachable IP, Request timed out!"
                email_warning(subject)

        def linked_in():
            url='https://linkedin.com/in/cyber-services'
            webbrowser.open_new_tab(url)

        def git_hub():
            url='https://github.com/IT-Support-L2'
            webbrowser.open_new_tab(url)

        def paypal():
            url='https://www.paypal.com/paypalme/HamdiBouaskar'
            webbrowser.open_new_tab(url)

        def StartTask():
            schedule.every(task_timer.get()).minutes.do(cpu_check)
            schedule.every(task_timer.get()).minutes.do(disc_space_check)
            schedule.every(task_timer.get()).minutes.do(available_memory_check)
            schedule.every(task_timer.get()).minutes.do(upload_speed)
            schedule.every(task_timer.get()).minutes.do(download_speed)
            schedule.every(task_timer.get()).minutes.do(latency_check)
            schedule.every(task_timer.get()).minutes.do(ping_ip)
            schedule.every(task_timer.get()).minutes.do(mailing)

            while True:
              schedule.run_pending()
              time.sleep(1)

        def StopTask():
            schedule.cancel_job(StartTask)

        self.TSeparator1 = ttk.Separator(top)
        self.TSeparator1.place(x=30, y=40, width=442)

        self.style.configure('TNotebook.Tab', background=_bgcolor)
        self.style.configure('TNotebook.Tab', foreground=_fgcolor)
        self.style.map('TNotebook.Tab', background=
            [('selected', _compcolor), ('active',_ana2color)])
        self.TNotebook1 = ttk.Notebook(top)
        self.TNotebook1.place(x=25, y=53, height=526, width=450)
        self.TNotebook1_t1_1 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t1_1, padding=3)
        self.TNotebook1.tab(0, text="System Preferences", compound="left"
                ,underline="-1", )
        self.TNotebook1_t1_1.configure(borderwidth="1")
        self.TNotebook1_t1_1.configure(relief="sunken")
        self.TNotebook1_t1_1.configure(background="#353535")
        self.TNotebook1_t1_1.configure(highlightbackground="#d9d9d9")
        self.TNotebook1_t1_1.configure(highlightcolor="black")
        self.TNotebook1_t2_1 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t2_1, padding=3)
        self.TNotebook1.tab(1, text="Email Preferences", compound="left"
                ,underline="-1", )
        self.TNotebook1_t2_1.configure(borderwidth="1")
        self.TNotebook1_t2_1.configure(background="#000000")
        self.TNotebook1_t2_1.configure(highlightbackground="#d9d9d9")
        self.TNotebook1_t2_1.configure(highlightcolor="black")
        self.TNotebook1_t3_1 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t3_1, padding=3)
        self.TNotebook1.tab(2, text="Help",compound="left",underline="-1",)
        self.TNotebook1_t3_1.configure(background="#d9d9d9")
        self.TNotebook1_t3_1.configure(highlightbackground="#d9d9d9")
        self.TNotebook1_t3_1.configure(highlightcolor="black")
        self.TNotebook1_t4_1 = tk.Frame(self.TNotebook1)
        self.TNotebook1.add(self.TNotebook1_t4_1, padding=3)
        self.TNotebook1.tab(3, text="Follow me", compound="left", underline="-1")
        self.TNotebook1_t4_1.configure(background="#d9d9d9")
        self.TNotebook1_t4_1.configure(highlightbackground="#d9d9d9")
        self.TNotebook1_t4_1.configure(highlightcolor="black")

        self.Labelframe1 = tk.LabelFrame(self.TNotebook1_t1_1)
        self.Labelframe1.place(x=10, y=10, height=48, width=421)
        self.Labelframe1.configure(relief='ridge')
        self.Labelframe1.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe1.configure(foreground="black")
        self.Labelframe1.configure(relief="ridge")
        self.Labelframe1.configure(text='''CPU Check''')
        self.Labelframe1.configure(background="#d9d9d9")
        self.Labelframe1.configure(highlightbackground="#d9d9d9")
        self.Labelframe1.configure(highlightcolor="black")

        self.CPU_Entry = tk.Entry(self.Labelframe1)
        self.CPU_Entry.place(x=290, y=15, height=27, width=104
                , bordermode='ignore')
        self.CPU_Entry.configure(background="#c1ffc1")
        self.CPU_Entry.configure(cursor="")
        self.CPU_Entry.configure(disabledforeground="#a3a3a3")
        self.CPU_Entry.configure(font="TkFixedFont")
        self.CPU_Entry.configure(foreground="#000000")
        self.CPU_Entry.configure(highlightbackground="#d9d9d9")
        self.CPU_Entry.configure(highlightcolor="black")
        self.CPU_Entry.configure(insertbackground="black")
        self.CPU_Entry.configure(justify='center')
        self.CPU_Entry.configure(selectbackground="blue")
        self.CPU_Entry.configure(selectforeground="white")
        self.CPU_Entry.configure(textvariable=cpu)

        self.Label4 = tk.Label(self.Labelframe1)
        self.Label4.place(x=60, y=20, height=14, width=93, bordermode='ignore')
        self.Label4.configure(activebackground="#f9f9f9")
        self.Label4.configure(activeforeground="black")
        self.Label4.configure(background="#d9d9d9")
        self.Label4.configure(disabledforeground="#a3a3a3")
        self.Label4.configure(foreground="#000000")
        self.Label4.configure(highlightbackground="#d9d9d9")
        self.Label4.configure(highlightcolor="black")
        self.Label4.configure(text='''Enter CPU''')

        self.Labelframe2 = tk.LabelFrame(self.TNotebook1_t1_1)
        self.Labelframe2.place(x=10, y=70, height=48, width=421)
        self.Labelframe2.configure(relief='ridge')
        self.Labelframe2.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe2.configure(foreground="black")
        self.Labelframe2.configure(relief="ridge")
        self.Labelframe2.configure(text='''RAM Check''')
        self.Labelframe2.configure(background="#d9d9d9")
        self.Labelframe2.configure(highlightbackground="#d9d9d9")
        self.Labelframe2.configure(highlightcolor="black")

        self.Label5 = tk.Label(self.Labelframe2)
        self.Label5.place(x=60, y=20, height=14, width=93, bordermode='ignore')
        self.Label5.configure(activebackground="#f9f9f9")
        self.Label5.configure(activeforeground="black")
        self.Label5.configure(background="#d9d9d9")
        self.Label5.configure(disabledforeground="#a3a3a3")
        self.Label5.configure(foreground="#000000")
        self.Label5.configure(highlightbackground="#d9d9d9")
        self.Label5.configure(highlightcolor="black")
        self.Label5.configure(text='''Enter RAM''')

        self.RAM_Entry = tk.Entry(self.Labelframe2)
        self.RAM_Entry.place(x=287, y=16, height=27, width=104, bordermode='ignore')
        self.RAM_Entry.configure(background="#c1ffc1")
        self.RAM_Entry.configure(disabledforeground="#a3a3a3")
        self.RAM_Entry.configure(font="TkFixedFont")
        self.RAM_Entry.configure(foreground="#000000")
        self.RAM_Entry.configure(highlightbackground="#d9d9d9")
        self.RAM_Entry.configure(highlightcolor="black")
        self.RAM_Entry.configure(insertbackground="black")
        self.RAM_Entry.configure(justify='center')
        self.RAM_Entry.configure(selectbackground="blue")
        self.RAM_Entry.configure(selectforeground="white")
        self.RAM_Entry.configure(textvariable=ram)

        self.Labelframe3 = tk.LabelFrame(self.TNotebook1_t1_1)
        self.Labelframe3.place(x=10, y=130, height=48, width=420)
        self.Labelframe3.configure(relief='ridge')
        self.Labelframe3.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe3.configure(foreground="black")
        self.Labelframe3.configure(relief="ridge")
        self.Labelframe3.configure(text='''Storage Check''')
        self.Labelframe3.configure(background="#d9d9d9")
        self.Labelframe3.configure(highlightbackground="#d9d9d9")
        self.Labelframe3.configure(highlightcolor="black")

        self.Label6 = tk.Label(self.Labelframe3)
        self.Label6.place(x=60, y=20, height=14, width=103, bordermode='ignore')
        self.Label6.configure(activebackground="#f9f9f9")
        self.Label6.configure(activeforeground="black")
        self.Label6.configure(background="#d9d9d9")
        self.Label6.configure(disabledforeground="#a3a3a3")
        self.Label6.configure(foreground="#000000")
        self.Label6.configure(highlightbackground="#d9d9d9")
        self.Label6.configure(highlightcolor="black")
        self.Label6.configure(text='''Enter Storage''')

        self.STORAGE_Entry = tk.Entry(self.Labelframe3)
        self.STORAGE_Entry.place(x=287, y=16, height=27, width=104
                , bordermode='ignore')
        self.STORAGE_Entry.configure(background="#c1ffc1")
        self.STORAGE_Entry.configure(disabledforeground="#a3a3a3")
        self.STORAGE_Entry.configure(font="TkFixedFont")
        self.STORAGE_Entry.configure(foreground="#000000")
        self.STORAGE_Entry.configure(highlightbackground="#d9d9d9")
        self.STORAGE_Entry.configure(highlightcolor="black")
        self.STORAGE_Entry.configure(insertbackground="black")
        self.STORAGE_Entry.configure(justify='center')
        self.STORAGE_Entry.configure(selectbackground="blue")
        self.STORAGE_Entry.configure(selectforeground="white")
        self.STORAGE_Entry.configure(textvariable=storage)

        self.Labelframe4 = tk.LabelFrame(self.TNotebook1_t1_1)
        self.Labelframe4.place(x=10, y=190, height=48, width=420)
        self.Labelframe4.configure(relief='ridge')
        self.Labelframe4.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe4.configure(foreground="black")
        self.Labelframe4.configure(relief="ridge")
        self.Labelframe4.configure(text='''Ping / Reachability Check''')
        self.Labelframe4.configure(background="#d9d9d9")
        self.Labelframe4.configure(highlightbackground="#d9d9d9")
        self.Labelframe4.configure(highlightcolor="black")

        self.PING_Entry = tk.Entry(self.Labelframe4)
        self.PING_Entry.place(x=160, y=16, height=27, width=234
                , bordermode='ignore')
        self.PING_Entry.configure(background="#c1ffc1")
        self.PING_Entry.configure(disabledforeground="#a3a3a3")
        self.PING_Entry.configure(font="TkFixedFont")
        self.PING_Entry.configure(foreground="#000000")
        self.PING_Entry.configure(highlightbackground="#d9d9d9")
        self.PING_Entry.configure(highlightcolor="black")
        self.PING_Entry.configure(insertbackground="black")
        self.PING_Entry.configure(justify='center')
        self.PING_Entry.configure(selectbackground="blue")
        self.PING_Entry.configure(selectforeground="white")
        self.PING_Entry.configure(textvariable=Ping)

        self.Label12 = tk.Label(self.Labelframe4)
        self.Label12.place(x=40, y=20, height=16, width=94, bordermode='ignore')
        self.Label12.configure(activebackground="#f9f9f9")
        self.Label12.configure(activeforeground="black")
        self.Label12.configure(background="#d9d9d9")
        self.Label12.configure(disabledforeground="#a3a3a3")
        self.Label12.configure(foreground="#000000")
        self.Label12.configure(highlightbackground="#d9d9d9")
        self.Label12.configure(highlightcolor="black")
        self.Label12.configure(text='''Enter IP Address''')

        self.Labelframe5 = tk.LabelFrame(self.TNotebook1_t1_1)
        self.Labelframe5.place(x=10, y=250, height=48, width=420)
        self.Labelframe5.configure(relief='ridge')
        self.Labelframe5.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe5.configure(foreground="black")
        self.Labelframe5.configure(relief="ridge")
        self.Labelframe5.configure(text='''Upload Speed Check''')
        self.Labelframe5.configure(background="#d9d9d9")
        self.Labelframe5.configure(highlightbackground="#d9d9d9")
        self.Labelframe5.configure(highlightcolor="black")

        self.UPLOAD_Entry = tk.Entry(self.Labelframe5)
        self.UPLOAD_Entry.place(x=287, y=16, height=27, width=104
                , bordermode='ignore')
        self.UPLOAD_Entry.configure(background="#c1ffc1")
        self.UPLOAD_Entry.configure(disabledforeground="#a3a3a3")
        self.UPLOAD_Entry.configure(font="TkFixedFont")
        self.UPLOAD_Entry.configure(foreground="#000000")
        self.UPLOAD_Entry.configure(highlightbackground="#d9d9d9")
        self.UPLOAD_Entry.configure(highlightcolor="black")
        self.UPLOAD_Entry.configure(insertbackground="black")
        self.UPLOAD_Entry.configure(justify='center')
        self.UPLOAD_Entry.configure(selectbackground="blue")
        self.UPLOAD_Entry.configure(selectforeground="white")
        self.UPLOAD_Entry.configure(textvariable=upload_sp)

        self.Label7 = tk.Label(self.Labelframe5)
        self.Label7.place(x=30, y=20, height=14, width=133, bordermode='ignore')
        self.Label7.configure(activebackground="#f9f9f9")
        self.Label7.configure(activeforeground="black")
        self.Label7.configure(background="#d9d9d9")
        self.Label7.configure(disabledforeground="#a3a3a3")
        self.Label7.configure(foreground="#000000")
        self.Label7.configure(highlightbackground="#d9d9d9")
        self.Label7.configure(highlightcolor="black")
        self.Label7.configure(text='''Enter Upload Speed''')

        self.Labelframe6 = tk.LabelFrame(self.TNotebook1_t1_1)
        self.Labelframe6.place(x=10, y=370, height=48, width=420)
        self.Labelframe6.configure(relief='ridge')
        self.Labelframe6.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe6.configure(foreground="black")
        self.Labelframe6.configure(relief="ridge")
        self.Labelframe6.configure(text='''Latency Check''')
        self.Labelframe6.configure(background="#d9d9d9")
        self.Labelframe6.configure(highlightbackground="#d9d9d9")
        self.Labelframe6.configure(highlightcolor="black")

        self.Label8 = tk.Label(self.Labelframe6)
        self.Label8.place(x=40, y=20, height=14, width=83, bordermode='ignore')
        self.Label8.configure(activebackground="#f9f9f9")
        self.Label8.configure(activeforeground="black")
        self.Label8.configure(background="#d9d9d9")
        self.Label8.configure(disabledforeground="#a3a3a3")
        self.Label8.configure(foreground="#000000")
        self.Label8.configure(highlightbackground="#d9d9d9")
        self.Label8.configure(highlightcolor="black")
        self.Label8.configure(text='''Enter Latency''')

        self.LATENCY_Entry = tk.Entry(self.Labelframe6)
        self.LATENCY_Entry.place(x=287, y=16, height=27, width=104
                , bordermode='ignore')
        self.LATENCY_Entry.configure(background="#c1ffc1")
        self.LATENCY_Entry.configure(disabledforeground="#a3a3a3")
        self.LATENCY_Entry.configure(font="TkFixedFont")
        self.LATENCY_Entry.configure(foreground="#000000")
        self.LATENCY_Entry.configure(highlightbackground="#d9d9d9")
        self.LATENCY_Entry.configure(highlightcolor="black")
        self.LATENCY_Entry.configure(insertbackground="black")
        self.LATENCY_Entry.configure(justify='center')
        self.LATENCY_Entry.configure(selectbackground="blue")
        self.LATENCY_Entry.configure(selectforeground="white")
        self.LATENCY_Entry.configure(textvariable=latency)

        self.Labelframe11 = tk.LabelFrame(self.TNotebook1_t1_1)
        self.Labelframe11.place(x=10, y=430, height=48, width=420)
        self.Labelframe11.configure(relief='ridge')
        self.Labelframe11.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe11.configure(foreground="black")
        self.Labelframe11.configure(relief="ridge")
        self.Labelframe11.configure(text='''Task Scheduler''')
        self.Labelframe11.configure(background="#d9d9d9")
        self.Labelframe11.configure(highlightbackground="#d9d9d9")
        self.Labelframe11.configure(highlightcolor="black")

        self.Label3 = tk.Label(self.Labelframe11)
        self.Label3.place(x=40, y=20, height=17, width=203, bordermode='ignore')
        self.Label3.configure(activebackground="#f9f9f9")
        self.Label3.configure(activeforeground="black")
        self.Label3.configure(background="#d9d9d9")
        self.Label3.configure(disabledforeground="#a3a3a3")
        self.Label3.configure(foreground="#000000")
        self.Label3.configure(highlightbackground="#d9d9d9")
        self.Label3.configure(highlightcolor="black")
        self.Label3.configure(text='''Enter Check Time Interval in minute-s''')

        self.SCHEDULER_Entry = tk.Entry(self.Labelframe11)
        self.SCHEDULER_Entry.place(x=287, y=15, height=27, width=104
                , bordermode='ignore')
        self.SCHEDULER_Entry.configure(background="#c1ffc1")
        self.SCHEDULER_Entry.configure(disabledforeground="#a3a3a3")
        self.SCHEDULER_Entry.configure(font="TkFixedFont")
        self.SCHEDULER_Entry.configure(foreground="#000000")
        self.SCHEDULER_Entry.configure(highlightbackground="#d9d9d9")
        self.SCHEDULER_Entry.configure(highlightcolor="black")
        self.SCHEDULER_Entry.configure(insertbackground="black")
        self.SCHEDULER_Entry.configure(justify='center')
        self.SCHEDULER_Entry.configure(selectbackground="blue")
        self.SCHEDULER_Entry.configure(selectforeground="white")
        self.SCHEDULER_Entry.configure(textvariable=task_timer)

        self.Labelframe12 = tk.LabelFrame(self.TNotebook1_t1_1)
        self.Labelframe12.place(x=10, y=310, height=48, width=420)
        self.Labelframe12.configure(relief='groove')
        self.Labelframe12.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe12.configure(foreground="black")
        self.Labelframe12.configure(text='''Download Speed Check''')
        self.Labelframe12.configure(background="#d9d9d9")
        self.Labelframe12.configure(highlightbackground="#d9d9d9")
        self.Labelframe12.configure(highlightcolor="black")

        self.Label13 = tk.Label(self.Labelframe12)
        self.Label13.place(x=40, y=20, height=14, width=133, bordermode='ignore')

        self.Label13.configure(activebackground="#f9f9f9")
        self.Label13.configure(activeforeground="black")
        self.Label13.configure(background="#d9d9d9")
        self.Label13.configure(disabledforeground="#a3a3a3")
        self.Label13.configure(foreground="#000000")
        self.Label13.configure(highlightbackground="#d9d9d9")
        self.Label13.configure(highlightcolor="black")
        self.Label13.configure(text='''Enter Download Speed''')

        self.DWONLOAD_Entry = tk.Entry(self.Labelframe12)
        self.DWONLOAD_Entry.place(x=287, y=16, height=27, width=104
                , bordermode='ignore')
        self.DWONLOAD_Entry.configure(background="#c1ffc1")
        self.DWONLOAD_Entry.configure(disabledforeground="#a3a3a3")
        self.DWONLOAD_Entry.configure(font="TkFixedFont")
        self.DWONLOAD_Entry.configure(foreground="#000000")
        self.DWONLOAD_Entry.configure(highlightbackground="#d9d9d9")
        self.DWONLOAD_Entry.configure(highlightcolor="black")
        self.DWONLOAD_Entry.configure(insertbackground="black")
        self.DWONLOAD_Entry.configure(justify='center')
        self.DWONLOAD_Entry.configure(selectbackground="blue")
        self.DWONLOAD_Entry.configure(selectforeground="white")
        self.DWONLOAD_Entry.configure(textvariable=download_sp)

        self.Labelframe7 = tk.LabelFrame(self.TNotebook1_t2_1)
        self.Labelframe7.place(x=10, y=30, height=64, width=426)
        self.Labelframe7.configure(relief='ridge')
        self.Labelframe7.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe7.configure(foreground="black")
        self.Labelframe7.configure(relief="ridge")
        self.Labelframe7.configure(text='''SMTP''')
        self.Labelframe7.configure(background="#d9d9d9")
        self.Labelframe7.configure(highlightbackground="#d9d9d9")
        self.Labelframe7.configure(highlightcolor="black")

        self.SMTP_Entry = tk.Entry(self.Labelframe7)
        self.SMTP_Entry.place(x=79, y=19, height=30, width=294
                , bordermode='ignore')
        self.SMTP_Entry.configure(background="#c1ffc1")
        self.SMTP_Entry.configure(disabledforeground="#a3a3a3")
        self.SMTP_Entry.configure(font="TkFixedFont")
        self.SMTP_Entry.configure(foreground="#000000")
        self.SMTP_Entry.configure(highlightbackground="#d9d9d9")
        self.SMTP_Entry.configure(highlightcolor="black")
        self.SMTP_Entry.configure(insertbackground="black")
        self.SMTP_Entry.configure(justify='center')
        self.SMTP_Entry.configure(selectbackground="blue")
        self.SMTP_Entry.configure(selectforeground="white")
        self.SMTP_Entry.configure(textvariable=smtp)

        self.Labelframe8 = tk.LabelFrame(self.TNotebook1_t2_1)
        self.Labelframe8.place(x=10, y=120, height=64, width=426)
        self.Labelframe8.configure(relief='ridge')
        self.Labelframe8.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe8.configure(foreground="black")
        self.Labelframe8.configure(relief="ridge")
        self.Labelframe8.configure(text='''Sender email address''')
        self.Labelframe8.configure(background="#d9d9d9")
        self.Labelframe8.configure(highlightbackground="#d9d9d9")
        self.Labelframe8.configure(highlightcolor="black")

        self.SenderEmailAdres_Entry = tk.Entry(self.Labelframe8)
        self.SenderEmailAdres_Entry.place(x=79, y=19, height=30, width=294
                , bordermode='ignore')
        self.SenderEmailAdres_Entry.configure(background="#c1ffc1")
        self.SenderEmailAdres_Entry.configure(cursor="")
        self.SenderEmailAdres_Entry.configure(disabledforeground="#a3a3a3")
        self.SenderEmailAdres_Entry.configure(exportselection="0")
        self.SenderEmailAdres_Entry.configure(font="TkFixedFont")
        self.SenderEmailAdres_Entry.configure(foreground="#000000")
        self.SenderEmailAdres_Entry.configure(highlightbackground="#a4ffa4")
        self.SenderEmailAdres_Entry.configure(highlightcolor="#bfffbf")
        self.SenderEmailAdres_Entry.configure(insertbackground="#000000")
        self.SenderEmailAdres_Entry.configure(justify='center')
        self.SenderEmailAdres_Entry.configure(selectbackground="blue")
        self.SenderEmailAdres_Entry.configure(selectforeground="white")
        self.SenderEmailAdres_Entry.configure(textvariable=sender_email)

        self.Labelframe9 = tk.LabelFrame(self.TNotebook1_t2_1)
        self.Labelframe9.place(x=10, y=210, height=64, width=426)
        self.Labelframe9.configure(relief='ridge')
        self.Labelframe9.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe9.configure(foreground="black")
        self.Labelframe9.configure(relief="ridge")
        self.Labelframe9.configure(text='''Sender's Password''')
        self.Labelframe9.configure(background="#d9d9d9")
        self.Labelframe9.configure(highlightbackground="#d9d9d9")
        self.Labelframe9.configure(highlightcolor="black")

        self.SenderPWD_Entry = tk.Entry(self.Labelframe9)
        self.SenderPWD_Entry.place(x=79, y=19, height=30, width=294
                , bordermode='ignore')
        self.SenderPWD_Entry.configure(background="#c1ffc1")
        self.SenderPWD_Entry.configure(cursor="")
        self.SenderPWD_Entry.configure(disabledforeground="#a3a3a3")
        self.SenderPWD_Entry.configure(exportselection="0")
        self.SenderPWD_Entry.configure(font="TkFixedFont")
        self.SenderPWD_Entry.configure(foreground="#000000")
        self.SenderPWD_Entry.configure(highlightbackground="#a4ffa4")
        self.SenderPWD_Entry.configure(highlightcolor="#bfffbf")
        self.SenderPWD_Entry.configure(insertbackground="#000000")
        self.SenderPWD_Entry.configure(justify='center')
        self.SenderPWD_Entry.configure(selectbackground="blue")
        self.SenderPWD_Entry.configure(selectforeground="white")
        self.SenderPWD_Entry.configure(show="*")
        self.SenderPWD_Entry.configure(textvariable=sender_pwd)

        self.Labelframe10 = tk.LabelFrame(self.TNotebook1_t2_1)
        self.Labelframe10.place(x=10, y=300, height=64, width=426)
        self.Labelframe10.configure(relief='ridge')
        self.Labelframe10.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Labelframe10.configure(foreground="black")
        self.Labelframe10.configure(relief="ridge")
        self.Labelframe10.configure(text='''Receiver email address''')
        self.Labelframe10.configure(background="#d9d9d9")
        self.Labelframe10.configure(highlightbackground="#d9d9d9")
        self.Labelframe10.configure(highlightcolor="black")

        self.ReceiverEmailAdres_Entry = tk.Entry(self.Labelframe10)
        self.ReceiverEmailAdres_Entry.place(x=79, y=19, height=30, width=294
                , bordermode='ignore')
        self.ReceiverEmailAdres_Entry.configure(background="#c1ffc1")
        self.ReceiverEmailAdres_Entry.configure(cursor="")
        self.ReceiverEmailAdres_Entry.configure(disabledforeground="#a3a3a3")
        self.ReceiverEmailAdres_Entry.configure(exportselection="0")
        self.ReceiverEmailAdres_Entry.configure(font="TkFixedFont")
        self.ReceiverEmailAdres_Entry.configure(foreground="#000000")
        self.ReceiverEmailAdres_Entry.configure(highlightbackground="#a4ffa4")
        self.ReceiverEmailAdres_Entry.configure(highlightcolor="#bfffbf")
        self.ReceiverEmailAdres_Entry.configure(insertbackground="#000000")
        self.ReceiverEmailAdres_Entry.configure(justify='center')
        self.ReceiverEmailAdres_Entry.configure(selectbackground="blue")
        self.ReceiverEmailAdres_Entry.configure(selectforeground="white")
        self.ReceiverEmailAdres_Entry.configure(textvariable=receiver_email)

        self.StartTask_Button = tk.Button(self.TNotebook1_t2_1)
        self.StartTask_Button.place(x=40, y=390, height=34, width=356)
        self.StartTask_Button.configure(activebackground="#bfffbf")
        self.StartTask_Button.configure(activeforeground="#000000")
        self.StartTask_Button.configure(background="#d9d9d9")
        self.StartTask_Button.configure(disabledforeground="#a3a3a3")
        self.StartTask_Button.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.StartTask_Button.configure(foreground="#000000")
        self.StartTask_Button.configure(highlightbackground="#d9d9d9")
        self.StartTask_Button.configure(highlightcolor="black")
        self.StartTask_Button.configure(pady="0")
        self.StartTask_Button.configure(text='''Start Task''')
        self.StartTask_Button.configure(command=StartTask)


        self.Stop_Task = tk.Button(self.TNotebook1_t2_1)
        self.Stop_Task.place(x=40, y=450, height=34, width=356)
        self.Stop_Task.configure(activebackground="#bfffbf")
        self.Stop_Task.configure(activeforeground="#000000")
        self.Stop_Task.configure(background="#d9d9d9")
        self.Stop_Task.configure(disabledforeground="#a3a3a3")
        self.Stop_Task.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Stop_Task.configure(foreground="#000000")
        self.Stop_Task.configure(highlightbackground="#d9d9d9")
        self.Stop_Task.configure(highlightcolor="black")
        self.Stop_Task.configure(pady="0")
        self.Stop_Task.configure(text='''Stop Task''')
        self.Stop_Task.configure(command=StopTask)

        self.TNotebook2 = ttk.Notebook(self.TNotebook1_t3_1)
        self.TNotebook2.place(x=0, y=10, height=475, width=420)
        self.TNotebook2.configure(takefocus="")
        self.TNotebook2_t1_1 = tk.Frame(self.TNotebook2)
        self.TNotebook2.add(self.TNotebook2_t1_1, padding=3)
        self.TNotebook2.tab(0, text="System Preferences", compound="left", underline="-1")
        self.TNotebook2_t1_1.configure(background="#d9d9d9")
        self.TNotebook2_t1_1.configure(highlightbackground="#d9d9d9")
        self.TNotebook2_t1_1.configure(highlightcolor="black")
        self.TNotebook2_t2_1 = tk.Frame(self.TNotebook2)
        self.TNotebook2.add(self.TNotebook2_t2_1, padding=3)
        self.TNotebook2.tab(1, text="Email Preferences", compound="left", underline="-1")
        self.TNotebook2_t2_1.configure(background="#d9d9d9")
        self.TNotebook2_t2_1.configure(highlightbackground="#d9d9d9")
        self.TNotebook2_t2_1.configure(highlightcolor="black")
        self.TNotebook2_t3_1 = tk.Frame(self.TNotebook2)
        self.TNotebook2.add(self.TNotebook2_t3_1, padding=3)
        self.TNotebook2.tab(2, text="License",compound="left",underline="-1",)
        self.TNotebook2_t3_1.configure(background="#d9d9d9")
        self.TNotebook2_t3_1.configure(highlightbackground="#d9d9d9")
        self.TNotebook2_t3_1.configure(highlightcolor="black")

        self.SysPref_Scrolledtext = ScrolledText(self.TNotebook2_t1_1)
        self.SysPref_Scrolledtext.place(x=0, y=19, height=423, width=405)
        self.SysPref_Scrolledtext.configure(background="white")
        self.SysPref_Scrolledtext.configure(font="TkTextFont")
        self.SysPref_Scrolledtext.configure(foreground="black")
        self.SysPref_Scrolledtext.configure(highlightbackground="#d9d9d9")
        self.SysPref_Scrolledtext.configure(highlightcolor="black")
        self.SysPref_Scrolledtext.configure(insertbackground="black")
        self.SysPref_Scrolledtext.configure(insertborderwidth="3")
        self.SysPref_Scrolledtext.configure(selectbackground="blue")
        self.SysPref_Scrolledtext.configure(selectforeground="white")
        self.SysPref_Scrolledtext.configure(wrap="none")

        self.EmailPref_Scrolledtext = ScrolledText(self.TNotebook2_t2_1)
        self.EmailPref_Scrolledtext.place(x=0, y=19, height=423, width=405)
        self.EmailPref_Scrolledtext.configure(background="white")
        self.EmailPref_Scrolledtext.configure(font="TkTextFont")
        self.EmailPref_Scrolledtext.configure(foreground="black")
        self.EmailPref_Scrolledtext.configure(highlightbackground="#d9d9d9")
        self.EmailPref_Scrolledtext.configure(highlightcolor="black")
        self.EmailPref_Scrolledtext.configure(insertbackground="black")
        self.EmailPref_Scrolledtext.configure(insertborderwidth="3")
        self.EmailPref_Scrolledtext.configure(selectbackground="blue")
        self.EmailPref_Scrolledtext.configure(selectforeground="white")
        self.EmailPref_Scrolledtext.configure(wrap="none")

        self.License_Scrolledtext = ScrolledText(self.TNotebook2_t3_1)
        self.License_Scrolledtext.place(x=0, y=19, height=423, width=405)
        self.License_Scrolledtext.configure(background="white")
        self.License_Scrolledtext.configure(font="TkTextFont")
        self.License_Scrolledtext.configure(foreground="black")
        self.License_Scrolledtext.configure(highlightbackground="#d9d9d9")
        self.License_Scrolledtext.configure(highlightcolor="black")
        self.License_Scrolledtext.configure(insertbackground="black")
        self.License_Scrolledtext.configure(insertborderwidth="3")
        self.License_Scrolledtext.configure(selectbackground="blue")
        self.License_Scrolledtext.configure(selectforeground="white")
        self.License_Scrolledtext.configure(wrap="none")

        self.Label1 = tk.Label(self.TNotebook1_t4_1)
        self.Label1.place(x=30, y=45, height=23, width=162)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(activeforeground="black")
        self.Label1.configure(background="#d9d9d9")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(highlightbackground="#d9d9d9")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''Follow me in Linkedin''')

        self.LINKEDIN_Button = tk.Button(self.TNotebook1_t4_1)
        self.LINKEDIN_Button.place(x=268, y=45, height=24, width=157)
        self.LINKEDIN_Button.configure(activebackground="#bfffbf")
        self.LINKEDIN_Button.configure(activeforeground="#000000")
        self.LINKEDIN_Button.configure(background="#d9d9d9")
        self.LINKEDIN_Button.configure(disabledforeground="#a3a3a3")
        self.LINKEDIN_Button.configure(foreground="#000000")
        self.LINKEDIN_Button.configure(highlightbackground="#d9d9d9")
        self.LINKEDIN_Button.configure(highlightcolor="black")
        self.LINKEDIN_Button.configure(pady="0")
        self.LINKEDIN_Button.configure(text='''Linkedin''')
        self.LINKEDIN_Button.configure(command=linked_in)

        self.Label2 = tk.Label(self.TNotebook1_t4_1)
        self.Label2.place(x=30, y=157, height=23, width=162)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(activeforeground="black")
        self.Label2.configure(background="#d9d9d9")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(font="-family {Segoe UI} -size 9 -weight bold")
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(highlightbackground="#d9d9d9")
        self.Label2.configure(highlightcolor="black")
        self.Label2.configure(text='''Follow me in Github''')

        self.GITHUB_Button = tk.Button(self.TNotebook1_t4_1)
        self.GITHUB_Button.place(x=268, y=157, height=24, width=157)
        self.GITHUB_Button.configure(activebackground="#bfffbf")
        self.GITHUB_Button.configure(activeforeground="#000000")
        self.GITHUB_Button.configure(background="#d9d9d9")
        self.GITHUB_Button.configure(disabledforeground="#a3a3a3")
        self.GITHUB_Button.configure(foreground="#000000")
        self.GITHUB_Button.configure(highlightbackground="#d9d9d9")
        self.GITHUB_Button.configure(highlightcolor="black")
        self.GITHUB_Button.configure(pady="0")
        self.GITHUB_Button.configure(text='''Github''')
        self.GITHUB_Button.configure(command=git_hub)

        self.DONATE_Button = tk.Button(self.TNotebook1_t4_1)
        self.DONATE_Button.place(x=20, y=267, height=24, width=407)
        self.DONATE_Button.configure(activebackground="#bfffbf")
        self.DONATE_Button.configure(activeforeground="#000000")
        self.DONATE_Button.configure(background="#d9d9d9")
        self.DONATE_Button.configure(disabledforeground="#a3a3a3")
        self.DONATE_Button.configure(foreground="#000000")
        self.DONATE_Button.configure(highlightbackground="#d9d9d9")
        self.DONATE_Button.configure(highlightcolor="black")
        self.DONATE_Button.configure(pady="0")
        self.DONATE_Button.configure(text='''Donate PayPal''')
        self.DONATE_Button.configure(command=paypal)

        self.Label11 = tk.Label(self.TNotebook1_t4_1)
        self.Label11.place(x=10, y=350, height=49, width=424)
        self.Label11.configure(activebackground="#f9f9f9")
        self.Label11.configure(activeforeground="black")
        self.Label11.configure(background="#d9d9d9")
        self.Label11.configure(disabledforeground="#a3a3a3")
        self.Label11.configure(foreground="#000000")
        self.Label11.configure(highlightbackground="#d9d9d9")
        self.Label11.configure(highlightcolor="black")
        self.Label11.configure(text='''To report a bug or to suggest a feature, feel free to contact me on Github.''')

        self.Label14 = tk.Label(self.TNotebook1_t4_1)
        self.Label14.place(x=40, y=420, height=31, width=364)
        self.Label14.configure(activebackground="#f9f9f9")
        self.Label14.configure(activeforeground="black")
        self.Label14.configure(background="#d9d9d9")
        self.Label14.configure(disabledforeground="#a3a3a3")
        self.Label14.configure(foreground="#000000")
        self.Label14.configure(highlightbackground="#d9d9d9")
        self.Label14.configure(highlightcolor="black")
        self.Label14.configure(justify='left')
        self.Label14.configure(text='''For professional inquiry, contact me at cyber-tech@keemail.me''')

        self.Label10 = tk.Label(top)
        self.Label10.place(x=40, y=10, height=21, width=424)
        self.Label10.configure(activebackground="#f9f9f9")
        self.Label10.configure(activeforeground="black")
        self.Label10.configure(background="#d9d9d9")
        self.Label10.configure(disabledforeground="#a3a3a3")
        self.Label10.configure(font="-family {Segoe UI Black} -size 12 -weight bold")
        self.Label10.configure(foreground="#000000")
        self.Label10.configure(highlightbackground="#d9d9d9")
        self.Label10.configure(highlightcolor="black")
        self.Label10.configure(text='''SYSTEM  WATCHDOG''')

        self.menubar = tk.Menu(top,font="TkMenuFont",bg=_bgcolor,fg=_fgcolor)
        top.configure(menu = self.menubar)

        self.Label9 = tk.Label(top)
        self.Label9.place(x=90, y=590, height=21, width=304)
        self.Label9.configure(activebackground="#f9f9f9")
        self.Label9.configure(activeforeground="black")
        self.Label9.configure(background="#d9d9d9")
        self.Label9.configure(disabledforeground="#a3a3a3")
        self.Label9.configure(font="-family {Segoe UI} -size 10 -weight bold")
        self.Label9.configure(foreground="#000000")
        self.Label9.configure(highlightbackground="#d9d9d9")
        self.Label9.configure(highlightcolor="black")
        self.Label9.configure(text='''By Cyber-Tech ® 2020''')


class AutoScroll(object):
    
    def __init__(self, master):
    
        try:
            vsb = ttk.Scrollbar(master, orient='vertical', command=self.yview)
        except:
            pass
        hsb = ttk.Scrollbar(master, orient='horizontal', command=self.xview)
        try:
            self.configure(yscrollcommand=self._autoscroll(vsb))
        except:
            pass
        self.configure(xscrollcommand=self._autoscroll(hsb))
        self.grid(column=0, row=0, sticky='nsew')
        try:
            vsb.grid(column=1, row=0, sticky='ns')
        except:
            pass
        hsb.grid(column=0, row=1, sticky='ew')
        master.grid_columnconfigure(0, weight=1)
        master.grid_rowconfigure(0, weight=1)
        
        
        methods = tk.Pack.__dict__.keys() | tk.Grid.__dict__.keys() \
                  | tk.Place.__dict__.keys()

        for meth in methods:
            if meth[0] != '_' and meth not in ('config', 'configure'):
                setattr(self, meth, getattr(master, meth))

    @staticmethod
    def _autoscroll(sbar):
        def wrapped(first, last):
            first, last = float(first), float(last)
            if first <= 0 and last >= 1:
                sbar.grid_remove()
            else:
                sbar.grid()
            sbar.set(first, last)
        return wrapped

    def __str__(self):
        return str(self.master)

def _create_container(func):
    
    def wrapped(cls, master, **kw):
        container = ttk.Frame(master)
        container.bind('<Enter>', lambda e: _bound_to_mousewheel(e, container))
        container.bind('<Leave>', lambda e: _unbound_to_mousewheel(e, container))
        return func(cls, container, **kw)
    return wrapped

class ScrolledText(AutoScroll, tk.Text):
    
    @_create_container
    def __init__(self, master, **kw):
        tk.Text.__init__(self, master, **kw)
        AutoScroll.__init__(self, master)

import platform
def _bound_to_mousewheel(event, widget):
    child = widget.winfo_children()[0]
    if platform.system() == 'Windows':
        child.bind_all('<MouseWheel>', lambda e: _on_mousewheel(e, child))
        child.bind_all('<Shift-MouseWheel>', lambda e: _on_shiftmouse(e, child))
    else:
        child.bind_all('<Button-4>', lambda e: _on_mousewheel(e, child))
        child.bind_all('<Button-5>', lambda e: _on_mousewheel(e, child))
        child.bind_all('<Shift-Button-4>', lambda e: _on_shiftmouse(e, child))
        child.bind_all('<Shift-Button-5>', lambda e: _on_shiftmouse(e, child))

def _unbound_to_mousewheel(event, widget):
    if platform.system() == 'Windows':
        widget.unbind_all('<MouseWheel>')
        widget.unbind_all('<Shift-MouseWheel>')
    else:
        widget.unbind_all('<Button-4>')
        widget.unbind_all('<Button-5>')
        widget.unbind_all('<Shift-Button-4>')
        widget.unbind_all('<Shift-Button-5>')

def _on_mousewheel(event, widget):
    if platform.system() == 'Windows':
        widget.yview_scroll(-1*int(event.delta/120),'units')
    else:
        if event.num == 4:
            widget.yview_scroll(-1, 'units')
        elif event.num == 5:
            widget.yview_scroll(1, 'units')

def _on_shiftmouse(event, widget):
    if platform.system() == 'Windows':
        widget.xview_scroll(-1*int(event.delta/120), 'units')
    else:
        if event.num == 4:
            widget.xview_scroll(-1, 'units')
        elif event.num == 5:
            widget.xview_scroll(1, 'units')

if __name__ == '__main__':
    vp_start_gui()
\$\endgroup\$
9
  • \$\begingroup\$ Code not working as expected is off-topic on code review \$\endgroup\$ – Aryan Parekh Nov 4 '20 at 19:28
  • \$\begingroup\$ Actually the code is working, it is showing Not Responding due to several functions running at the same time but its successfully working \$\endgroup\$ – user230552 Nov 4 '20 at 19:38
  • 1
    \$\begingroup\$ I somewhat doubt that you desire this not-responding state. As such, the code isn't working as you intend, and this question is indeed off-topic. Please consider posting this on Stack Overflow instead. \$\endgroup\$ – Reinderien Nov 4 '20 at 19:40
  • 1
    \$\begingroup\$ @Reinderien The Not responding is just the GUI freezing due to calculations, is that off-topic? \$\endgroup\$ – Aryan Parekh Nov 4 '20 at 19:41
  • 2
    \$\begingroup\$ It depends on the focus of the question. It could be edited to emphasize the desire for a general review, but if the main thrust of the question is to fix the not-responding issue then it's off-topic. \$\endgroup\$ – Reinderien Nov 4 '20 at 19:42
4
\$\begingroup\$

I'm going to give you the benefit of the doubt that you actually are just looking for a general review. There's a lot to cover here.

Variable naming

Particularly for a variable as important as w, it really does need a better name. I have no idea what it is. The same is true of val.

Globals

Avoid them. Attempt to pass val, w, root, top_level etc. as parameters; or make a class that holds them, where (for instance) destroy_window would become a class method instead of a global function.

Constants

Move _bgcolor and values like it to "static" scope (within Toplevel1, outside of any method).

RAD isolation

This code is really verbose. It's important to come up with a strategy that isolates the output of your designer tool from code that you've actually written. Currently it's a big crazy mix of both. There are many ways to do this, including subclassing, or simple instantiation.

If you had to re-run your designer, what would happen? Could you trust that it would leave all of your custom code alone in its current state? I wouldn't.

Except / pass

Never do this. Bare except interferes with some signalling exceptions whose absence will surprise you. If you expect that (for instance) ttk.Scrollbar() is going to fail in some way, then catch the specific exception - not every single exception that could ever exist.

Subclassing the strangest way possible

    methods = tk.Pack.__dict__.keys() | tk.Grid.__dict__.keys() \
              | tk.Place.__dict__.keys()

    for meth in methods:
        if meth[0] != '_' and meth not in ('config', 'configure'):
            setattr(self, meth, getattr(master, meth))

is spooky and almost definitely a bad idea. From the looks of it, you're accepting a master (whatever that is - you're missing all type hints), applying a shotgun-approach loop over a handful of predicted attribute names, and setting them as attributes on your own AutoScroll class to basically make it a proxy object.

First of all, this doesn't do what you think. __dict__ does not only return methods - it also returns any static variables set on those three classes.

Second, why the acrobatics? Why not just make AutoScroll a subclass of whatever master is? You further subclass it as ScrolledText anyway, and instantiate it via

    self.SysPref_Scrolledtext = ScrolledText(self.TNotebook2_t1_1)

where TNotebook2_t1_1 is a tk.Frame. So why not just make ScrolledText a subclass of tk.Frame, and instantiate TNotebook2_t1_1 as a ScrolledText directly?

\$\endgroup\$
3
  • \$\begingroup\$ thank you. As I said the GUI code is generated using PAGE, it's true there is some missings but its not my actual intention. My actual needs is how to fix schedule while loop because its the one behind getting freezed GUI while code successfully running in background. I made a test of a GUI with one button and one function and I confirm schedule while loop is behind freezed GUI. \$\endgroup\$ – user230552 Nov 5 '20 at 11:02
  • \$\begingroup\$ We've been over this: if you need to fix something, then it's broken, and if it's broken, it does not belong on Code Review Stack Exchange. \$\endgroup\$ – Reinderien Nov 5 '20 at 14:23
  • \$\begingroup\$ Everything is working as expected except GUI FREEZE, else If you think that my question does not belong to this page, I have to kindly follow your decision. Regards. \$\endgroup\$ – user230552 Nov 5 '20 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy