0

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)
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685

1 Answers1

0

In my opinion, you can create variable to store selected value. See how I'm dealing with this problem.

def display():
    print(my_spinbox_var.get())
my_spinbox_var=IntVar()
my_spinbox=Spinbox(top_right,from_0,to=numpkts,width=3,textvariable=my_spinbox_var)
my_spinbox.grid(row=4,column=10)

Please do not hesitate to contact me.

Robert

Chernoviz
  • 16
  • 1
  • 3