我已经构建了简单的 tkinter GUI。现在,我尝试可视化 3 个不同的图形(通过使用不同的变量调用相同的函数)并将它们放置在 GUI 的 3 个不同行中。
当我这样做时,我遇到了两个问题:
每次运行脚本(interface.py)时,我都会得到 2 个窗口 - GUI 和外部图形的窗口。如何摆脱第二个?
我无法可视化所有 3 个图表。脚本在显示第一个脚本后停止。我相信这是因为第一个图在循环中工作(迭代大量数据点)。有什么解决办法吗?
界面:
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 6 10:24:35 2020
@author: Dar0
"""
from tkinter import * #import tkinter module
from visualizer import main #import module 'visualizer' that shows the graph in real time
class Application(Frame):
''' Interface for visualizing graphs, indicators and text-box. '''
def __init__(self, master):
super(Application, self).__init__(master)
self.grid()
self.create_widgets()
def create_widgets(self):
# Label of the 1st graph
Label(self,
text='Hook Load / Elevator Height / Depth vs Time'
).grid(row = 0, column = 0, sticky = W)
# Graph 1 - Hook Load / Elevator Height / Depth vs Time
# button that displays the plot
#plot_button = Button(self,2
# command = main,
# height = 2,
# width = 10,
# text = "Plot"
# ).grid(row = 1, column = 0, sticky = W)
self.graph_1 = main(root, 1, 0)
# place the button
# in main window
# Label of the 2nd graph
Label(self,
text = 'Hook Load / Elevator Height vs Time'
).grid(row = 3, column = 0, sticky = W)
# Graph 2 - Hook Load / Elevator Height vs Time
self.graph_2 = main(root, 4, 0)
#Label of the 3rd graph
Label(self,
text = 'Hook Load vs Time'
).grid(row = 6, column = 0, sticky = W)
四季花海
相关分类