import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QLabel
from PyQt5.QtWidgets import QWidget
app = QApplication(sys.argv)
window = QWidget()
window.setWindowTitle('PyQt5 App')
window.setGeometry(100, 100, 280, 80)
window.move(600, 15)
helloMsg = QLabel('This is Test', parent=window)
helloMsg.move(60, 30)
window.show()
sys.exit(app.exec_())
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWidgets import QWidget
from PyQt5.QtWidgets import QGridLayout
from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtWidgets import QPushButton
from PyQt5.QtWidgets import QVBoxLayout
class GUI(QMainWindow):
-
- SuperClass Constructor
- setWindowTitle
- setFixedSize
- generalLayout
- centralWidget
- createDisplayLED
- createButtons
-
- createDisplayLED()
- createButtons()
- setDisplayText()
- getDisplayText()
- clearDisplay()
ERROR_MSG = 'ERROR'
def evaluateExpression(expression):
try:
result = str(eval(expression, {}, {}))
except Exception:
result = ERROR_MSG
return result
from functools import partial
class Controller:
-
def init(self, model, view):
self._evaluate = model
self._view = view
self._connectSignals() -
- calculateResult()
- buildExpression()
- connectSignals()
import sys
from PyQt5.QtWidgets import QApplication
from view import GUI
from model import evaluateExpression
from controller import Controller
def main():
pycalc = QApplication(sys.argv)
view = GUI()
view.show()
model = evaluateExpression
Controller(model=model, view=view)
sys.exit(pycalc.exec_())
if name == "main":
main()