1
class QuickScan:
#GUI

    def __init__(self,root,frame):
        self.root = root
        self.frame = frame


        self.mainVTURLframe = ttk.LabelFrame(frame, text='Quick Scan Report')
        self.mainVTURLframe.grid(column=0,row=1,padx=8,pady=4)

        ttk.Label(self.mainVTURLframe, text="Progress:").grid(column=0,row=1,sticky='W')
        self.progressBar = ttk.Progressbar(self.mainVTURLframe, orient='horizontal',length=300, mode='determinate')
        self.progressBar.grid(column=1,row=1)

        ttk.Label(self.mainVTURLframe, text="Status:").grid(column=0, row=3, sticky='W')  # <== right-align
        self.status = StringVar()
        statusEntry = ttk.Entry(self.mainVTURLframe, width=Consts.ENTRY_WIDTH, textvariable=self.status, state='readonly')
        statusEntry.grid(column=1, row=3, sticky='W')
    
        chooseFileButton = ttk.Button(self.mainVTURLframe, text="Scan Now!", width=40,command=self.getfile).grid(column=1, row=0)

    def md5(self,fname):
        hash_md5 = hashlib.md5()
        try:
            with open(fname, "rb") as f:
                for chunk in iter(lambda: f.read(2 ** 20), b""):
                    hash_md5.update(chunk)
        except Exception:
            pass
        return hash_md5.hexdigest()

    def get_all_abs_paths(self,rootdir):
        viruslist = open('C:/FYP/SecuCOM2022/virusshare.md5.txt','rt')
        virusinside = [l.rstrip() for l in viruslist]
        paths = list()
        virus="detected"
        novirus="clear"
        for dirpath,_,filenames in os.walk(rootdir):
            for f in filenames:
                paths.append(os.path.abspath(os.path.join(dirpath, f)))

        for filename in paths:
            print(filename, self.md5(filename))
            if self.md5(filename) in virusinside:
                print(virus)
                os.remove(filename)
            else:
                print(novirus)

    def getfile(self):
        file2=('C:/Users/User/Desktop/irustesting')
        file3=('C:/Users/User/Desktop/testvirus')
        self.get_all_abs_paths(file2)
        self.get_all_abs_paths(file3)

I am trying to show the terminal output inside the Status bar, is there any solution or suggestion to do that? I had try others method in stackoverflow but didn't work.

Below is my GUI to make it more clear and understanding. enter image description here

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.