When I try to place variables as text, it says this: TypeError: 'Text' object is not subscriptable
Here is the code I used to generate this error:
import PySimpleGUI as sg
font1 = ("Calibri", 15)
text1 = "PlaceholderText1"
text2 = "PlaceholderText2"
text3 = "PlaceholderText3"
text4 = "PlaceholderText4"
text5 = "PlaceholderText5"
text6 = "PlaceholderText6"
text7 = "PlaceholderText7"
text8 = "PlaceholderText8"
text9 = "PlaceholderText9"
text10 = "PlaceholderText10"
def stock():
layout = [[sg.Text("Our Stock:", font=font1)
[sg.Text(text1)]
[sg.Text(text2)]
[sg.Text(text3)]
[sg.Text(text4)]
[sg.Text(text5)]
[sg.Text(text5)]
[sg.Text(text6)]
[sg.Text(text7)]
[sg.Text(text8)]
[sg.Text(text9)]
[sg.Text(text10)]]]
window = sg.Window("Our Stock", layout, modal=True, size=(250, 300))
choice = None
while True:
event, values = window.read()
if event == "Exit" or event == sg.WIN_CLOSED:
break
window.close()
def lobbyWindow():
layout = [[sg.Text("What do you want to buy?")],
[sg.Input(key='INPUT1')],
[sg.Button("View Stock"), sg.Button("Exit"), sg.Button("Admin Panel")]]
window = sg.Window("The Store", layout)
while True:
event, values = window.read()
if event == "Exit" or event == sg.WIN_CLOSED:
break
if event == "View Stock":
stock()
window.close()
lobbyWindow()
It should carry on with the placeholder text because I set it outside any functions. I think there's something to do this, but I don't know how to do it.