I have code which detects objects in a video and adds each object to a counter. I want to print this counter in a message box. I have tried using tkMessageBox, but the problem is I want the message to say "number of vehicles: ", counter. I have tried both of the following lines:
tkMessageBox.showinfo("Vehicle count", "Number of vehicles: " + counter)
and:
tkMessageBox.showinfo("Vehicle count", "Number of vehicles: ", counter)
However I get the errors
cannot concatenate 'str' and 'int' objects" and"showinfo() takes at most 2 arguments (3 given).
I also want to be able to resize and adjust the position of the message box, and apparently you cannot do this with tkMessageBox. Are there any alternatives to tkMessageBox that could be used?
This avoids the complaint about concatenate 'str' and 'int'
:
"Number of vehicles: " + str(counter)
Here is another typical way to do that:
"Number of vehicles: {}".format(counter)