tkinter制作音乐播放器界面(未完成版)

主程序 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)
# 播放MV按钮
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)

# 设置中部播放MV区域
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)
# playPauseSongTriangle = bottomControlCanvas.create_polygon(81, 27, 73, 22, 73, 32, outline='white', width=2, fill='')
# 下一首
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
# for i in range(x):
#    n = n + 465/x
#    bottomControlCanvas.coords(fillLine, (0, 0, n, 10))
#    window.update()
#    time.sleep(0.01)
# 显示歌曲时间
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)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值