[Bug] unknown color name "1234567890" error when changing default color in global settings
Type of Issue (Enhancement, Error, Bug, Question)
Bug
Operating System
Windows 10
PySimpleGUI Port (tkinter, Qt, Wx, Web)
tkinter
Versions
Python version: 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] port: tkinter tkinter version: 8.6.9 PySimpleGUI version: 4.39.1 PySimpleGUI filename: C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py
Python version (sg.sys.version)
3.9.1
PySimpleGUI Version (sg.__version__)
4.39.1
GUI Version (tkinter (sg.tclversion_detailed), PySide2, WxPython, Remi)
8.6.9
Your Experience In Months or Years (optional)
Years Python programming experience 1 Years Programming experience overall 1 Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine) no Anything else you think would be helpful?
Troubleshooting
These items may solve your problem. Please check those you've done by changing - [ ] to - [X]
- [x] Searched main docs for your problem www.PySimpleGUI.org
- [ ] Looked for Demo Programs that are similar to your goal Demos.PySimpleGUI.org
- [ ] If not tkinter - looked for Demo Programs for specific port
- [ ] For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
- [ ] Run your program outside of your debugger (from a command line)
- [X] Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
- [ ] Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description
I saw I could change the default theme in the global settings, so I ran sg.main(). This launched the settings, or whatever it is, I couldn't really tell, and I went to global settings and changed the default theme a few times. When I changed it to one of the last on the bottom of the list, it just stopped running and gave the error beneath. I guess this is a bug? I have uninstalled it multiple times, I checked everything was gone, and it was, but I keep getting this error no matter how much I re-install or re-run.
Traceback (most recent call last):
File "C:\Users\janva\PycharmProjects\projects\Number Guesser\timer.py", line 3, in <module>
gui.main()
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 20173, in main
window = _create_main_window()
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 20140, in _create_main_window
window = Window('PySimpleGUI Main Test Harness', layout,
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 7918, in __init__
self.Finalize()
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 8570, in finalize
self.Read(timeout=1)
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 8354, in read
results = self._read(timeout=timeout, timeout_key=timeout_key)
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 8420, in _read
self._Show()
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 8181, in _Show
StartupTK(self)
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 13962, in StartupTK
_convert_window_to_tk(window)
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 13834, in _convert_window_to_tk
PackFormIntoFrame(window, master, window)
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 12290, in PackFormIntoFrame
PackFormIntoFrame(element, element.TKColFrame, toplevel_form)
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 13212, in PackFormIntoFrame
_add_right_click_menu(element)
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 12182, in _add_right_click_menu
top_menu.config(activeforeground=toplevel_form.right_click_menu_selected_colors[0])
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1638, in configure
return self._configure('configure', cnf, kw)
File "C:\Users\janva\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1628, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown color name "1234567890"
Process finished with exit code 1
Code To Duplicate
This won't really give you an error because it will just run the main window thing. The problem started when I picked one of the last themes in the dropdown menu for default themes in global settings.
import PySimpleGUI as gui
gui.main()
Screenshot, Sketch, or Drawing

It was the things you did PRIOR to these errors, prior to calling sg.main() that matters.
What's not well documented right now is that file you should delete to restore these settings. That tells me I need to provide a new function
main_reset_global_settings()
Rather than try the same crashing action that achieves the same results, let's try a few other options.
The first is to see what you changed the theme to.
When I run 4.39.1 and call sg.main()
I get this window.

Choosing the global settings, this is the window and the list of options when pulled down:

The last option is Topanga, a theme that is not known to have problems.
Backing up, one of the items is to search the issues. Searching for 1234566789, I'm taken to this issue: https://github.com/PySimpleGUI/PySimpleGUI/issues/4193
It describes a similar issue and that the GtiHub release fixes it. Downloading a new PySimpleGUI.py file will likely fix this. But, let's continue to debug.
Instead of calling sg.main and crashing, let's call sg.theme() and see what theme you choose:
import PySimpleGUI as sg
print(sg.theme())
It prints "Topanga" since that's the item on the list.
I think you likely choose one of the gray "Default" themes that has a previously noted Issue. Print it and ket's see what you choose.
To "fix"this, to reset the settings, delete this file:
_PySimpleGUI_settings_global_.json
You will find it located here: C:\Users\YOUR_USER_NAME\AppData\Local\PySimpleGUI\settings
This is the default path for settings files.
You can print this constant to see this:
print(sg.DEFAULT_USER_SETTINGS_WIN_PATH)
The global settings file is not documented but there is a block of constants at the top of the PySimpleGUI.py file to give you a hint.

To get a fix for your specific problem, great the version from GitHub 4.39.1.13.
You can delete the settings file so that you don't have to worry about any startup trouble of older versions too.
Of course, the fix to not have this crash and hopefully, after the release of 4.40.0 this weekend, you won't experience this again.
A NEW theme has been added just to be sure and clear how to get everything gray, it's called:
GrayGrayGray
sg.theme(GrayGrayGray)
This code:
import PySimpleGUI as sg
sg.theme('GrayGrayGray')
layout = [ [sg.Text('My Window')],
[sg.Input(key='-IN-')],
[sg.Text(size=(12,1), key='-OUT-')],
[sg.Button('Go'), sg.Button('Exit')] ]
sg.Window('Window Title', layout).read(close=True)
will now produce this window:

Yeah I think I checked SystemDefault or SystemDefault1 as theme. I will try tomorrow and see if any of your solutions work.
The issue has been solved.
The following was in the settings file. So SystemDefault1 was the theme that made it crash and bug. I changed it to DarkAmber and it can start up again now. Thank you very much for your help.
{"-editor program-": "", "-explorer program-": "", "-editor format string-": "<editor> <file>", "-python command-": "", "-theme-": "SystemDefault1"}

Issues stay open until the change is released to PyPI so re-opening this one.
Back to your problem for a moment. One proposed solution was to delete the system settings since it had a theme that was bad. The basic problem was that you were unable to call sg.main() without it crashing.
Had I really thought things through, the easiest way out, rather than deleting the settings file, is to simply set the theme to some other value and then call sg.main().
The global theme (the bad one) would have been loaded initially, but by setting the theme yourself prior to calling sg.main() it would allow you to at least then run the main program and choose another global theme, or as instructed in the global settings window, set the theme to blank so that the default PySimpleGUI theme is used (Dark Blue 3)
I wanted to get this documented here so that if someone else runs into a similar problem, there's a way around the problem without deleting the entire settings.
One thing that will be good is to display the settings filename in the main window. This would have allows you to directly edit the json and set the theme. But, because you didn't know where it was on your system, without looking at the PySimpleGUI source, you really didn't have the edit option available.
So, I think there are perhaps 2 changes rather than 1.
This was released a while ago.