主程序 music_play.py (主界面已完成)
import tkinter as tk
import time
from music_control_function import *
window = tk.Tk()
window.title('MusicPlay')
window.geometry('500x300')
topControlCanvas = tk.Canvas(window, bg='#017BDE', height=50, width=500)
topControlCanvas.pack(side='top')
loadButton = tk.Button(window, text='登 录', font=('Arial', 12), bg='#017BDE', fg='white', width=10, height=1)
loadButton.place(x=15, y=12)
signButton = tk.Button(window, text='注 册', font=('Arial', 12), bg='#017BDE', fg='white', width=10, height=1)
signButton.place(x=135, y=12)
openFileButton = tk.Button(window, text='打开文件', font=('Arial', 12), bg='#017BDE', fg='white', width=10, height=1, command=open_file)
openFileButton.place(x=255, y=12)
playMVButton = tk.Button(window, text='播放MV', font=('Arial', 12), bg='#017BDE', fg='white', width=10, height=1)
playMVButton.place(x=375, y=12)
musicStr = tk.StringVar()
musicStr.set(('心之向往', '白日梦蓝', '春天的故事'))
musicList = tk.Listbox(window, listvariable=musicStr)
musicList.place(x=10, y=60)
middleMVCanvas = tk.Canvas(window, bg='#017BDE', height=180, width=330)
imgMVFile = tk.PhotoImage(file='kaixin.gif')
imgMV = middleMVCanvas.create_image(160, 145, image=imgMVFile)
middleMVCanvas.place(x=160, y=60)
bottomControlCanvas = tk.Canvas(window, bg='#017BDE', height=50, width=500)
upSongOval = bottomControlCanvas.create_oval(12, 12, 40, 40, outline='white', width=2)
upSongLine = bottomControlCanvas.create_line(22, 22, 22, 32, fill='white', width=2)
upSongTriangle = bottomControlCanvas.create_polygon(22, 27, 30, 22, 30, 32, outline='white', width=2, fill='')
playPauseSongOval = bottomControlCanvas.create_oval(62, 12, 90, 40, outline='white', width=2)
playPauseSongLineOne = bottomControlCanvas.create_line(73, 22, 73, 32, fill='white', width=2)
playPauseSongLineTwo = bottomControlCanvas.create_line(80, 22, 80, 32, fill='white', width=2)
nextSongOval = bottomControlCanvas.create_oval(112, 12, 140, 40, outline='white', width=2)
nextSongLine = bottomControlCanvas.create_line(131, 22, 131, 32, fill='white', width=2)
nextSongTriangle = bottomControlCanvas.create_polygon(131, 27, 123, 22, 123, 32, outline='white', width=2, fill='')
songName = tk.StringVar()
songName.set('生之向往')
songNameLabel = tk.Label(window, textvariable=songName, bg='#017BDE', fg='yellow', font=('Arial', 10), height=1)
songNameLabel.place(x=180, y=252)
fillLine = bottomControlCanvas.create_rectangle(180, 32, 350, 34, outline='#80BCD5', fill='#80BCD5')
x = 500
n = 465/x
songTime = tk.StringVar()
songTime.set('02:08/05:21')
songTimeLabel = tk.Label(window, textvariable=songTime, bg='#017BDE', fg='yellow', font=('Arial', 10), height=1)
songTimeLabel.place(x=360, y=267)
def songControl(event):
print(event)
songControlClick = bottomControlCanvas.bind(sequence='<Button 1>', func=songControl)
bottomControlCanvas.pack(side='bottom')
window.mainloop()
控制流程程序 music_control_function.py (未完成)
import tkinter as tk
from tkinter import filedialog
def open_file():
print("打开当前文件夹")
fname = filedialog.askopenfile(title='打开文件', filetypes=[('s2out', '*.dat'), ('All Files', '*')])
print(fname)