Improved file browser module
This commit is contained in:
parent
72d05bc6df
commit
3d01f149e6
@ -554,7 +554,7 @@ multiple: whether to allow selecting multiple options
|
|||||||
self.selections = default
|
self.selections = default
|
||||||
self.pos = self.selections[0]
|
self.pos = self.selections[0]
|
||||||
self.lastDraw = None
|
self.lastDraw = None
|
||||||
# self.draw()
|
self.draw()
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
title = self.title
|
title = self.title
|
||||||
@ -648,8 +648,8 @@ class fileBrowser(Listbox):
|
|||||||
self.pos = 0
|
self.pos = 0
|
||||||
files = []
|
files = []
|
||||||
folders = []
|
folders = []
|
||||||
folders.append((os.path.abspath(".."), "Back"))
|
|
||||||
os.chdir(self.dir)
|
os.chdir(self.dir)
|
||||||
|
self.back_directory = os.path.abspath("..")
|
||||||
for i in sorted(os.listdir(self.dir)):
|
for i in sorted(os.listdir(self.dir)):
|
||||||
if os.path.isdir(i):
|
if os.path.isdir(i):
|
||||||
folders.append((os.path.abspath(i), i))
|
folders.append((os.path.abspath(i), i))
|
||||||
@ -667,7 +667,7 @@ class fileBrowser(Listbox):
|
|||||||
self.lastDraw = None
|
self.lastDraw = None
|
||||||
|
|
||||||
def collapse(self):
|
def collapse(self):
|
||||||
self.dir = self.items[0][0]
|
self.dir = self.back_directory
|
||||||
self.items = self.make_list()
|
self.items = self.make_list()
|
||||||
self.lastDraw = None
|
self.lastDraw = None
|
||||||
|
|
||||||
@ -697,6 +697,8 @@ class fileBrowser(Listbox):
|
|||||||
elif c in (10, 261, curses.KEY_RIGHT): # newline or right arrow
|
elif c in (10, 261, curses.KEY_RIGHT): # newline or right arrow
|
||||||
if os.path.isfile(self.getDir()) and self.select_type == "file":
|
if os.path.isfile(self.getDir()) and self.select_type == "file":
|
||||||
self.done = 1
|
self.done = 1
|
||||||
|
self.dir = self.getDir()
|
||||||
|
self.setStatus(self.dir)
|
||||||
return 1
|
return 1
|
||||||
if os.path.isdir(self.getDir()) and self.select_type != "file":
|
if os.path.isdir(self.getDir()) and self.select_type != "file":
|
||||||
self.done = 1
|
self.done = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user