Started a new "Troubleshooting" section that contains error messages that can be searched for. It's meant for common typo kind of errors like missing a comma in your layout.

This commit is contained in:
PySimpleGUI 2022-02-09 11:14:50 -05:00
parent 9f8995a6f3
commit fb75b9b832
3 changed files with 167 additions and 1 deletions

View File

@ -7184,6 +7184,60 @@ window.close()
------------------
# Troubleshooting
![](https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/master/images/emojis/frust_112.png)
This section was added in early 2022, so it's a bit late in arriving, but it's a start. This section meant to be found when searching for common errors.
Some errors are too broad to cover here like module not found. That one has a huge number of possible root causes.
Instead, we're covering errors that are likely problems in your source code and they cannot be found by the PySimpleGUI code.
If it's any consolation, I run into these same errors frequently! We're programmers and mistakes happen.
## TypeError: list indices must be integers or slices, not ...
You'll get this error when you miss adding a comma at the end of a row in your layout.
Having extra commas isn't a problem and sometimes can be helpful to prevent this error. By leaving an extra comma on the last row, then you'll be able to add more rows without the fear of this error.
This is a **good** layout:
```python
import PySimpleGUI as sg
layout = [[sg.Text('Row 1')],
[sg.Text('Row 2')],]
event, values = sg.Window('Window Title', layout).read(close=True)
```
This one is **not good**
If the commas are removed from the layout, then we'll get this TypeError...
```python
import PySimpleGUI as sg
layout = [[sg.Text('Row 1')]
[sg.Text('Row 2')]]
event, values = sg.Window('Window Title', layout).read(close=True)
```
Generates the TypeErrpr:
```
Traceback (most recent call last):
File "scratch_356.py", line 4, in <module>
[sg.Text('Row 2')]]
TypeError: list indices must be integers or slices, not Text
Process finished with exit code 1
```
---
# "Demo Programs" Applications

View File

@ -5638,4 +5638,62 @@ window.close()
[Tkinter bindings documentation](https://tcl.tk/man/tcl8.6/TkCmd/bind.htm#M18)
------------------
------------------
# Troubleshooting
![](https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/master/images/emojis/frust_112.png)
This section was added in early 2022, so it's a bit late in arriving, but it's a start. This section meant to be found when searching for common errors.
Some errors are too broad to cover here like module not found. That one has a huge number of possible root causes.
Instead, we're covering errors that are likely problems in your source code and they cannot be found by the PySimpleGUI code.
If it's any consolation, I run into these same errors frequently! We're programmers and mistakes happen.
## TypeError: list indices must be integers or slices, not ...
You'll get this error when you miss adding a comma at the end of a row in your layout.
Having extra commas isn't a problem and sometimes can be helpful to prevent this error. By leaving an extra comma on the last row, then you'll be able to add more rows without the fear of this error.
This is a **good** layout:
```python
import PySimpleGUI as sg
layout = [[sg.Text('Row 1')],
[sg.Text('Row 2')],]
event, values = sg.Window('Window Title', layout).read(close=True)
```
This one is **not good**
If the commas are removed from the layout, then we'll get this TypeError...
```python
import PySimpleGUI as sg
layout = [[sg.Text('Row 1')]
[sg.Text('Row 2')]]
event, values = sg.Window('Window Title', layout).read(close=True)
```
Generates the TypeErrpr:
```
Traceback (most recent call last):
File "scratch_356.py", line 4, in <module>
[sg.Text('Row 2')]]
TypeError: list indices must be integers or slices, not Text
Process finished with exit code 1
```

View File

@ -7184,6 +7184,60 @@ window.close()
------------------
# Troubleshooting
![](https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/master/images/emojis/frust_112.png)
This section was added in early 2022, so it's a bit late in arriving, but it's a start. This section meant to be found when searching for common errors.
Some errors are too broad to cover here like module not found. That one has a huge number of possible root causes.
Instead, we're covering errors that are likely problems in your source code and they cannot be found by the PySimpleGUI code.
If it's any consolation, I run into these same errors frequently! We're programmers and mistakes happen.
## TypeError: list indices must be integers or slices, not ...
You'll get this error when you miss adding a comma at the end of a row in your layout.
Having extra commas isn't a problem and sometimes can be helpful to prevent this error. By leaving an extra comma on the last row, then you'll be able to add more rows without the fear of this error.
This is a **good** layout:
```python
import PySimpleGUI as sg
layout = [[sg.Text('Row 1')],
[sg.Text('Row 2')],]
event, values = sg.Window('Window Title', layout).read(close=True)
```
This one is **not good**
If the commas are removed from the layout, then we'll get this TypeError...
```python
import PySimpleGUI as sg
layout = [[sg.Text('Row 1')]
[sg.Text('Row 2')]]
event, values = sg.Window('Window Title', layout).read(close=True)
```
Generates the TypeErrpr:
```
Traceback (most recent call last):
File "scratch_356.py", line 4, in <module>
[sg.Text('Row 2')]]
TypeError: list indices must be integers or slices, not Text
Process finished with exit code 1
```
---
# "Demo Programs" Applications