Python Forum
[PyQt] Crashing When Request Math Equation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] Crashing When Request Math Equation
#1
this error occurs when I click on Hpa- In i have no idea what is happening.
this error is occurring inline 68-70. thanks in advanced!

from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets import*
import sys


class mywindow(QMainWindow):
    def __init__(self):
        super(mywindow, self).__init__()
        self.setGeometry(0, 0, 700, 960)
        self.setWindowTitle('Electronic Flight Bag')
        self.initUI()


    def initUI(self):
        #webpage
        self.simbreif = QtWidgets.QPushButton(self)
        self.simbreif.setGeometry(510, 260, 171, 61)
        self.simbreif.setText('Open SimBrief')
        self.simbreif.clicked.connect(self.simbriefclick)

        self.skyvector = QtWidgets.QPushButton(self)
        self.skyvector.setGeometry(50, 600, 171, 61)
        self.skyvector.setText('SkyVector')
        self.skyvector.clicked.connect(self.skyvectorclick)

#        self.navigraph = QtWidgets.QCheckBox(self)
#        self.navigraph.setGeometry(520, 400, 91, 21)
#        self.navigraph.setText('navigraph')
#        self.navigraph.clicked.connect(self.chartclick)

        #math
        #hascopascels to inches of mercury
        self.hpain = QtWidgets.QPushButton(self)
        self.hpain.setGeometry(598,90,85,61)
        self.hpain.setText('Hpa - IN')
        self.hpain.clicked.connect(self.hpainclick)
        #label
        self.hpainlabel = QtWidgets.QLabel(self)
        self.hpainlabel.setText('21211')
        self.hpainlabel.move(560,210)

        #inches of mercury to hascopascels
        self.inhpa = QtWidgets.QPushButton(self)
        self.inhpa.setGeometry(510,90,85,61)
        self.inhpa.setText('IN - Hpa')
        #Hpa In entry
        self.hpainentry = QLineEdit(self)
        self.hpainentry.setGeometry(510,170,171,31)
        self.hpainentry.setPlaceholderText('Please Enter Unit of Choice')




    def simbriefclick(self):
        print('yes')
        self.web = QWebEngineView()
        self.web.load(QUrl('https://www.simbrief.com/'))
        self.web.show()

    def skyvectorclick(self):
        self.web = QWebEngineView()
        self.web.load(QUrl('https://skyvector.com/'))
        self.web.show()

    def hpainclick(self):
        hpainanswer = int(hpainentry) /3386
        self.hpainlabel.setText(hpainanswer)
    




def window():
    app = QApplication(sys.argv)
    win = mywindow()
    win.show()
    sys.exit(app.exec_())
window()
Reply
#2
Output:
NameError: name 'hpainentry' is not defined
try

    def hpainclick(self):
        hpainanswer = int(self.hpainentry.text()) / 3386
        self.hpainlabel.setText(str(hpainanswer))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PYQT5] Crashing when using .hide() and .show() aking76 0 4,810 Sep-18-2018, 02:09 PM
Last Post: aking76

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020