Home > Mobile >  I want to use User input from PySimpleGUI to one of my output Excel file name
I want to use User input from PySimpleGUI to one of my output Excel file name

Time:06-01

I wanted to use User input from PYSimpleGUI to one of my output Excel file name in Python. I am getting error:

str1=(sg.Text["-IN4-"]) TypeError: 'type' object is not subscriptable

import PySimpleGUI as sg
import pandas as pd
import logging
---
---
g.theme("DarkTeal9")
layout = [[sg.T("")], [sg.Text("Data File:      "), sg.Input(), sg.FileBrowse(key="-IN1-")],
          [sg.T("")],   [sg.Text("Output Path: "), sg.Input(), sg.FolderBrowse(key="-IN3-")],
          **[sg.T("")],   [sg.Text("PID:             "), sg.Input(),sg.Text(key="-IN4-")]**,
          [[sg.T("")],sg.Button("Submit")]]
--- 
---
while True:
    event, values = window.read()
    if (event == sg.WINDOW_CLOSED or event == 'Exit') :
        exit()
    elif event == "Submit":
        print(values["-IN1-"])
        print(values["-IN3-"])
        loaddata1=pd.read_excel(values["-IN1-"])
        **str1=(sg.Text["-IN4-"])**
        window.minimize()
        break
---
---
---
**loaddata1.to_excel(values["-IN3-"] "\ "  f"str1" "_Data_with_Flags.xlsx", index=0)**

I want output file name as userinput_Data_with_Flags

Please do correct if my code is wrong.

CodePudding user response:

Change the row of elements with the sg.Text(key="-IN4-"), like so:

[sg.T("")],   [sg.Text("PID:             "), sg.Input(key="-IN4-")],
  • Related