[sg.InputText(key='filename', size=(50, 1), font=('楷体', 10))]显示应为类型 'list[Text]' (匹配的泛型类型 'list[_T]'),但实际为 'list[Input]'该如何修改 
时间: 2023-05-24 07:06:34 浏览: 12
将 `sg.InputText()` 改为 `sg.Text()`,因为 `sg.Text()` 返回一个纯文本元素,而 `sg.InputText()` 返回一个输入框元素。所以正确的代码应该是这样的:
```
sg.Text('文件名:', font=('楷体', 10)),
sg.Input(key='filename', size=(50, 1), font=('楷体', 10))
```
相关问题
[sg.Text('FileName', size=(7, 1), font=('华文中宋', 15))]+[sg.InputText(key='filename', size=(50, 1), font=('楷体', 10))],如何修改
您可以按照以下方式进行修改:
[sg.Text('文件名', size=(7, 1), font=('华文中宋', 15))] [sg.InputText(key='filename', size=(50, 1), font=('楷体', 10))],
您可以修改以下内容:
- 将“FileName”改为“文件名”或其他您希望显示的文本。
- 您可以调整大小、字体类型和字号,以适合您的需求。例如,您可以将大小从“size=(7, 1)”更改为“size=(10, 1)”。
- 您可以将输入框的长度更改为适合您的文件名长度。例如,您可以将“size=(50, 1)”更改为“size=(30, 1)”。
- 您可以将字体类型从“font=('楷体', 10)”更改为其他字体,例如“font=('微软雅黑', 12)”。
layout = [ [sg.Text('FileName', size=(7, 1), font=('华文中宋', 15))]+[sg.InputText(key='filename', size=(50, 1), font=('楷体', 10))], [sg.Output(size=(65, 10), font=('楷体', 10))], [sg.FilesBrowse("SELECT-FILE", key='file', target='filename'), sg.Button('CHANGE'), sg.Button('EXIT'),sg.Text('File-Converter', justification="left", font=('华文行楷', 30))] ]
This is a layout definition written in Python using the PySimpleGUI library. It creates a graphical user interface (GUI) with multiple elements including text, input, output, buttons, and file browsing options.
The layout includes:
- A text element with the label "FileName" using the "华文中宋" font with a size of 15.
- An input text element with a key of "filename" and a size of 50 using the "楷体" font with a size of 10.
- An output element with a size of 65 and a font of "楷体" with a size of 10.
- Three buttons: "SELECT-FILE", "CHANGE", and "EXIT".
- A text element with the label "File-Converter" using the "华文行楷" font with a size of 30 and left justification.
The layout is stored in a list called "layout". The square brackets indicate nested lists that contain different elements. The commas separate each element within a nested list.
相关推荐








