-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_plotter.py
More file actions
48 lines (39 loc) · 1.52 KB
/
Copy pathfunction_plotter.py
File metadata and controls
48 lines (39 loc) · 1.52 KB
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
43
44
45
46
47
48
import sys
from PySide2.QtWidgets import QApplication, QMainWindow, QMessageBox
from utils.UI_MainWIndow import Ui_MainWindow
from utils.validation import Validation
from utils.plotter import Plotter
class FunctionPlotterWindow(QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.plot_button.clicked.connect(self.plot)
def plot(self):
# Get input data from the UI
function_str = self.function_input.text()
min_input = self.min_input.text()
max_input = self.max_input.text()
# Perform input validation
input_data = Validation(function_str, min_input, max_input)
if input_data.validate():
# Create a Plotter instance
plotter = Plotter()
try:
# Generate plot
plotter.get_values(input_data.function_input , input_data.min_input, input_data.max_input)
self.gridLayout_3.addWidget(plotter.canvas, 0, 0, 1, 1)
plotter.figure.clear()
plotter.plot()
except Exception:
# Display error message if an exception occurs during plotting
plotter.figure.clear()
plotter.display_error()
def main():
# Create the application and window instance
app = QApplication(sys.argv)
window = FunctionPlotterWindow()
# Show the window and start the application event loop
window.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()