0

Currently, im still pretty new to PySimpleGUI and im trying to figure out how to display text pulled from a variable.

for example, without PySimpleGUI i would do as follows,

shiftLength = [ 
"1",
"8",
]

eightShift = [
"8-4",
"9-5",
"10-6",
"11-7",
"12-8",
]

eightHour = {
              "8 hour" : "eightShift",
}

N = (random.choice(shiftLength))

if N in eightTime:
    print(random.choice(eightShift)) 

How would I apply sg.Text instead of print? would i just do something like this?

if N in eightTime:
    M = random.choice(eightShift) 

layout = [[sg.Text(m)], [sg.Button("OK")]]
copperkam
  • 29
  • 5
  • Read cookbook and look through the demo programs and you will quickly learn how to use PySimpleGUI. Guessing sometimes works, but rarely for a more complex problem. It's like anything you learn in Python... It's gotta be learned, at least for a few minutes. – Mike from PSG Dec 07 '20 at 13:40

1 Answers1

1

Okay so turns out I was right on this, doing something like

if N in eightTime:
    M = random.choice(eightShift) 

layout = [[sg.Text(m)], [sg.Button("OK")]]

Does work, but you have to keep all variable above (which i didnt at first) the layout block. Maybe next time ill understand what im looking for enough to not come here.

copperkam
  • 29
  • 5