moving back to python2, so the xattr library works; dirWidget2 converted
This commit is contained in:
+7
-11
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/python
|
||||
''' a widget that shows only a dir listing
|
||||
'''
|
||||
|
||||
import sys,os,argparse
|
||||
from tkinter import *
|
||||
from Tkinter import *
|
||||
|
||||
class DirWidget(Listbox):
|
||||
''' a simple widget that shows a list of directories, staring
|
||||
@@ -17,11 +17,11 @@ class DirWidget(Listbox):
|
||||
the most interesting parts of the interface are:
|
||||
constructor - send in the directory to view
|
||||
method - currentPath() returns text of current path
|
||||
signal - selected calls a slot with a single arg: new path
|
||||
new event <<DirChanged>>
|
||||
'''
|
||||
|
||||
def __init__(self, parent, directory='.'):
|
||||
super(DirWidget,self).__init__(parent)
|
||||
Listbox.__init__(self,parent)
|
||||
self.directory = directory
|
||||
self.refill()
|
||||
self.bind("<Key>",self.quickFind)
|
||||
@@ -34,16 +34,14 @@ class DirWidget(Listbox):
|
||||
self.refill()
|
||||
self.event_generate("<<DirChanged>>")
|
||||
def refill(self):
|
||||
current,dirs,files = os.walk(self.directory,followlinks=True).__next__()
|
||||
current,dirs,files = os.walk(self.directory,followlinks=True).next()
|
||||
dirs = sorted(dirs, key=lambda s: s.lower())
|
||||
if '/' not in dirs:
|
||||
dirs = ['..'] + dirs
|
||||
self.delete(0,END)
|
||||
for d in dirs:
|
||||
#li = QListWidgetItem(d,self)
|
||||
# replace this with an insert
|
||||
self.insert(END,d)
|
||||
self.selection_set(0)
|
||||
#self.selection_set(0)
|
||||
def currentPath(self):
|
||||
return self.directory
|
||||
def quickFind(self,event):
|
||||
@@ -52,9 +50,7 @@ class DirWidget(Listbox):
|
||||
event.char = event.char.lower()
|
||||
if event.char not in 'abcdefghijklmnopqrstuvwxyz0123456789_-.%':
|
||||
return
|
||||
print("quickFind: "+event.char+" ")
|
||||
for i in range(self.size()):
|
||||
print("qf get: " + self.get(i))
|
||||
if self.get(i)[0].lower()==event.char:
|
||||
self.activate(i)
|
||||
self.see(i)
|
||||
@@ -62,7 +58,7 @@ class DirWidget(Listbox):
|
||||
|
||||
if __name__=="__main__":
|
||||
def alert(some_event):
|
||||
print("dirWidget hit" + str(some_event))
|
||||
print("dirWidget hit dir: " + some_event.widget.currentPath())
|
||||
os.system('notify-send -t 1500 "file: ' +
|
||||
some_event.widget.currentPath() + '"')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user