Add linearIntercept
This commit is contained in:
parent
be1ebdd4d9
commit
f234437774
|
@ -0,0 +1,38 @@
|
||||||
|
from PyQt5 import QtWidgets, uic
|
||||||
|
|
||||||
|
|
||||||
|
class linearInterceptWin(QtWidgets.QMainWindow):
|
||||||
|
def __init__(self):
|
||||||
|
super(linearInterceptWin, self).__init__()
|
||||||
|
self.ui = uic.loadUi("ui/linearInterceptWindow.ui", self)
|
||||||
|
|
||||||
|
# Get calcBtn, and connect it to stuff.
|
||||||
|
self.calcBtn = self.findChild(QtWidgets.QPushButton, "calcBtn")
|
||||||
|
self.calcBtn.clicked.connect(self.calcBtnPressed)
|
||||||
|
|
||||||
|
# Get line1mBox
|
||||||
|
self.line1mBox = self.findChild(QtWidgets.QLineEdit, "line1mBox")
|
||||||
|
# Get line1cBox
|
||||||
|
self.line1cBox = self.findChild(QtWidgets.QLineEdit, "line1cBox")
|
||||||
|
|
||||||
|
# Get line2mBox
|
||||||
|
self.line2mBox = self.findChild(QtWidgets.QLineEdit, "line2mBox")
|
||||||
|
# Get line2cBox
|
||||||
|
self.line2cBox = self.findChild(QtWidgets.QLineEdit, "line2cBox")
|
||||||
|
|
||||||
|
# Get resultXBox
|
||||||
|
self.resultXBox = self.findChild(QtWidgets.QLineEdit, "resultXBox")
|
||||||
|
# Get resultYBox
|
||||||
|
self.resultYBox = self.findChild(QtWidgets.QLineEdit, "resultYBox")
|
||||||
|
|
||||||
|
self.ui.show()
|
||||||
|
|
||||||
|
def calcBtnPressed(self):
|
||||||
|
m1 = int(self.line1mBox.text())
|
||||||
|
c1 = int(self.line1cBox.text())
|
||||||
|
m2 = int(self.line2mBox.text())
|
||||||
|
c2 = int(self.line2cBox.text())
|
||||||
|
x = (c2 - c1) / (m1 - m2)
|
||||||
|
y = m1 * x + c1
|
||||||
|
self.resultXBox.setText(str(x))
|
||||||
|
self.resultYBox.setText(str(y))
|
|
@ -0,0 +1,158 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>linearInterceptWin</class>
|
||||||
|
<widget class="QMainWindow" name="linearInterceptWin">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>399</width>
|
||||||
|
<height>158</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MainWindow</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>391</width>
|
||||||
|
<height>121</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Line 1</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>167</width>
|
||||||
|
<height>58</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>m:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="line1mBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>c:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="line1cBox"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Line 2</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>167</width>
|
||||||
|
<height>58</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>m:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="line2mBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>c:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="line2cBox"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="calcBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Calculate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="layoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>30</x>
|
||||||
|
<y>120</y>
|
||||||
|
<width>331</width>
|
||||||
|
<height>27</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>X:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="resultXBox">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="resultYBox">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -1,5 +1,6 @@
|
||||||
from PyQt5 import QtWidgets, uic
|
from PyQt5 import QtWidgets, uic
|
||||||
from ui.linearWindow import linearWin
|
from ui.linearWindow import linearWin
|
||||||
|
from ui.linearInterceptWindow import linearInterceptWin
|
||||||
|
|
||||||
|
|
||||||
class mainWin(QtWidgets.QMainWindow):
|
class mainWin(QtWidgets.QMainWindow):
|
||||||
|
@ -23,6 +24,9 @@ class mainWin(QtWidgets.QMainWindow):
|
||||||
print(self.equval)
|
print(self.equval)
|
||||||
if self.equval == "Linear":
|
if self.equval == "Linear":
|
||||||
linearWin()
|
linearWin()
|
||||||
|
elif self.equval == "LinearIntercept":
|
||||||
|
print(self.equval)
|
||||||
|
linearInterceptWin()
|
||||||
|
|
||||||
def onEquCboChanged(self, text):
|
def onEquCboChanged(self, text):
|
||||||
self.equval = text
|
self.equval = text
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Linear Intresect</string>
|
<string>LinearIntercept</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
Loading…
Reference in New Issue