gpt4 book ai didi

Python 3.5 - 将按钮放在按钮之上

转载 作者:太空宇宙 更新时间:2023-11-03 17:04:36 25 4
gpt4 key购买 nike

所以我正在创建一个钢琴程序,当按下 tkinter gui 界面上的按钮时,该程序会播放声音。当我将按钮放在我想要的位置时。钢琴的黑键位于白键后面。 Image Link .

如何才能使黑键位于白键之上。

下面的代码

from tkinter import *
import winsound
Gui=Tk()
Gui.title("Piano")
Gui.geometry("400x400")

def PianoF():
winsound.PlaySound("PianoF.wav",winsound.SND_ASYNC)
def PianoGb():
winsound.PlaySound("PianoGb.wav",winsound.SND_ASYNC)
def PianoG():
winsound.PlaySound("PianoG.wav",winsound.SND_ASYNC)
def PianoAb():
winsound.PlaySound("PianoAb.wav",winsound.SND_ASYNC)
def PianoA():
winsound.PlaySound("PianoA.wav",winsound.SND_ASYNC)
def PianoBb():
winsound.PlaySound("PianoBb.wav",winsound.SND_ASYNC)
def PianoB():
winsound.PlaySound("PianoB.wav",winsound.SND_ASYNC)
def PianoC():
winsound.PlaySound("PianoC.wav",winsound.SND_ASYNC)
def PianoDb():
winsound.PlaySound("PianoDb.wav",winsound.SND_ASYNC)
def PianoD():
winsound.PlaySound("PianoD.wav",winsound.SND_ASYNC)
def PianoEb():
winsound.PlaySound("PianoEb.wav",winsound.SND_ASYNC)
def PianoE():
winsound.PlaySound("PianoE.wav",winsound.SND_ASYNC)

FNote=Button(Gui,height=15,width=6,bg='white',command=PianoF)
GbNote=Button(Gui,height=9,width=5,bg='black',command=PianoGb)
GNote=Button(Gui,height=15,width=6,bg='white',command=PianoG)
AbNote=Button(Gui,height=9,width=5,bg='black',command=PianoAb)
ANote=Button(Gui,height=15,width=6,bg='white',command=PianoA)
BbNote=Button(Gui,height=9,width=5,bg='black',command=PianoBb)
BNote=Button(Gui,height=15,width=6,bg='white',command=PianoB)
CNote=Button(Gui,height=15,width=6,bg='white',command=PianoC)
DbNote=Button(Gui,height=9,width=5,bg='black',command=PianoDb)
DNote=Button(Gui,height=15,width=6,bg='white',command=PianoD)
EbNote=Button(Gui,height=9,width=5,bg='black',command=PianoEb)
ENote=Button(Gui,height=15,width=6,bg='white',command=PianoE)


GbNote.place(x=28,y=0)
AbNote.place(x=84,y=0)
BbNote.place(x=140,y=0)
DbNote.place(x=252,y=0)
EbNote.place(x=308,y=0)

FNote.place(x=0,y=0)
GNote.place(x=56,y=0)
ANote.place(x=112,y=0)
BNote.place(x=168,y=0)
CNote.place(x=224,y=0)
DNote.place(x=280,y=0)
ENote.place(x=336,y=0)

最佳答案

for w in (ANote, BNote, CNote, DNote, ENote, FNote, GNote):
w.lower()

使用列表而不是那种类型的名称会更好。

关于Python 3.5 - 将按钮放在按钮之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34698880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com