|  | @@ -1,4 +1,4 @@
 | 
	
		
			
				|  |  | -#!/usr/bin/python3
 | 
	
		
			
				|  |  | +#!/usr/bin/python
 | 
	
		
			
				|  |  |  """ a simple gui or command line app
 | 
	
		
			
				|  |  |  to view and create/edit file comments
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -15,7 +15,8 @@ these comments stick to the symlink
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import sys,os,argparse
 | 
	
		
			
				|  |  |  from dirWidget2 import DirWidget
 | 
	
		
			
				|  |  | -from tkinter import *
 | 
	
		
			
				|  |  | +from Tkinter import *
 | 
	
		
			
				|  |  | +from ttk import *
 | 
	
		
			
				|  |  |  import xattr, sqlite3, time
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  VERSION = "0.2"
 | 
	
	
		
			
				|  | @@ -94,6 +95,11 @@ class FileObj():
 | 
	
		
			
				|  |  |  			pass
 | 
	
		
			
				|  |  |  	def getName(self):
 | 
	
		
			
				|  |  |  		return self.fileName
 | 
	
		
			
				|  |  | +	def getShortName(self):
 | 
	
		
			
				|  |  | +		if self.fileName[-1]=='/':	#do show dirs, they can have comments
 | 
	
		
			
				|  |  | +			return os.path.basename(self.fileName[:-1])+'/'
 | 
	
		
			
				|  |  | +		else:
 | 
	
		
			
				|  |  | +			return os.path.basename(self.fileName)
 | 
	
		
			
				|  |  |  	def getComment(self):
 | 
	
		
			
				|  |  |  		return self.comment
 | 
	
		
			
				|  |  |  	def setComment(self,newComment):
 | 
	
	
		
			
				|  | @@ -117,19 +123,14 @@ class DirNotes(Frame):
 | 
	
		
			
				|  |  |  		has 3 list boxes: dir_left, dir_right (may be invisible) and files
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		'''
 | 
	
		
			
				|  |  | -	def __init__(self, filename, db, parent=None):
 | 
	
		
			
				|  |  | -		super(DirNotes,self).__init__(parent)
 | 
	
		
			
				|  |  | +	def __init__(self, parent, filename, db):
 | 
	
		
			
				|  |  | +		Frame.__init__(self,parent)
 | 
	
		
			
				|  |  |  		self.db = db
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		win = QWidget()
 | 
	
		
			
				|  |  | -		self.setCentralWidget(win)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		lb = QTableWidget()
 | 
	
		
			
				|  |  | -		self.lb = lb
 | 
	
		
			
				|  |  | -		lb.setColumnCount(2)
 | 
	
		
			
				|  |  | -		lb.horizontalHeader().setResizeMode( 1, QHeaderView.Stretch );
 | 
	
		
			
				|  |  | -		lb.verticalHeader().setDefaultSectionSize(20);	# thinner rows
 | 
	
		
			
				|  |  | -		lb.verticalHeader().setVisible(False)
 | 
	
		
			
				|  |  | +		self.lb = lb = Treeview(self)
 | 
	
		
			
				|  |  | +		lb['columns'] = ('comment')
 | 
	
		
			
				|  |  | +		lb.heading('#0',text='Name')
 | 
	
		
			
				|  |  | +		lb.heading('comment',text='Comment')
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		# resize the comments column
 | 
	
		
			
				|  |  |  		# and resize the parent window to match the directory size
 | 
	
	
		
			
				|  | @@ -143,49 +144,50 @@ class DirNotes(Frame):
 | 
	
		
			
				|  |  |  		files.sort()
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		d = dirs + files
 | 
	
		
			
				|  |  | -		lb.setRowCount(len(d))
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		self.files = []
 | 
	
		
			
				|  |  |  		for i in range(len(d)):
 | 
	
		
			
				|  |  |  			this_file = FileObj(current+'/'+d[i])
 | 
	
		
			
				|  |  |  			self.files = self.files + [this_file]
 | 
	
		
			
				|  |  | -			item = QTableWidgetItem(this_file.getName())
 | 
	
		
			
				|  |  | -			item.setFlags(QtCore.Qt.ItemIsEnabled)
 | 
	
		
			
				|  |  | -			lb.setItem(i,0,item)
 | 
	
		
			
				|  |  | +			lb.insert('','end',iid=str(i),text=this_file.getShortName(),)
 | 
	
		
			
				|  |  |  			#lb.itemAt(i,0).setFlags(Qt.ItemIsEnabled) #NoItemFlags)
 | 
	
		
			
				|  |  |  			comment = this_file.getComment()
 | 
	
		
			
				|  |  | -			lb.setItem(i,1,QTableWidgetItem(comment))
 | 
	
		
			
				|  |  | -		lb.setHorizontalHeaderItem(0,QTableWidgetItem("file"))
 | 
	
		
			
				|  |  | -		lb.setHorizontalHeaderItem(1,QTableWidgetItem("comment"))
 | 
	
		
			
				|  |  | -		lb.resizeColumnsToContents()
 | 
	
		
			
				|  |  | +			lb.set(item=str(i),column='comment',value=comment)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		e = QLabel("View and edit file comments stored in extended attributes user.xdg.comment",win)
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		e2 = Label(self,text="View and edit file comments stored in extended attributes user.xdg.comment")
 | 
	
		
			
				|  |  | +		e1 = Label(self,text="Active Directory:")
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		b1 = QPushButton("restore from database",win)
 | 
	
		
			
				|  |  | -		dirLeft = DirWidget(current,win)
 | 
	
		
			
				|  |  | -		dirLeft.setMaximumHeight(140)
 | 
	
		
			
				|  |  | -		dirLeft.setMaximumWidth(200)
 | 
	
		
			
				|  |  | -		dirRight = DirWidget(current,win)
 | 
	
		
			
				|  |  | -		dirRight.setMaximumHeight(140)
 | 
	
		
			
				|  |  | -		dirRight.setMaximumWidth(200)
 | 
	
		
			
				|  |  | -		dirRight.setEnabled(False)
 | 
	
		
			
				|  |  | +		b1 = Button(self,text="restore from database")
 | 
	
		
			
				|  |  | +		dirLeft = DirWidget(self,current)
 | 
	
		
			
				|  |  | +		#dirLeft.setMaximumHeight(140)
 | 
	
		
			
				|  |  | +		#dirLeft.setMaximumWidth(200)
 | 
	
		
			
				|  |  | +		dirRight = DirWidget(self,current)
 | 
	
		
			
				|  |  | +		#~ dirRight.setMaximumHeight(140)
 | 
	
		
			
				|  |  | +		#~ dirRight.setMaximumWidth(200)
 | 
	
		
			
				|  |  | +		#~ dirRight.setEnabled(False)
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		layout = QVBoxLayout()
 | 
	
		
			
				|  |  | -		upperLayout = QHBoxLayout()
 | 
	
		
			
				|  |  | -		layout.addWidget(e)
 | 
	
		
			
				|  |  | -		upperLayout.addWidget(dirLeft)
 | 
	
		
			
				|  |  | -		upperLayout.addWidget(b1)
 | 
	
		
			
				|  |  | -		upperLayout.addWidget(dirRight)
 | 
	
		
			
				|  |  | -		layout.addLayout(upperLayout)
 | 
	
		
			
				|  |  | -		layout.addWidget(lb)
 | 
	
		
			
				|  |  | -		win.setLayout(layout)
 | 
	
		
			
				|  |  | +		#~ layout = QVBoxLayout()
 | 
	
		
			
				|  |  | +		#~ upperLayout = QHBoxLayout()
 | 
	
		
			
				|  |  | +		#~ layout.addWidget(e)
 | 
	
		
			
				|  |  | +		#~ upperLayout.addWidget(dirLeft)
 | 
	
		
			
				|  |  | +		#~ upperLayout.addWidget(b1)
 | 
	
		
			
				|  |  | +		#~ upperLayout.addWidget(dirRight)
 | 
	
		
			
				|  |  | +		#~ layout.addLayout(upperLayout)
 | 
	
		
			
				|  |  | +		#~ layout.addWidget(lb)
 | 
	
		
			
				|  |  | +		#~ win.setLayout(layout)
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		lb.itemChanged.connect(self.change)
 | 
	
		
			
				|  |  | -		b1.pressed.connect(self.restore_from_database)
 | 
	
		
			
				|  |  | +		#~ lb.itemChanged.connect(self.change)
 | 
	
		
			
				|  |  | +		#~ b1.pressed.connect(self.restore_from_database)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		QShortcut(QKeySequence("Ctrl+Q"), self, self.close)	
 | 
	
		
			
				|  |  | -		self.setWindowTitle("test")
 | 
	
		
			
				|  |  | -		self.setMinimumSize(600,400)
 | 
	
		
			
				|  |  | +		#~ QShortcut(QKeySequence("Ctrl+Q"), self, self.close)	
 | 
	
		
			
				|  |  | +		#~ self.setWindowTitle("test")
 | 
	
		
			
				|  |  | +		#~ self.setMinimumSize(600,400)
 | 
	
		
			
				|  |  | +		e1.pack(anchor=W,padx=20)
 | 
	
		
			
				|  |  | +		dirLeft.pack(anchor=W,padx=20,pady=5)
 | 
	
		
			
				|  |  | +		e2.pack()
 | 
	
		
			
				|  |  | +		lb.pack()
 | 
	
		
			
				|  |  |  	def closeEvent(self,e):
 | 
	
		
			
				|  |  |  		print("closing")
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -212,6 +214,7 @@ if __name__=="__main__":
 | 
	
		
			
				|  |  |  	db = DataBase()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	tk_basis = Tk()
 | 
	
		
			
				|  |  | +	tk_basis.title("DirNotes "+p.dirname)
 | 
	
		
			
				|  |  |  	dn = DirNotes(tk_basis,p.dirname,db)
 | 
	
		
			
				|  |  |  	dn.pack()
 | 
	
		
			
				|  |  |  	
 | 
	
	
		
			
				|  | @@ -263,4 +266,8 @@ user.xdg.publisher
 | 
	
		
			
				|  |  |  			-choose & cancel buttons
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	'''
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +'''
 | 
	
		
			
				|  |  | +http://stackoverflow.com/questions/18562123/how-to-make-ttk-treeviews-rows-editable
 | 
	
		
			
				|  |  | +'''
 | 
	
		
			
				|  |  |  
 |