Ejemplo n.º 1
0
	def excecute(self, *args):
		if self.new_name_entry.get() !='' and FileModule.checker(self.new_name_entry.get()):
			try:
				os.chdir(os.path.split(self.file)[0])
				if os.path.isdir(self.file):
					os.rename(os.path.split(self.file)[1], self.new_name_entry.get())
				elif os.path.isfile(self.file):
					try:
						if FileModule.get_file_extension(self.file) == FileModule.get_file_extension(self.new_name_entry.get()):
							os.rename(os.path.split(self.file)[1], self.new_name_entry.get())
						elif FileModule.get_file_extension(self.new_name_entry.get()) == '':
							os.rename(os.path.split(self.file)[1], self.new_name_entry.get()+'.'+FileModule.get_file_extension(self.file))
						else:
							req = tkinter.messagebox.askokcancel(self.params1[2],self.params1[3])
							if req:
								os.rename(os.path.split(self.file)[1], self.new_name_entry.get())
					except PermissionError:
						tkinter.messagebox.showerror(self.params2[0], self.params2[1])
				else:
					pass
				self.close()
			except FileExistsError:
				tkinter.messagebox.showerror(self.params2[2], self.params2[3])
Ejemplo n.º 2
0
 def load_file_info(self, prest):
     """
         Load file in
     """
     try:
         elmt = os.path.join(self.addressBar_entry.get(), self.resultDisplay_frame.get((self.resultDisplay_frame.curselection())))
         selectItem = self.resultDisplay_frame.get((self.resultDisplay_frame.curselection()))
         ext = FileModule.get_file_extension(selectItem).lower()
         if os.path.isdir(elmt):
             self.description_icon_label.config(image=self.folder)
             self.description_type_label.config(text=FILE_NAME[32])
             self.description_size_label.config(text='')
             self.description_date_label.config(text='')
         else:
             if ext=='pdf':
                 self.description_icon_label.config(image=self.pdf_file)
                 self.description_type_label.config(text=FILE_NAME[2])
             elif ext=='mp4' or ext=='avi' or ext=='mkv' or ext=='3gp'or ext=='webm':
                 self.description_icon_label.config(image=self.video_file)
                 self.description_type_label.config(text=FILE_NAME[3]) 
             elif ext=='zip' or ext=='rar'or ext=='tar'or ext=='gz':
                 self.description_icon_label.config(image=self.archive_folder)
                 self.description_type_label.config(text=FILE_NAME[4])
             elif ext=='mp3' or ext=='wav' or ext=='wma' or ext=='ogg' or ext=='m4a':
                 self.description_icon_label.config(image=self.music_file)
                 self.description_type_label.config(text=FILE_NAME[5])
             elif ext=='jpg' or ext=='jpeg' or ext=='png' or ext=='gif':
                 self.description_icon_label.config(image=self.picture)
                 self.description_type_label.config(text=FILE_NAME[6])
             elif ext=='lnk':
                 self.description_icon_label.config(image=self.link)
                 self.description_type_label.config(text=FILE_NAME[7])
             elif ext=='py' or ext=='pyc':
                 self.description_icon_label.config(image=self.python)
                 self.description_type_label.config(text=FILE_NAME[8])
             elif ext=='php':
                 self.description_icon_label.config(image=self.php)
                 self.description_type_label.config(text=FILE_NAME[9])
             elif ext=='pptm' or ext=='ppt':
                 self.description_icon_label.config(image=self.powerpoint)
                 self.description_type_label.config(text=FILE_NAME[10])
             elif ext=='html':
                 self.description_icon_label.config(image=self.html)
                 self.description_type_label.config(text=FILE_NAME[11])
             elif ext=='java' or ext=='jar' or ext=='class':
                 self.description_icon_label.config(image=self.java)
                 self.description_type_label.config(text=FILE_NAME[12])
             elif ext=='exe':
                 self.description_icon_label.config(image=self.exe)
                 self.description_type_label.config(text=FILE_NAME[13])
             elif ext=='xlsx' or ext=='csv':
                 self.description_icon_label.config(image=self.excel)
                 self.description_type_label.config(text=FILE_NAME[14])
             elif ext=='css':
                 self.description_icon_label.config(image=self.css)
                 self.description_type_label.config(text=FILE_NAME[15])
             elif ext=='cpp':
                 self.description_icon_label.config(image=self.cpp)
                 self.description_type_label.config(text=FILE_NAME[16])
             elif ext=='c':
                 self.description_icon_label.config(image=self.c)
                 self.description_type_label.config(text=FILE_NAME[17])
             elif ext=='doc' or ext=="docx" or ext=="odt":
                 self.description_icon_label.config(image=self.word)
                 self.description_type_label.config(text=FILE_NAME[18])
             elif ext=='txt':
                 self.description_icon_label.config(image=self.text)
                 self.description_type_label.config(text=FILE_NAME[19])
             elif ext=='crt':
                 self.description_icon_label.config(image=self.crt)
                 self.description_type_label.config(text=FILE_NAME[20])
             elif ext=='iso':
                 self.description_icon_label.config(image=self.disk_image)
                 self.description_type_label.config(text=FILE_NAME[21])
             elif ext=='dll':
                 self.description_icon_label.config(image=self.dll)
                 self.description_type_label.config(text=FILE_NAME[22])
             elif ext=='h':
                 self.description_icon_label.config(image=self.header)
                 self.description_type_label.config(text=FILE_NAME[23])
             elif ext=='htm':
                 self.description_icon_label.config(image=self.htm)
                 self.description_type_label.config(text=FILE_NAME[24])
             elif ext=='log':
                 self.description_icon_label.config(image=self.log)
                 self.description_type_label.config(text=FILE_NAME[25])
             elif ext=='perl':
                 self.description_icon_label.config(image=self.perl)
                 self.description_type_label.config(text=FILE_NAME[26])
             elif ext=='rpm':
                 self.description_icon_label.config(image=self.rpm)
                 self.description_type_label.config(text=FILE_NAME[27])
             elif ext=='rtf':
                 self.description_icon_label.config(image=self.rtf)
                 self.description_type_label.config(text=FILE_NAME[28])
             elif ext=='sql':
                 self.description_icon_label.config(image=self.sql)
                 self.description_type_label.config(text=FILE_NAME[29])
             elif ext=='xml':
                 self.description_icon_label.config(image=self.xml)
                 self.description_type_label.config(text=FILE_NAME[30])
             elif ext=='deb':
                 self.description_icon_label.config(image=self.deb)
                 self.description_type_label.config(text=FILE_NAME[31])
             else:
                 self.description_icon_label.config(image=self.other_file)
                 try:
                     if ext=='':
                         self.description_type_label.config(text=FILE_NAME[1])
                     else:
                         self.description_type_label.config(text='{0} {1}'.format(FILE_NAME[0],ext.upper()))
                 except AttributeError:
                     pass
             if FileModule.get_date(elmt) == None:
                 self.description_date_label.config(text='')
             if FileModule.get_size(elmt) == None:
                 self.description_size_label.config(text='')
             else:
                 self.description_date_label.config(text='{}'.format(FileModule.get_date(elmt)))
                 self.description_size_label.config(text='{0} : {1} Ko'.format(OTHERS_WORDS[1],FileModule.get_size(elmt)))   
     except TclError:
         pass