0

Tkinter Options Menu not displaying selection receiving below error

AttributeError: 'NoneType' object has no attribute 'set'

Used this code to add dynamic list to the option menu. Option menu changing dynamically when new list is generated but when select the item from the list the above error is coming

dropdownmenu=StringVar()
om=dropdownmenu.set("Select any section")
lst=final_key_list
drop_menu=drop.children['menu']
for val in lst:
   drop_menu.add_command(label=val,command=lambda v=om,l=val:v.set(1))
Harry
  • 11
  • 4
  • `dropdownmenu.set()` doesn't return anything, so why did you assign it to `om`? Also I believe you have a confusion between `l` and `1` in your lambda. – jasonharper May 16 '22 at 04:24
  • I want to show first option as "Select any section" when clicking the drop down list will be visible. If i want to use lambda command means whether i have to use 1=val or L=val?. If i am wrong please correct me. – Harry May 16 '22 at 05:09
  • I do not understand the code after the lambda command i just replicate it based on my code answers were found v=om,l=val:v.set(1)) – Harry May 16 '22 at 05:11
  • @jasonharper I got your point. I have corrected om and 1 in the code it fixed the issue. – Harry May 16 '22 at 05:51

0 Answers0