0

I want pysimplegui to do the following:

  • read a number I input in an InputText;
  • store that number in a variable "n" that then is used to search for a specific element in an Excel sheet;
  • return value adjacent to the "n" variable from the Excel sheet and display it in a TextBox in the same window.

So far, I managed to get the GUI to display the number I input in one box into another box from that same window, but not sure how to first run that number through a piece of code so that it returns something else in the second TextBox.

import PySimpleGUI as sg

sg.theme('DarkAmber')
layout = [
    [sg.Text("Enter Avaya Code")],
    [sg.InputText("", key="avaya", size=(20, 3), do_not_clear=True)],
    [sg.Text("Enter Extension")],
    [sg.InputText("", key="extension", size=(20, 3), do_not_clear=True)],
    [sg.Button("Search", size=(7, 2))]]

window = sg.Window("Search").Layout(layout)

while True:
    event, values = window.Read()
    if event == "Search":
        window.FindElement("extension").Update(values["avaya"])```
Any suggestions?
Vlad Nemes
  • 11
  • 2
  • Don't understand the question. - how to first run that number through a piece of code so that it returns something else in the second TextBox. It may make sense in your head, but it didn't come through well in words. – Mike from PSG Apr 04 '20 at 15:21
  • Will try to rephrase. The number that I input in textbox 1 should be passed to a function that performs a search in an Excel file. The result of that search should then appear in textbox 2. Does this make more sense? – Vlad Nemes Apr 05 '20 at 06:48
  • Looks like you've done everything but add your call to do the search and get results. Instead of updating the second with the value of the first in your update call, you would use the value returned from your search function. If search: result = call_func() ; update(result). I must be missing something. – Mike from PSG Apr 05 '20 at 15:19

0 Answers0