Search code examples
pythonuser-interfacetkinterdiskimage

Creating a GUI for loading file tree of a disk image file


I am creating a GUI application which can load a disk image (i.e. output of linux dd command) and list down all its files and directories along with extensions and date created/modified etc.

I have been using tkinter previously to load drives in GUI, however I didn't get success loading disk image files.

Below is code for loading drive

def browseFiles():
file = filedialog.askopenfile(initialdir = "/",
                                      title = "Select a File",
                                      filetypes = (("Text files",
                                                    "*.txt*"),
                                                   ("all files",
                                                    "*.*")))
  
# Change label contents
filepath = os.path.abspath(file.name)
label_file_explorer.configure(text="File Opened: "+filepath)
metadata = subprocess.run(['ls', '-la', 'grep', filepath], capture_output=True, text=True, shell=True)
label_file_metadata.configure(text=metadata)

How can I modify to load disk images?


Solution

  • I have used diskimage library to read disk images and then from the response populate Listbox of tkinter to create a minimal GUI.