I am cleaning up some code, I originally had:
program_lbl = Label(input_frame, text="Program")
program_lbl.grid(column=1, row=0)
program_combo = Combobox(input_frame, values = ['program1', 'program2'], state = "readonly", width = 8)
program_combo.grid(column=1, row=1)
program_combo.set('program1') #set program1 as default
and I condensed it to:
program_lbl = Label(input_frame, text="Program").grid(column=1, row=0)
program_combo = Combobox(input_frame, values = ['program1', 'program2'], state = "readonly", width = 8).grid(column=1, row=1)
program_combo.set('HUNTER') #set program1 as default
but I get the following error:
Traceback (most recent call last):
File "c:\Users\j56967\.vscode\extensions\ms-python.python-2019.3.6558\pythonFiles\ptvsd_launcher.py", line 45, in <module>
main(ptvsdArgs)
File "c:\Users\j56967\.vscode\extensions\ms-python.python-2019.3.6558\pythonFiles\lib\python\ptvsd\__main__.py", line 391, in main
run()
File "c:\Users\j56967\.vscode\extensions\ms-python.python-2019.3.6558\pythonFiles\lib\python\ptvsd\__main__.py", line 272, in run_file
runpy.run_path(target, run_name='__main__')
File "C:\Python367-64\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Python367-64\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Python367-64\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\j56967\Documents\python\gui_refinement.py", line 46, in <module>
program_combo.set('program1')
AttributeError: 'NoneType' object has no attribute 'set'
When I comment out the program_combo.set('program1')
line everything works but the combobox has no default selection.
EDIT: The duplicate marked below has a great answer to my question, thank you.