采用tkinter可视化GUI编写的界面,感兴趣的自行查找相关资料学习。
python代码:
import asyncio
import os
import re
import time
import threading
import winreg
from tkinter import *
from urllib import parse
import requests
from lxml import etree
# 127万能音乐下载器
class Music:
def __init__(self):
self.init_Menu()
def init_Menu(self):
self.top = Tk()
self.top.geometry("400x400")
self.top.title("Author:xuhao QQ:916295795 Email:916295795@qq.com")
self.show_main_frame()
def show_main_frame(self):
self.frame = Frame(self.top)
self.label = Label(self.frame,
text='万能音乐下载器V2.0')
self.label.pack()
# 设置数据库地址
self.windowlabel = Label(self.frame,
text='消息栏')
self.windowlabel.pack()
self.cwd = StringVar(self.frame)
self.cwd.set("快输入歌曲信息叭!(*^▽^*)")
# frame容器
self.dirfm = Frame(self.frame)
# 下滑框
self.dirsb = Scrollbar(self.dirfm)
self.dirsb.pack(side=RIGHT, fill=Y)
self.v = StringVar()
self.main = Listbox(self.dirfm, listvariable=self.v, height=15,
width=50, yscrollcommand=self.dirsb.set)
self.dirsb.config(command=self.main.yview)
self.main.pack(side=LEFT, fill=BOTH)
self.dirfm.pack()
# 装载了StringVar
self.dirn = Entry(self.frame, width=50,
textvariable=self.cwd)
self.dirn.pack()
# 又是一个容器
self.bfm = Frame(self.frame)
self.getdata_btn = Button(self.bfm, text='查找歌曲',
command=self.getmusicdata,
activeforeground='white',
activebackground='blue')
self.download_btn = Button(self.bfm, text='下载歌曲',
command=self.selectdownloaddata,
activeforeground='white',
activebackground='blue')
self.clear = Button(self.bfm, text='清空输入',
command=self.clearInput,
activeforeground='white',
activebackground='green')
self.openfiledir = Button(self.bfm, text='歌曲位置',
command=self.openfd,
activeforeground='white',
activebackground='green')
self.quit = Button(self.bfm, text='退出程序',
command=self.top.quit,
activeforeground='white',
activebackground='red')
self.getdata_btn.pack(side=LEFT)
self.download_btn.pack(side=LEFT)
self.cl