Step-by-Step Guide: Python GUI File Manager Using Tkinter and Shutil | codingdidi

In this tutorial, Akansha Yadav walks viewers through building a Windows‑focused file manager GUI with Python. She explains the three core libraries used—os for operating‑system interactions, tkinter for the graphical interface, and shutil (referred to as the "shuttle" library) for file operations such as copy and move. The video details the creation of backend functions for opening, copying, deleting, and renaming files, as well as opening, deleting, and moving folders. It then shows how to assemble the GUI: initializing the root window, configuring titles, geometry, colors, fonts, and adding labels, buttons, and a Listbox with a vertical scrollbar to display directory contents. Throughout, Akansha demonstrates exception handling with try/except blocks, uses tkinter dialogs and message boxes for user input and feedback, and finalizes the application with root.update and the main event loop. The tutorial emphasizes practical Python basics, module usage, and encourages viewers to experiment, comment, and request further projects.
Chapters
Ladies and gentlemen, hello everyone, welcome back to my YouTube channel. In today's video, I will tell you about one program which can help you showcase your Python basics knowledge and your modules knowledge. So there are two main concepts that has been used in this project. First is the library of Python, which is os library and tkinter library. os library means operating system library, and the tkinter library is for creating GUI applications or graphical user interface for your project, whether it is you are taking input or you are want— you wanted to display anything. So anything related GUI, you can use this tkinter library for that. So to do that, there is one more library which is being used in this, which is called shuttle library. And in this shuttle library, you are going to use it to make a copy of the files and all. So this entire project is known as the file manager. So file manager or file explorer, you can call it. So you might have seen on Windows or on Mac as well, we have one file explorer where we have the documents, downloads, all those files are there. So same thing I'm going to do, and this is specifically for the users who are using Windows, and this will work on Windows itself because we are using OS, we are not using specifically anything for Mac. So if you are a Windows user, then you can implement this or you can try this. This is the working project which will give you one interface where you will have multiple buttons. You have to select the button what exactly you wanted to do with the files or folders. So very first thing is you have to import the library. So these are the libraries that you need to install or import in your node. First is you have to go and create your Python project. Once you have created .py file or .ipynv file, you have to write this command to import all these files, all these modules. Next is that we have to create backend function. So first function is called open file function. To open a file function, this is the code that you need to write. You have to ask the— you have to ask the tkinter to ask for update for opening any file, any file name, and then you are going to start a file. Second will be your copy file function. In copy file function, you have to use the try and except block, and try and except block will help you avoid errors. This is a part of exception handling, and this project, as I said, is going to showcase your skills. So you have to do the copy file part as well. And third button is going to be the delete file. To deleting for deleting the file, you also have to instruct your tkinter library to look for that file that user wants to delete and then select that file and then remove it from the operating system and then print it whether it is deleted or not. So this is the piece of code that you need to add. Number 4 is renaming a file. In case of renaming a file, we need 2 things. First thing is you have to search for the file that you wanted to rename. Second thing, there should be one more pop-up come— coming up on our window to write down the new name that we wanted to instruct it. So for that, you have to use tkinter. In this case, you have to open a message box in this case, and you have to set the title for that, you have to set the geometry for that, and you have to add a label as well. And once you are done with everything, you will instruct your OS library to rename it. And then show info, which is from the tkinter, you have to instruct your message dialog box to pop up and show the info that the file has been renamed. So these are the steps, and this is the piece of code that you need to add in that. Another is to open a folder. Open— opening a folder is very simple because we already have os library and tkinter library. So using tkinter library, you are going to ask to search for the file name that the user is looking for, and then you have to instruct your OS to open or start that folder. Another is to delete a folder. To delete a folder, you to instruct your tkinter library to ask for the directory that you wanted to delete. You have to select the folder, user has to select the folder, and then rmdir, which is going to folder to folder. And then you will instruct, which means you will show the information that the folder has been deleted. Another part is to move folder. To move the folder, you have to instruct it to ask that directly, that you have to select the folder, that which folder you wanted to, you know, move. And then you will show that you have just selected the folder to move. Now please select the desired destination. Once the user will select the desired destination, you have to use— we are using try and except block again. To avoid errors and the exception handling. And in this case, you have to write down .move function from the shuttle library to move one file to another file. Above also, when we were trying to read— when we were trying to work on the copy file also, we were using the shuttle library. Same way in there, in this case also, you have to use the shuttle library to move the folder from one file— one place to another place. Another one is to list all folders and all files in the folder. To do that, what you need is first is you need the folder location. Second thing is you need all the list of the files that are available inside that folder. So for that, I am using os library to get the files from that particular folder. But to get the folder, I am using the tkinter library. Then you have to do— then you have to create certain interface so that it will list all those file names for you in the separate window which is being created by you. For that, you have to use top level brackets root, which is going to be your main window. And under that main window, there should be one more window which will be titled with this— what should be the geometry, what should be the resizing. Everything you can modify as per your, your requirement. And then you have to use the— use the object which is called list box. And in that list box. You can set the background color, what should be the font, what should be the height and width, and so on. You can write it down. And if you want it to be a scrollbar, because maybe you have multiple files that cannot be viewed in the one, uh, interface, then in that case you can add a scrollbar as well, just like I have added. I have added a vertical one. I don't want a horizontal one, so I have added a vertical one. And I have also added the Y view parameter in this, and then I have packed it to the right side of my screen., and then I am configuring it, and then I am taking all the files from that particular variable and appending it, or inserting it, you can say, in the list box. Once you have done that, what you have to do is you have created all the backend function. Now you are ready with the functions. Now you need each and every button to initialize everything. So for that, what I have done is I have written a title, I have written background color— you have to set it basically so that in the GUI you are going to have an interactive way to visualize everything. And then we have the font size— you have to specify what should be the font and what should be the size. Then what should be the background button color, and then initializing a window. Every time we use root because that is like considered as a very good way to initialize it, which will avoid any error for you. Another is to give the title. We have already specified a title. Geometry, you can specify resizable. Yes, you wanted to make it resizable, then you will make it 0, 0 so that user can resize it as per user's convenience. And then third is— then the next is the configure. So you have to configure the background color also. So root.config will help you to do that. Then you have to create multiple buttons and labels. So first should the label. In the label, I wanted to print the title which is being given over here, just like I have written Add the Date Coding DD File Manager. In this case, it will print that particular label in the font Comic Sans MS, then size will be 15, background color already provided, wrap length 250. And wherever you wanted to place it, you will use .place function to place it using x and y parameter. Same way, then you will create multiple buttons like for opening a file, copying a file, for renaming, for deleting, for opening, for deleting, for moving, and for listing the files. And then you Finalize the window with root.update, and then you will make it in the main loop so that it will work for you in the app. So this was the entire code for writing this program. Once you are done with that, don't forget to comment down so that you can— like, I will guide you further for more projects, that what are the different projects that you can create to showcase your skills. So if this video helped you a lot, so don't forget to like this video and comment down your views if you want more complex or more easy project than this. Then I'm here to assist you with all those things. So bye-bye, we'll meet in the next video.










