import PySimpleGUI as sg
import random
sg.theme("Dark Green")
x = 0
y = 0
def generate():
x = values["FROM"]
y = values["TO"]
values['OUTPUT'] = random.randint(int(x), int(y))
window['OUTPUT'].update(values['OUTPUT'])
layout = [
[sg.Text("From:"), sg.Input(size = (5, 1), enable_events = True, key = "FROM")],
[sg.Text("To:"), sg.Input(size = (5, 1), enable_events = True, key = "TO")],
[sg.Button("Generate:", key = "GENERATE"), sg.Text(random.randint(int(x), int(y)), key = 'OUTPUT')],
]
window = sg.Window("Random numbers", layout, size = (150, 100))
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
elif event == "GENERATE":
generate()
window.close()
[sg.Button("Generate:", key = "GENERATE"), sg.Text(random.randint(int(x), int(y)), size=(4,1), key = 'OUTPUT')],
[sg.Button("Generate:", key = "GENERATE"), sg.Text(random.randint(int(x), int(y)), key = 'OUTPUT', auto_size_text=False)],