Форум сайта python.su
0
import os import tkinter from tkinter import * MGI = tkinter.Tk() MGI.title("LISTER V 0.0.2") MGI.geometry('900x350') #String_sort = '' #arry_sort = [''] def clicked_Button1(): i = 0 ii = 0 iii = 0 arry_sort = [''] String_sort = '' for root, dirs, files in os.walk(path.get()): arry_sort += files for x in files: iii += 1 i += 1 while ii < iii: if ".mp3" in arry_sort[ii + 1]: continue else: path_listOFiles.insert(END, arry_sort[ii +1]) ii += 1 def clicked_Button2(): i = 0 ii = 0 iii = 0 arry_sort = [''] for root, dirs, files in os.walk(path.get()): arry_sort += files i += 1 while ii < i: if ".mp3" in arry_sort[ii]: Listbox.insert(END, arry_sort[ii]) ii += 1 button1 = Button(MGI, text = "FIND THE PATH", width = 20 , height = 2, command = clicked_Button1) path_listMP3 = Listbox(width = 50) path_listOFiles = Listbox(width = 50) path = Entry(MGI, width = 50) path.place(x = 155, y = 10) button1.place(x = 155, y = 16) path_listMP3.place(x = 155, y = 100) path_listOFiles.place(x = 500, y = 100) MGI.mainloop() #Vladi lister files by rafi import os import tkinter from tkinter import * MGI = tkinter.Tk() MGI.title("LISTER V 0.0.2") MGI.geometry('900x350') #String_sort = '' #arry_sort = [''] def clicked_Button1(): i = 0 ii = 0 iii = 0 arry_sort = [''] String_sort = '' for root, dirs, files in os.walk(path.get()): arry_sort += files for x in files: iii += 1 i += 1 while ii < iii: if ".mp3" in arry_sort[ii + 1]: continue else: path_listOFiles.insert(END, arry_sort[ii +1]) ii += 1 def clicked_Button2(): i = 0 ii = 0 iii = 0 arry_sort = [''] for root, dirs, files in os.walk(path.get()): arry_sort += files i += 1 while ii < i: if ".mp3" in arry_sort[ii]: Listbox.insert(END, arry_sort[ii]) ii += 1 button1 = Button(MGI, text = "FIND THE PATH", width = 20 , height = 2, command = clicked_Button1) path_listMP3 = Listbox(width = 50) path_listOFiles = Listbox(width = 50) path = Entry(MGI, width = 50) path.place(x = 155, y = 10) button1.place(x = 155, y = 16) path_listMP3.place(x = 155, y = 100) path_listOFiles.place(x = 500, y = 100) MGI.mainloop()
Офлайн
1
while ii < iii: if ".mp3" in arry_sort[ii + 1]: continue else: path_listOFiles.insert(END, arry_sort[ii +1]) ii += 1
while ii < iii: if ".mp3" in arry_sort[ii + 1]: continue else: path_listOFiles.insert(END, arry_sort[ii +1]) ii += 1
Офлайн
72
tempkoder12Тогда clicked_Button1() нужно переписать:
По задумке программа в один listbox должно показывать только MP3 файлы а в втором все остальные кроме MP3
def clicked_Button1(): for root, dirs, files in os.walk(path.get()): for f in files: if f.endswith('.mp3'): path_listMP3.insert('end', f) else: path_listOFiles.insert('end', f)
Офлайн
0
а что делает функция for f in files?
Офлайн
72
Перебирает в цикле содержимое files и присваивает переменной f.
Офлайн