编写一个钢琴键的布局 from tkinter import * root = Tk() root.geometry("700x220") # Frame是一个矩形区域,用于放置其他组件 # A Frame is a rectangular area where other components are placed f1 = Frame(root) f1.pack() f2 = Frame(root) f2.pack() btnText = ("fashion", "chinese style", "japanese style", "Heavy metal", "light music") for txt in btnText: Button(f1, text=txt).pack(side="left", padx="18") for i in range(1, 20): Label(f2, width=5, height=10, borderwidth=1, relief="solid", bg="black" if i % 2 == 0 else "white").pack(side="left", padx=2) root.mainloop()