from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from mainUI import *
from PyQt5.QtCore import *
import sys
# ----------------------UYGULAMA OLUŞTUR-------------------#
# ---------------------------------------------------------#
app = QApplication(sys.argv)
app.setStyle("Fusion")
winAna = QMainWindow()
ui = Ui_Calculator()
ui.setupUi(winAna)
winAna.show()
# -----------------------Hesap Makinası--------------------#
# ---------------------------------------------------------#
class mainCalcFunc(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setWindowTitle('PyQt5 Calculator GUI')
ui.lineEditCalc.setWordWrap(True)
ui.lineEditCalc.setAlignment(Qt.AlignRight)
ui.lineEditCalc.setFont(QFont('Arial', 120))
def action_equal(self):
equation = ui.lineEditCalc.text()
try:
ans = eval(equation)
ui.lineEditCalc.setText(str(ans))
except:
ui.lineEditCalc.setText("Wrong Input")
def mul(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "*")
def sub(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "-")
def add(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "+")
def div(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "/")
def clearAll(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText("")
def clearLast(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text[:-1])
def nokta(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + ".")
def action1(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "1")
def action2(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "2")
def action3(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "3")
def action4(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "4")
def action5(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "5")
def action6(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "6")
def action7(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "7")
def action8(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "8")
def action9(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "9")
def action0(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "0")
def action00(self):
text = ui.lineEditCalc.text()
ui.lineEditCalc.setText(text + "00")
ui.btnBolme.clicked.connect(div)
ui.btnArti.clicked.connect(add)
ui.btnCikarma.clicked.connect(sub)
ui.btnCarpma.clicked.connect(mul)
ui.btnEsittir.clicked.connect(action_equal)
ui.btn1.clicked.connect(action1)
ui.btn2.clicked.connect(action2)
ui.btn3.clicked.connect(action3)
ui.btn4.clicked.connect(action4)
ui.btn5.clicked.connect(action5)
ui.btn6.clicked.connect(action6)
ui.btn7.clicked.connect(action7)
ui.btn8.clicked.connect(action8)
ui.btn9.clicked.connect(action9)
ui.btn0.clicked.connect(action0)
ui.btnCift0.clicked.connect(action00)
ui.btnC.clicked.connect(clearAll)
ui.btnCE.clicked.connect(clearLast)
ui.btnVirgul.clicked.connect(nokta)
sys.exit(app.exec_())
Hiç yorum yok:
Yorum Gönder