Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 在消息框中打印输出_Python 2.7_Tkinter_Tkmessagebox - Fatal编程技术网

Python 2.7 在消息框中打印输出

Python 2.7 在消息框中打印输出,python-2.7,tkinter,tkmessagebox,Python 2.7,Tkinter,Tkmessagebox,我有一个代码,可以检测视频中的对象,并将每个对象添加到计数器中。我想在消息框中打印此计数器。我曾尝试使用tkMessageBox,但问题是我希望消息显示“车辆数量:”,计数器。我尝试了以下两种方法: tkMessageBox.showinfo("Vehicle count", "Number of vehicles: " + counter) 以及: 但是我得到了错误 无法连接“str”和“int”对象,“showinfo()在 最多2个参数(给出3个) 我还希望能够调整消息框的大小和位置,显

我有一个代码,可以检测视频中的对象,并将每个对象添加到计数器中。我想在消息框中打印此计数器。我曾尝试使用tkMessageBox,但问题是我希望消息显示“车辆数量:”,计数器。我尝试了以下两种方法:

tkMessageBox.showinfo("Vehicle count", "Number of vehicles: " + counter)
以及:

但是我得到了错误

无法连接“str”和“int”对象,“showinfo()在 最多2个参数(给出3个)


我还希望能够调整消息框的大小和位置,显然tkMessageBox无法做到这一点。tkMessageBox还有其他替代品吗?

这避免了对
连接'str'和'int'的抱怨。

"Number of vehicles: " + str(counter)
下面是另一种典型的方法:

"Number of vehicles: {}".format(counter)
"Number of vehicles: {}".format(counter)