I am making a file browser in Python 3.5 and I've included renaming and viewing, but am not sure how to make it so that when you click the file it opens. I know how to use os.startfile("file")
, but I'm not sure where to include it.
try:
from Tkinter import *
except ImportError:
from tkinter import *
from idlelib.TreeWidget import ScrolledCanvas, FileTreeItem, TreeNode
root = Tk()
root.title("Browser")
sc = ScrolledCanvas(root, bg="white", highlightthickness=0, takefocus=1)
sc.frame.pack(expand=1, fill="both", side="left")
loc = input("Please enter your directory: ")
item = FileTreeItem(loc)
node = TreeNode(sc.canvas, None, item)
node.expand()
root.mainloop()