From fb75b9b8329f31a7d2559931283533278a862e7a Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Wed, 9 Feb 2022 11:14:50 -0500 Subject: [PATCH] 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. --- docs/index.md | 54 +++++++++++++++++ .../markdown input files/2_readme.md | 60 ++++++++++++++++++- readme_creator/output/index.md | 54 +++++++++++++++++ 3 files changed, 167 insertions(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index fd596edc..62c7400f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 + [sg.Text('Row 2')]] +TypeError: list indices must be integers or slices, not Text + +Process finished with exit code 1 +``` + --- # "Demo Programs" Applications diff --git a/readme_creator/markdown input files/2_readme.md b/readme_creator/markdown input files/2_readme.md index 458f7e9d..f294d550 100644 --- a/readme_creator/markdown input files/2_readme.md +++ b/readme_creator/markdown input files/2_readme.md @@ -5638,4 +5638,62 @@ window.close() [Tkinter bindings documentation](https://tcl.tk/man/tcl8.6/TkCmd/bind.htm#M18) ------------------- \ No newline at end of file +------------------ + +# 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 + [sg.Text('Row 2')]] +TypeError: list indices must be integers or slices, not Text + +Process finished with exit code 1 +``` + diff --git a/readme_creator/output/index.md b/readme_creator/output/index.md index fd596edc..62c7400f 100644 --- a/readme_creator/output/index.md +++ b/readme_creator/output/index.md @@ -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 + [sg.Text('Row 2')]] +TypeError: list indices must be integers or slices, not Text + +Process finished with exit code 1 +``` + --- # "Demo Programs" Applications