This repository has been archived by the owner on Aug 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrootlocusGUI.py
42 lines (36 loc) · 1.48 KB
/
rootlocusGUI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from rootlocusplot import RLPlotting
import tkinter as tk
import matplotlib.pyplot as plt
if __name__ == "__main__":
# create and setup window
root = tk.Tk()
width, height = 600, 400
canvas1 = tk.Canvas(root, width=width, height=height)
canvas1.pack()
# prompt user for numerator coefficients
numLabel = tk.Label(root, text="numerator coefficients with space as separator")
canvas1.create_window(width/2, 20, window=numLabel)
numEntry = tk.Entry(root)
canvas1.create_window(width/2, 40, window=numEntry)
# prompt user for denominator coefficients
denLabel = tk.Label(root, text="denominator coefficients with space as separator")
canvas1.create_window(width/2, 60, window=denLabel)
denEntry = tk.Entry(root)
canvas1.create_window(width/2, 80, window=denEntry)
# function to embed plot in window
def plotRL():
numerator = [int(i) for i in numEntry.get().split()]
denominator = [int(i) for i in denEntry.get().split()]
RL = RLPlotting(numerator, denominator)
# display RL information
RLInfo = tk.Label(root, text=RL)
canvas1.create_window(width/2, 250, window=RLInfo, height=250, width=width)
# display plot outside window
ax, fig = RL.plot()
plt.show()
return RLInfo
# button to generate and display plot
plotIt = tk.Button(text="plot it!", command=plotRL)
# RLInfo = None
canvas1.create_window(width/2, 110, window=plotIt)
root.mainloop()