该计划的总体目标是制作一个显示团队和个人得分的记分牌。它需要包含4列和5行用于团队方面,20个单独的空间用于单个输入。
我想创建一个使用我创建的上一个框使用用户输入的表。到目前为止,我已经创建了用户需要输入其团队名称并显示没有条目的表的位置。我需要它来显示他们正在做的事件以及得分和他们的团队名称/名称。
我是Python和tkinter的新手所以任何可以帮助我解决这个问题的人都会很棒!
from tkinter import *
import tkinter as tk
from time import sleep
def team_name():
print('Okay, what is your team name?')
window = Toplevel(main)
thirdLabel = Label(window, text='Please enter your team name below:',
bg='black', fg='yellow')
thirdLabel.pack()
Label2 = Label(window,text = '')
Label2.pack(padx=15,pady= 5)
entry2 = Entry(window,bd =5)
entry2.pack(padx=15, pady=5)
buttonconfirm1 = Button(window, text='Confirm',command=confirm1)
buttonconfirm1.pack()
def confirm1 ():
window = Toplevel(main)
confirmLabel = Label(window, text='Scoreboard', bg='black',
fg='yellow')
confirmLabel.pack(fill=X)
def table ():
window = Toplevel(main)
label3 = Label(window, text='Team name/Individual name', bg='black',
fg='yellow')
label3.pack()
firstBox = Entry(window, bd=1)
firstBox.pack()
secondBox = Entry(window, bd=1)
secondBox.pack()
thirdBox = Entry(window, bd=1)
thirdBox.pack()
def scoreboard():
window = Toplevel(main)
entry_1 = Label(window, text = '')
entry_2 = Label(window, text = '')
def individual_name():
print('Okay, what is you name?')
window = Toplevel(main)
secondLabel = Label(window, text='Please enter your name below',
bg='black', fg='yellow')
secondLabel.pack()
Label1 = Label(window,text = '')
Label1.pack(padx=15,pady= 5)
entry1 = Entry(window,bd =5)
entry1.pack(padx=15, pady=5)
buttonConfirm = Button(window, text='Confirm', command=table)
buttonConfirm.pack()
def confirm ():
window = Toplevel(main)
confirmLabel = Label(window, text='Scoreboard', bg='black', fg='yellow')
confirmLabel.pack(fill=X)
def close():
main.destroy()
main = Tk()
main.maxsize(800,600)
# Labels section
main_menu_label = Label(main, text='Welcome to the scoreboard! Please
select from the options below:', bg='Black',
fg='white')
# Using a photo for top frame on menu and making a label to place it
photo = PhotoImage(file='Scoreboard.gif')
photo_label = Label(main, image=photo)
photo_label.pack(side=TOP)
# Invisible frames for widget placement
top_frame = Frame(main)
top_frame.pack()
bottom_frame = Frame(main)
bottom_frame.pack(side=BOTTOM)
print('Okay! What is your team name?')
# Buttons for main menu and display on the screen
first_button = Button(top_frame, text='Are you entering as an
individual?', fg='yellow', bg='black',
command=individual_name)
second_button = Button(bottom_frame, text='Are you entering as a team?',
fg='yellow', bg='black', command=team_name)
quit_button = Button(bottom_frame, text='Quit?', fg='yellow', bg='black',
command=close)
first_button.pack()
second_button.pack()
quit_button.pack()
main.mainloop()
对不起,如果这有点令人困惑,我真的无法解释比我已经拥有的更多!