I'm trying to make a small program that you can enter names into places, assign scores, then save and show the data.
It currently works using this code
import PySimpleGUI as sg
col1 = [
[sg.Push(), sg.Text('Insert Names Here'), sg.Push()],
[sg.Text('1st '), sg.Push(), sg.Input('', key='-1place-', size=(30), do_not_clear=False)],
[sg.Text('2nd '), sg.Push(), sg.Input('', key='-2place-', size=(30), do_not_clear=False)],
[sg.Push(), sg.Button('Calculate'), sg.Push()],
]
col2 = [
[sg.Text('Points')],
[sg.Input('', key='-1points-', size=(5, 30))],
[sg.Input('', key='-2points-', size=(5, 30))],
[sg.Button('Save')]
]
col3 = [
[sg.Push(), sg.Text('Rankings'), sg.Push()],
#insert table here
[sg.Push(), sg.Button('Refresh Scores'), sg.Button('Open to Print'), sg.Push()]
]
layout = [
[
sg.Column(col1),
sg.VSeparator(),
sg.Column(col2),
sg.VSeparator(),
sg.Column(col3),
]
]
window = sg.Window("Shooter Rankings", layout)
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
the problem is now I need to track the top 20 names and repeating that code is pretty bulky so I tried changing the first column to this but keep getting errors.
import PySimpleGUI as sg
def NameBox(num):
return [sg.Text(str(num)),sg.Push(), sg.Input(key=f"-{num}place-", size=(30), do_not_clear=False)]
col1 = [
[sg.Push(), sg.Text('Insert Names Here'), sg.Push()],
[NameBox(x) for x in range(5)],
[sg.Push(), sg.Button('Calculate'), sg.Push()],
]
am I missing something simple or do I just need to list them all out individually?