![](/img/trans.png)
[英]How can I pass multiple user input values from PySimpleGUI to a function, then output result to PySimpleGUI?
[英]I want to use User input from PySimpleGUI to one of my output Excel file name
我想將來自 PYSimpleGUI 的用戶輸入用於我在 Python 中的輸出Excel 文件名之一。 我收到錯誤:
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)**
我想要輸出文件名作為用戶輸入_Data_with_Flags
如果我的代碼錯誤,請糾正。
使用 sg.Text(key="-IN4-") 更改元素行,如下所示:
[sg.T("")], [sg.Text("PID: "), sg.Input(key="-IN4-")],
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.