我对 tkinter 还很陌生,我需要制作一个按钮,在同一个按钮上方的行中添加一个条目小部件,这可能吗?
from tkinter import *
root = Tk()
playerFrame = Frame(root)
#Players' numbers and names / Numeros e nomes dos jogadores
pnum1 = Label(playerFrame, text="1").grid(column=0, row=0)
pnum2 = Label(playerFrame, text="2").grid(column=0, row=1)
pnum3 = Label(playerFrame, text="3").grid(column=0, row=2)
pnum4 = Label(playerFrame, text="4").grid(column=0, row=3)
pnum5 = Label(playerFrame, text="5").grid(column=0, row=4)
pnum6 = Label(playerFrame, text="6").grid(column=0, row=5)
pnum7 = Label(playerFrame, text="7").grid(column=0, row=6)
player1 = Entry(playerFrame).grid(column=1, row=0)
player2 = Entry(playerFrame).grid(column=1, row=1)
player3 = Entry(playerFrame).grid(column=1, row=2)
player4 = Entry(playerFrame).grid(column=1, row=3)
player5 = Entry(playerFrame).grid(column=1, row=4)
player6 = Entry(playerFrame).grid(column=1, row=5)
player7 = Entry(playerFrame).grid(column=1, row=6)
#Function for the addPlayer button / Função para o botão addPlayer
def AddPlayer():
pass
#Button to add more players / Botão para adicionar mais jogadores
addPlayer = Button(playerFrame, text="Add player / Adicionar jogador").grid(column=1, row=7)
playerFrame.pack(side=TOP, anchor=NW)
root.mainloop()
我需要按钮向下并在其上方添加输入行