I am able to select items from my list but once I click the item I am not able to print the contents back to the terminal. I am also trying to figure out how to close the prompt once the user makes a selection. Any help would be greatly appreciated.
window.title('UTC Time Selection')
# for scrolling vertically
yscrollbar = Scrollbar(window)
yscrollbar.pack(side = RIGHT, fill = Y)
label = Label(window,
text = "Select the UTC Time for Scanning to Start : ",
font = ("Times New Roman", 12),
padx = 10, pady = 10)
label.pack()
list = Listbox(window, selectmode = "single",
yscrollcommand = yscrollbar.set)
# Widget expands horizontally and
# vertically by assigning both to
# fill option
list.pack(padx = 10, pady = 10,
expand = YES, fill = "both")
x =["0000", "0100", "0200", "0300", "0400",
"0500", "0600", "0700", "0800", "0900",
"1000", "1100", "1200", "1300", "1400",
"1500", "1600", "1700", "1800", "1900",
"2000", "2100", "2200", "2300"]
for each_item in range(len(x)):
list.insert(END, x[each_item])
list.itemconfig(each_item, bg = "white")
# Attach listbox to vertical scrollbar
yscrollbar.config(command = list.yview)
Button(window, text="Save & Exit", command=window.destroy).pack()
window.mainloop()
the_response = list.get(list.curselection())
print (the_response)