feat(song_list): 本地歌曲搜索功能
- 在歌曲列表框下方添加搜索框,用于输入搜索关键词 - 实现本地歌曲搜索功能,根据用户输入实时过滤歌曲列表 - 优化歌曲列表显示,调整滚动条位置和大小 - 更新软件版本号至 4.1.4
This commit is contained in:
60
NFLmusic.py
60
NFLmusic.py
@ -317,8 +317,13 @@ def refresh():
|
||||
music_dir_without_endswith = [os.path.splitext(file)[0] for file in os.listdir(path) if
|
||||
file.endswith(('.mp3', '.flac', '.ogg', '.m4a'))]
|
||||
music_dir = [file for file in os.listdir(path) if file.endswith(('.mp3', '.flac', '.ogg', '.m4a'))]
|
||||
for musics in music_dir_without_endswith:
|
||||
listbox1.insert("end", musics)
|
||||
if var7.get() in ["", lang.get(la, "ui.download.entry.song_name")]:
|
||||
for musics in music_dir_without_endswith:
|
||||
listbox1.insert("end", musics)
|
||||
else:
|
||||
for musics in music_dir_without_endswith:
|
||||
if search_words in musics:
|
||||
listbox1.insert("end", musics)
|
||||
except:
|
||||
pass
|
||||
|
||||
@ -666,6 +671,7 @@ def update():
|
||||
root.destroy()
|
||||
except Exception as e:
|
||||
# 重新显示窗口
|
||||
check_update_button["state"] = "normal"
|
||||
root.deiconify()
|
||||
print(e)
|
||||
download_page.destroy()
|
||||
@ -722,6 +728,7 @@ def update():
|
||||
root.destroy()
|
||||
except Exception as e:
|
||||
# 重新显示窗口
|
||||
check_update_button["state"] = "normal"
|
||||
root.deiconify()
|
||||
print(e)
|
||||
download_page.destroy()
|
||||
@ -1099,6 +1106,18 @@ def entry_focus(boolean):
|
||||
var0.set(lang.get(la, "ui.download.entry.song_name"))
|
||||
|
||||
|
||||
def entry1_focus(boolean):
|
||||
global last_search_target1, focused
|
||||
if boolean:
|
||||
focused = True
|
||||
if entry1.get() == lang.get(la, "ui.download.entry.song_name"):
|
||||
var7.set("")
|
||||
else:
|
||||
focused = False
|
||||
if entry1.get() == "":
|
||||
var7.set(lang.get(la, "ui.download.entry.song_name"))
|
||||
|
||||
|
||||
def change_playing_mode():
|
||||
global playingmode
|
||||
if playingmode == 0:
|
||||
@ -1167,7 +1186,25 @@ def download_version():
|
||||
copy(version_json[get_treeview_index(version_list, version_download_choice)]["password"])
|
||||
|
||||
|
||||
version = "4.1.3"
|
||||
def search_local_song():
|
||||
global music_dir_without_endswith, search_words
|
||||
while True:
|
||||
if focused:
|
||||
former_words = var7.get()
|
||||
time.sleep(1)
|
||||
current_words = var7.get()
|
||||
if former_words != current_words and entry1.get() != lang.get(la, "ui.download.entry.song_name"):
|
||||
search_words = current_words
|
||||
filtered_list = [song for song in music_dir_without_endswith if search_words in song]
|
||||
print(filtered_list)
|
||||
listbox1.delete(0, END)
|
||||
for song in filtered_list:
|
||||
listbox1.insert(END, song)
|
||||
else:
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
version = "4.1.4"
|
||||
poem = ""
|
||||
appdata = os.getenv("APPDATA")
|
||||
make_resource()
|
||||
@ -1220,6 +1257,7 @@ song_list = []
|
||||
music_file_without_endswith = ""
|
||||
lyric = ""
|
||||
last_search_target = ""
|
||||
last_search_target1 = ""
|
||||
root.resizable(0, 0)
|
||||
screen_width = root.winfo_screenwidth()
|
||||
screen_height = root.winfo_screenheight()
|
||||
@ -1242,8 +1280,11 @@ var5 = StringVar()
|
||||
var5.set(la)
|
||||
var6 = BooleanVar()
|
||||
var6.set(auto_play)
|
||||
var7 = StringVar()
|
||||
var7.set(lang.get(la, "ui.download.entry.song_name"))
|
||||
isJoking = False
|
||||
changed = False
|
||||
focused = False
|
||||
player = None
|
||||
OptionMenu = ttk.OptionMenu
|
||||
Button = ttk.Button
|
||||
@ -1255,6 +1296,7 @@ showed = False
|
||||
page = "homepage"
|
||||
will_page = "homepage"
|
||||
former_page = "homepage"
|
||||
search_words = lang.get(la, "ui.download.entry.song_name")
|
||||
next_showed = False
|
||||
loaded = False
|
||||
have_checked = False
|
||||
@ -1341,12 +1383,17 @@ labelframe_song_list.place(x=20, y=20)
|
||||
|
||||
scrollbar1 = Scrollbar(labelframe_song_list, orient=VERTICAL)
|
||||
|
||||
listbox1 = Listbox(labelframe_song_list, width=30, height=17, yscrollcommand=scrollbar1.set)
|
||||
listbox1.place(x=10, y=8)
|
||||
listbox1 = Listbox(labelframe_song_list, width=30, height=16, yscrollcommand=scrollbar1.set)
|
||||
listbox1.place(x=10, y=0)
|
||||
listbox1.bind("<Double-1>", playsound)
|
||||
|
||||
entry1 = Entry(labelframe_song_list, width=31, textvariable=var7)
|
||||
entry1.bind("<FocusIn>", lambda event: entry1_focus(True))
|
||||
entry1.bind("<FocusOut>", lambda event: entry1_focus(False))
|
||||
entry1.place(x=10, y=295)
|
||||
|
||||
scrollbar1.config(command=listbox1.yview)
|
||||
scrollbar1.place(x=227, y=8, height=315)
|
||||
scrollbar1.place(x=227, y=0, height=292)
|
||||
|
||||
refresh()
|
||||
|
||||
@ -1567,6 +1614,7 @@ menu1.place(x=50, y=20)
|
||||
|
||||
root.iconbitmap(resource_path + "/.NFLmusic/resource/icon.ico")
|
||||
|
||||
run(search_local_song)
|
||||
run(tick)
|
||||
music_player.bind(cls_time=playing_time, cls_progress_bar=playing_progress)
|
||||
playing_progress["command"] = lambda event: music_player.set_progress(playing_progress.get())
|
||||
|
Reference in New Issue
Block a user