Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.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 要与matplotlib窗口同时打开tkinter窗口吗?_Python_Matplotlib_Tkinter - Fatal编程技术网

Python 要与matplotlib窗口同时打开tkinter窗口吗?

Python 要与matplotlib窗口同时打开tkinter窗口吗?,python,matplotlib,tkinter,Python,Matplotlib,Tkinter,''我的代码打开matplotlib窗口和tkinter,但tkinter窗口在退出matplotlib窗口后打开。我希望他们两个同时出现 只需将所有内容放在show()之前: 谢谢,它工作了,但是你能告诉我为什么不使用root.mainloop吗?如果你启动mainloop,你的程序将在那一行停止。它将等待根目录被销毁(当您关闭窗口时)。mainloop只是一个检查事件的无限循环,您只能在应用程序中调用它一次(使用show()执行此操作)。 from pylab import * import

''我的代码打开matplotlib窗口和tkinter,但tkinter窗口在退出matplotlib窗口后打开。我希望他们两个同时出现


只需将所有内容放在show()之前:


谢谢,它工作了,但是你能告诉我为什么不使用root.mainloop吗?如果你启动mainloop,你的程序将在那一行停止。它将等待根目录被销毁(当您关闭窗口时)。mainloop只是一个检查事件的无限循环,您只能在应用程序中调用它一次(使用show()执行此操作)。
from pylab import *
import matplotlib.pyplot as plt
from matplotlib import style
import numpy as np
import pylab
style.use('seaborn-white')

x = [0,8,-3,-8]
y = [0,8,1,-8]
color=['w','w','w','w']

fig = plt.figure()
ax1 = fig.add_subplot(111)

scatter(x,y, s=100 ,marker='.', c=color,edgecolor='w')
plt.ylabel('X')
plt.xlabel('Y')
ax1.yaxis.label.set_rotation(0)
circle1=plt.Circle((0,0),5,color='r',fill=False,linewidth='4')
fig = plt.gcf()
fig.gca().add_artist(circle1)
left,right = ax1.get_xlim()
low,high = ax1.get_ylim()
arrow( left, 0, right -left, 0, length_includes_head = True, head_width = 0.15 )
arrow( 0, low, 0, high-low, length_includes_head = True, head_width = 0.15 )


fig = pylab.gcf()
fig.canvas.set_window_title('Inner Slip Ring')


grid()
show()

from tkinter import *
root=Tk()
w=Label(root, text="hello")
w.pack()
root.mainloop()
...
root=Tk()
w=Label(root, text="hello")
w.pack()
#root.mainloop()    # Don't use this

grid()
show()