Python Forum
[Tkinter] add search bar = search for input in all computer directory
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] add search bar = search for input in all computer directory
#1
Hi, it is possible in tkinter to code the searchbar for a search in all the computer for a given input? Can provide some code?
I know the code for specific file path (example "notepad.exe"), but this case is different.
I'm not asking how to create a searchbar, i know that. I'm asking how do we do a full search in windows for given name in the searchbox. Regards, Francisco

import tkinter  
import time  
from tkinter import ttk
from tkinter import *
import tkinter as tk
import time
import sys
import os
import subprocess
import idlelib
import urllib.request
import ctypes
import functools
from tkinter import PhotoImage
import webbrowser
from tkinter import messagebox
import pymsgbox

###################################
master = Tk()
master.configure(background='blue')
master.minsize(1000,400)
master.geometry("1000x400")
###################################

def downloads(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Downloads/")

def musicas(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Music/")
        
def imagens(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Pictures/")

def videos(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Videos/")

def documentos(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Documents/")

    
progress_var = tkinter.IntVar()
pb = ttk.Progressbar(master, orient="horizontal", length=400, maximum=100, mode="determinate", var=progress_var)

pb.grid(padx=100, pady=300)

#########################################################################################

photo1=PhotoImage(file="downloads.png")
b1 = Button(master,image=photo1, command=downloads, height=200, width=200, compound=LEFT)
b1.place(x = 0, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo2=PhotoImage(file="musica.png")
b2 = Button(master,image=photo2, command=musicas, height=200, width=200, compound=LEFT)
b2.place(x = 200, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo3=PhotoImage(file="imagens.png")
b3 = Button(master,image=photo3, command=imagens, height=200, width=200, compound=LEFT)
b3.place(x = 400, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo4=PhotoImage(file="videos.png")
b4 = Button(master,image=photo4, command=videos, height=200, width=200, compound=LEFT)
b4.place(x = 600, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo5=PhotoImage(file="documentos.png")
b5 = Button(master,image=photo5, command=documentos, height=200, width=200, compound=LEFT)
b5.place(x = 800, y = 0)# x = mexe na horizontal e y = mexe na vertical

####################################    
master.resizable(False, False) 
master.mainloop()
###################################
Reply
#2
If i get this to work the problem will be solved. The only problem, i have to put this file in each folder that i want to do the search, it is possible for him to search all the C:\\, and display the created folder in desktop?
import os 
from pathlib import Path

DIRECTORIES = {
    "HTML": [".html5", ".html", ".htm", ".xhtml"],
    "IMAGENS": [".jpeg", ".jpg", ".tiff", ".gif", ".bmp", ".png", ".bpg", "svg", ".heif", ".psd"],
    "VIDEOS": [".avi", ".flv", ".wmv", ".mov", ".mp4", ".webm", ".vob", ".mng", ".qt", ".mpg", ".mpeg", ".3gp"],
    "DOCUMENTOS": [".oxps", ".epub", ".pages", ".docx", ".doc", ".fdf", ".ods", ".odt", ".pwi", ".xsn", ".xps", ".dotx", ".docm", ".dox", ".rvg", ".rtf", ".rtfd", ".wpd", ".xls", ".xlsx", ".ppt", "pptx", ".pdf",],
    "ARQUIVOS": [".a", ".ar", ".cpio", ".iso", ".tar", ".gz", ".rz", ".7z", ".dmg", ".rar", ".xar", ".zip"],
    "AUDIO": [".aac", ".aa", ".aac", ".dvf", ".m4a", ".m4b", ".m4p", ".mp3", ".msv", "ogg", "oga", ".raw", ".vox", ".wav", ".wma"],
    "FICHEIROS DE TEXTO": [".txt", ".in", ".out"],

}
FILE_FORMATS = {file_format: directory
                for directory, file_formats in DIRECTORIES.items()
                for file_format in file_formats}

def organize_junk():
    for entry in os.scandir():
        if entry.is_dir():
            continue
        file_path = Path(entry)
        file_format = file_path.suffix.lower()
        if file_format in FILE_FORMATS:
            directory_path = Path(FILE_FORMATS[file_format])
            directory_path.mkdir(exist_ok=True)
            file_path.rename(directory_path.joinpath(file_path))

        for dir in os.scandir():
            try:
                os.rmdir(dir)
            except:
                pass

if __name__ == "__main__": 
    organize_junk()
Reply
#3
the following code will search from starting directory to last node.
you can find values for stat here: https://docs.python.org/3/library/stat.html

with this, you can test each entry for file type (directory, regular file, symbolic link, etc,)
and use what you need as they are all presented in the list returned from walk node:

You can insert what you need into your tkinter search algorithm
import os
import stat
from pathlib import Path


class FileWalker:
    '''
    startdir = path relative to current path, example '../data' or
               use absolute path
    '''
    def __init__(self, startdir):
        # Anchor starting directory
        os.chdir(os.path.abspath(os.path.dirname(__file__)))
        fileinfo = self.walk_node(startdir)

        # print first 10 entries.
        for n, entry in enumerate(fileinfo):
            if n > 10:
                break
            print(f'\nabspath: {entry[0]}')
            print(f'stats:   {entry[1]}')
            if stat.S_ISDIR(entry[1][0]):
                print(f'{entry[0].name} is a directory')
            elif stat.S_ISREG(entry[1][0]):
                print(f'{entry[0].name} is a regular file')
            # You can check for all possibilities.

    def find_file(self, filename):
        print(f'Searching for {filename}')
        for entry in self.fileinfo:
            if filename == entry[0].name:
                print(f'file found in {entry[0].resolve()}')

    def walk_node(self, node, display=False):
        p = Path(node)
        fileinfo = []
        for file in p.glob('**/*'):
            fileinfo.append([file.resolve(), file.stat()])
        return fileinfo

if __name__ == '__main__':
    fw = FileWalker('/home/larz60/Documents/TestFileWalker/data')
    print('\n\n')
    fw.find_file('Delaware.html')
sample run from above (first 10 itens in array)
Output:
abspath: /home/larz60/Documents/TestFileWalker/data/control stats: os.stat_result(st_mode=16895, st_ino=71960773, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1550099077, st_ctime=1555110549) control is a directory abspath: /home/larz60/Documents/TestFileWalker/data/www2.census.gov.old stats: os.stat_result(st_mode=16895, st_ino=71960776, st_dev=2049, st_nlink=3, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1551005107, st_ctime=1555110556) www2.census.gov.old is a directory abspath: /home/larz60/Documents/TestFileWalker/data/html_old stats: os.stat_result(st_mode=16895, st_ino=71960656, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110549, st_mtime=1550613985, st_ctime=1555110549) html_old is a directory abspath: /home/larz60/Documents/TestFileWalker/data/json stats: os.stat_result(st_mode=16895, st_ino=71960655, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1549856578, st_ctime=1555110548) json is a directory abspath: /home/larz60/Documents/TestFileWalker/data/tmp stats: os.stat_result(st_mode=16895, st_ino=69209097, st_dev=2049, st_nlink=3, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110541, st_mtime=1551742394, st_ctime=1555110541) tmp is a directory abspath: /home/larz60/Documents/TestFileWalker/data/tmp_old stats: os.stat_result(st_mode=16895, st_ino=71960713, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1550613985, st_ctime=1555110549) tmp_old is a directory abspath: /home/larz60/Documents/TestFileWalker/data/docs stats: os.stat_result(st_mode=16895, st_ino=71959774, st_dev=2049, st_nlink=6, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1551614378, st_ctime=1555110548) docs is a directory abspath: /home/larz60/Documents/TestFileWalker/data/0README_PL.doc stats: os.stat_result(st_mode=33279, st_ino=69209092, st_dev=2049, st_nlink=1, st_uid=1000, st_gid=1000, st_size=98816, st_atime=1555110540, st_mtime=1551005110, st_ctime=1555110540) 0README_PL.doc is a regular file abspath: /home/larz60/Documents/TestFileWalker/data/www2.census.gov stats: os.stat_result(st_mode=16895, st_ino=69209211, st_dev=2049, st_nlink=95, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110542, st_mtime=1551563760, st_ctime=1555110542) www2.census.gov is a directory abspath: /home/larz60/Documents/TestFileWalker/data/html stats: os.stat_result(st_mode=16895, st_ino=69209093, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1551742394, st_ctime=1555110540) html is a directory abspath: /home/larz60/Documents/TestFileWalker/data/ftp stats: os.stat_result(st_mode=16895, st_ino=71959772, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1551573910, st_ctime=1555110542) ftp is a directory Searching for Delaware.html file found in /home/larz60/Documents/TestFileWalker/data/html_old/Delaware.html file found in /home/larz60/Documents/TestFileWalker/data/tmp_old/Delaware.html
when done playing with this code, remove all print statements, and the call to run (in __init__)
fileinfo = self.walk_node(startdir)
and then import the class into your program and use what you want.

** Edited 8:33 PM EDT **
added find_file routine and test for same
Reply
#4
Traceback (most recent call last):
File "C:\Users\Nelson\AppData\Local\Programs\Python\Python37-32\lib\pathlib.py", line 1144, in resolve
s = self._flavour.resolve(self, strict=strict)
File "C:\Users\Nelson\AppData\Local\Programs\Python\Python37-32\lib\pathlib.py", line 201, in resolve
s = self._ext_to_normal(_getfinalpathname(s))
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\hiberfil.sys'
Reply
#5
???
Reply
#6
Hi francisco

PermissionError:!!!

wuf :-)
Reply
#7
(Apr-13-2019, 07:00 AM)wuf Wrote: Hi francisco PermissionError:!!! wuf :-)
Hi Wuf, i got another way for it to work. I converted once the code that searches for the files (png, doc, docx, ...) to exe, i just need to place it in the folders i want and then from the main program a function to call all the exes in those specific folders. Yah, it gives a bit of work, indicating each path to the main program. I just put one of exes in the folder images, another downloads, documents, and so on, i hide the file from the user and then i press a button and it will organize all.

**code that organizes all files**(must be converted to exe once and placed in the folders that you want)
import os
import sys
from pathlib import Path

DIRECTORIES = {
    "HTML": [".html5", ".html", ".htm", ".xhtml"],
    "IMAGENS": [".jpeg", ".jpg", ".tiff", ".gif", ".bmp", ".png", ".bpg", "svg",
               ".heif", ".psd"],
    "VIDEOS": [".avi", ".flv", ".wmv", ".mov", ".mp4", ".webm", ".vob", ".mng",
               ".qt", ".mpg", ".mpeg", ".3gp"],
    "DOCUMENTOS": [".pdf", ".oxps", ".epub", ".pages", ".docx", ".doc", ".fdf", ".ods",
                  ".odt", ".pwi", ".xsn", ".xps", ".dotx", ".docm", ".dox",
                  ".rvg", ".rtf", ".rtfd", ".wpd", ".xls", ".xlsx", ".ppt",
                  "pptx", ".txt", ".in", ".out"],
    "ARQUIVOS": [".a", ".ar", ".cpio", ".iso", ".tar", ".gz", ".rz", ".7z",
                 ".dmg", ".rar", ".xar", ".zip"],
    "AUDIO": [".aac", ".aa", ".aac", ".dvf", ".m4a", ".m4b", ".m4p", ".mp3",
              ".msv", "ogg", "oga", ".raw", ".vox", ".wav", ".wma"],


}
FILE_FORMATS = {file_format: directory
                for directory, file_formats in DIRECTORIES.items()
                for file_format in file_formats}

def organize_junk():
    for entry in os.scandir():
        if entry.is_dir():
            continue
        file_path = Path(entry)
        file_format = file_path.suffix.lower()
        if file_format in FILE_FORMATS:
            directory_path = Path(FILE_FORMATS[file_format])
            directory_path.mkdir(exist_ok=True)
            file_path.rename(directory_path.joinpath(file_path))

        for dir in os.scandir():
            try:
                os.rmdir(dir)
            except:
                pass

if __name__ == "__main__": 
    organize_junk() 
**main code**
import tkinter  
import time  
from tkinter import ttk
from tkinter import *
import tkinter as tk
import time
import sys
import os
import subprocess
import idlelib
import urllib.request
import ctypes
import functools
from tkinter import PhotoImage
import webbrowser
from tkinter import messagebox
import pymsgbox

###################################
master = Tk()
master.configure(background = 'pink')
master_height = 400
master_width = 1000
screen_width = master.winfo_screenwidth()
screen_height = master.winfo_screenheight()
x_cordinate = int((screen_width/2) - (master_width/2))
y_cordinate = int((screen_height/2) - (master_height/2))
master.geometry("{}x{}+{}+{}".format(master_width, master_height, x_cordinate, y_cordinate))
###################################
time1 = ''
clock = Label(master, font=('times', 20, 'bold'))
clock.place(x=260, y=260)

def tick():
    global time1
    time2 = time.strftime('%H:%M:%S')
    if time2 != time1:
        time1 = time2
        clock.config(text=time2)
    clock.after(200, tick)
    
def downloads(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Downloads/")

def musicas(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Music/")
        
def imagens(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Pictures/")

def videos(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Videos/")

def documentos(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        os.startfile("C:/Users/Nelson/Documents/")

def organizador(): 
    for x in range(1, 110):
            progress_var.set(x)
            time.sleep(0.10)
            master.update()
            progress_var.set(0)

    if True:
        path = "C:/Users/Nelson/Desktop/Folder 1"
        os.chdir(path)
        os.system("organizer.exe")

        path = "C:/Users/Nelson/Desktop/Folder 2"
        os.chdir(path)
        os.system("organizer.exe")

        path = "C:/Users/Nelson/Desktop/Folder 3"
        os.chdir(path)
        os.system("organizer.exe")

        path = "C:/Users/Nelson/Desktop/Folder 4"
        os.chdir(path)
        os.system("organizer.exe")

    
progress_var = tkinter.IntVar()
pb = ttk.Progressbar(master, orient="horizontal", length=400, maximum=100, mode="determinate", var=progress_var)

pb.grid(padx=100, pady=300)

#########################################################################################

photo1=PhotoImage(file="downloads.png")
b1 = Button(master,image=photo1, command=downloads, height=200, width=200, bg='blue', compound=LEFT)
b1.place(x = 0, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo2=PhotoImage(file="musica.png")
b2 = Button(master,image=photo2, command=musicas, height=200, width=200, bg='green', compound=LEFT)
b2.place(x = 200, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo3=PhotoImage(file="imagens.png")
b3 = Button(master,image=photo3, command=imagens, height=200, width=200, bg='yellow', compound=LEFT)
b3.place(x = 400, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo4=PhotoImage(file="videos.png")
b4 = Button(master,image=photo4, command=videos, height=200, width=200, bg='purple', compound=LEFT)
b4.place(x = 600, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo5=PhotoImage(file="documentos.png")
b5 = Button(master,image=photo5, command=documentos, height=200, width=200, bg='orange', compound=LEFT)
b5.place(x = 800, y = 0)# x = mexe na horizontal e y = mexe na vertical

photo6=PhotoImage(file="sos.png")
b6 = Button(master,image=photo6, command=organizador, height=200, width=200, bg='wheat1', compound=LEFT)
b6.place(x = 800, y = 200)# x = mexe na horizontal e y = mexe na vertical
####################################
tick()
master.resizable(False, False) 
master.mainloop()
###################################
This program works like a charm, i have a lady that as almost 50000 photos, 20000 videos and so on,imagine how difficult is to organize all that, just put the file in the folders and the program will do that for me.
Reply
#8
(Apr-13-2019, 12:37 AM)Larz60+ Wrote: the following code will search from starting directory to last node.
you can find values for stat here: https://docs.python.org/3/library/stat.html

with this, you can test each entry for file type (directory, regular file, symbolic link, etc,)
and use what you need as they are all presented in the list returned from walk node:

You can insert what you need into your tkinter search algorithm
import os
import stat
from pathlib import Path


class FileWalker:
    '''
    startdir = path relative to current path, example '../data' or
               use absolute path
    '''
    def __init__(self, startdir):
        # Anchor starting directory
        os.chdir(os.path.abspath(os.path.dirname(__file__)))
        fileinfo = self.walk_node(startdir)

        # print first 10 entries.
        for n, entry in enumerate(fileinfo):
            if n > 10:
                break
            print(f'\nabspath: {entry[0]}')
            print(f'stats:   {entry[1]}')
            if stat.S_ISDIR(entry[1][0]):
                print(f'{entry[0].name} is a directory')
            elif stat.S_ISREG(entry[1][0]):
                print(f'{entry[0].name} is a regular file')
            # You can check for all possibilities.

    def find_file(self, filename):
        print(f'Searching for {filename}')
        for entry in self.fileinfo:
            if filename == entry[0].name:
                print(f'file found in {entry[0].resolve()}')

    def walk_node(self, node, display=False):
        p = Path(node)
        fileinfo = []
        for file in p.glob('**/*'):
            fileinfo.append([file.resolve(), file.stat()])
        return fileinfo

if __name__ == '__main__':
    fw = FileWalker('/home/larz60/Documents/TestFileWalker/data')
    print('\n\n')
    fw.find_file('Delaware.html')
sample run from above (first 10 itens in array)
Output:
abspath: /home/larz60/Documents/TestFileWalker/data/control stats: os.stat_result(st_mode=16895, st_ino=71960773, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1550099077, st_ctime=1555110549) control is a directory abspath: /home/larz60/Documents/TestFileWalker/data/www2.census.gov.old stats: os.stat_result(st_mode=16895, st_ino=71960776, st_dev=2049, st_nlink=3, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1551005107, st_ctime=1555110556) www2.census.gov.old is a directory abspath: /home/larz60/Documents/TestFileWalker/data/html_old stats: os.stat_result(st_mode=16895, st_ino=71960656, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110549, st_mtime=1550613985, st_ctime=1555110549) html_old is a directory abspath: /home/larz60/Documents/TestFileWalker/data/json stats: os.stat_result(st_mode=16895, st_ino=71960655, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1549856578, st_ctime=1555110548) json is a directory abspath: /home/larz60/Documents/TestFileWalker/data/tmp stats: os.stat_result(st_mode=16895, st_ino=69209097, st_dev=2049, st_nlink=3, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110541, st_mtime=1551742394, st_ctime=1555110541) tmp is a directory abspath: /home/larz60/Documents/TestFileWalker/data/tmp_old stats: os.stat_result(st_mode=16895, st_ino=71960713, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1550613985, st_ctime=1555110549) tmp_old is a directory abspath: /home/larz60/Documents/TestFileWalker/data/docs stats: os.stat_result(st_mode=16895, st_ino=71959774, st_dev=2049, st_nlink=6, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1551614378, st_ctime=1555110548) docs is a directory abspath: /home/larz60/Documents/TestFileWalker/data/0README_PL.doc stats: os.stat_result(st_mode=33279, st_ino=69209092, st_dev=2049, st_nlink=1, st_uid=1000, st_gid=1000, st_size=98816, st_atime=1555110540, st_mtime=1551005110, st_ctime=1555110540) 0README_PL.doc is a regular file abspath: /home/larz60/Documents/TestFileWalker/data/www2.census.gov stats: os.stat_result(st_mode=16895, st_ino=69209211, st_dev=2049, st_nlink=95, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110542, st_mtime=1551563760, st_ctime=1555110542) www2.census.gov is a directory abspath: /home/larz60/Documents/TestFileWalker/data/html stats: os.stat_result(st_mode=16895, st_ino=69209093, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1551742394, st_ctime=1555110540) html is a directory abspath: /home/larz60/Documents/TestFileWalker/data/ftp stats: os.stat_result(st_mode=16895, st_ino=71959772, st_dev=2049, st_nlink=2, st_uid=1000, st_gid=1000, st_size=4096, st_atime=1555110604, st_mtime=1551573910, st_ctime=1555110542) ftp is a directory Searching for Delaware.html file found in /home/larz60/Documents/TestFileWalker/data/html_old/Delaware.html file found in /home/larz60/Documents/TestFileWalker/data/tmp_old/Delaware.html
when done playing with this code, remove all print statements, and the call to run (in __init__)
fileinfo = self.walk_node(startdir)
and then import the class into your program and use what you want.

** Edited 8:33 PM EDT **
added find_file routine and test for same
Thanks for your tip, since your code gives me error. The person with lots of files, should put them in folders, that's why i created different code to do that. Then it's more easy for her to search for the any intended file
Reply
#9
I don't understand why you get an error.
It's thoroughly tested. where did you put the code, and how did you run it?

I also looked at your error message, and looks as though you have some permission issues.

If you correct those, you should have no problem running.
Also, which directory did you try and start in?
on windows, Microsoft will not allow access to some directories, and that could be a (fixable) issue.
I can alter the code to skip these directories.

Finally, what did you name the module? It cannot be the same name as any python commands.
When run, it's amazingly fast, I have 8 TB of internal disk space, and it finished fast.
Reply
#10
(Apr-13-2019, 03:37 PM)Larz60+ Wrote: I don't understand why you get an error. It's thoroughly tested. where did you put the code, and how did you run it? I also looked at your error message, and looks as though you have some permission issues. If you correct those, you should have no problem running. Also, which directory did you try and start in? on windows, Microsoft will not allow access to some directories, and that could be a (fixable) issue. I can alter the code to skip these directories. Finally, what did you name the module? It cannot be the same name as any python commands. When run, it's amazingly fast, I have 8 TB of internal disk space, and it finished fast.

I deleted all prints and changed
if __name__ == '__main__':
    fw = FileWalker('/home/larz60/Documents/TestFileWalker/data')
to
if __name__ == '__main__':
    fw = FileWalker('C:/')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Search data in treeview without search button TomasSanchexx 3 1,526 Aug-12-2023, 03:17 AM
Last Post: deanhystad
  search is not finding documentation i want Skaperen 1 866 Aug-26-2022, 08:17 AM
Last Post: Gribouillis
  [PyQt] [Solved]Display Search Results in QTable Extra 5 2,386 Jun-29-2022, 10:20 PM
Last Post: Extra
  [Tkinter] Text.search() regexp not working rfresh737 11 4,911 Apr-16-2021, 06:56 PM
Last Post: rfresh737
  Listbox search code partially works chesschaser 9 3,761 May-05-2020, 01:08 PM
Last Post: chesschaser
  tkinter search box DT2000 3 7,612 Apr-08-2020, 05:59 AM
Last Post: DT2000
  [Tkinter] GUI help for search engine carzymind 0 2,629 Sep-27-2019, 10:49 AM
Last Post: carzymind
  [Tkinter] Problem with tkinter search widget poopcupine 1 2,641 Mar-25-2019, 08:24 AM
Last Post: Larz60+
  Python, Tkinter. How to search a specific file in a folder Roo 3 3,386 Feb-13-2019, 10:41 AM
Last Post: Larz60+
  [WxPython] Search window position in Trelby blackclover 20 8,889 May-07-2018, 05:08 AM
Last Post: blackclover

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020