小编Ana*_*dav的帖子

当 tkinter 窗口关闭时,python 程序并未结束

我正在开发一个类似 GUI 的示波器项目。虽然 GUI 还没有准备好,但是我遇到了一个问题,当我关闭 TKinter 窗口时,程序没有关闭。它仍然在 python shell 中运行。我想这可能是关闭 tkinter 相关程序的方法。但我发现只要关闭 tkinter 窗口就会杀死程序。就我而言,即使关闭 tkinter 窗口后,程序仍在 python shell 中运行。我把我的代码放在这里,请看看问题出在哪里?

from tkinter import *
from matplotlib import pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import numpy as np

root = Tk()
root.geometry("800x500+100+100")
root.title('root window')

frame = Frame(root, borderwidth=1,bg="#0DBDAB") ## This is the frame in which plot will be shown
frame.place(relx=1.0/3,rely=0.5, anchor="center", relwidth=0.60,relheight=0.8)
xar = [0]
yar = [0]
k=0.2  ### This is just …
Run Code Online (Sandbox Code Playgroud)

python animation tkinter matplotlib matplotlib-widget

4
推荐指数
1
解决办法
4477
查看次数