I have to display a number of wireshark packets and the user can select the particular packet to view the information. For that, I have used one function called SelectedFilterSearch() to display packets of the selected filter.
The user will select the particular packet from a Spinbox, which will display when the number of packets is greater than zero with a command button to display. I am unable to get spinbox selected value. Can anyone help? Below is my code. I am not using class.
def SelectedFilterSearch():
cap = pyshark.FileCapture(pktfname.get(), display_filter= fltrname.get())
def display():
print(selectedspin.get())
numpkts = 0
for i in cap:
numpkts = numpkts + 1
if numpkts < 1:
messagebox.showerror("Error", "Selected filter not available")
else:
dispString = "There are " + str(numpkts) + " packet available. Please select a packet to display"
selectedspin = Spinbox(top_right, from_=0, to=numpkts, width=3).grid(row=4, column=10)
TFLDisplayLpkts = tkinter.Label(top_right, font=("Courier", 9), text=dispString, background="cyan").grid(row=3, column=10)
TFLDisplayB = tkinter.Button(top_right, text = "Display", command = display).grid(row=5, column=10)