Program quits while executing pushbutton in PyQT/QtDesigner program

0

I am new to PyQt and I have designed a very basic program with Qt designer and PyQt5. I am getting an error while executing the pushbutton that has a simple code to display name.

Error: Process finished with exit code -1073740791 (0xC0000409)

Reading through some of the posts people say this might be related to the kernel. One solution was to include app.aboutToQuit.connect(app.deleteLater) and replace app.exec_(). But that did not fix it

Here is what I do to run the program

  1. Execute the Python code, the UI window opens fine. I am able to enter values
  2. After clicking the push button, the program just quits. This happens only when I am trying to read values from the lineEdit box. If I replace the read lines with a simple print statement, I dont get any errors

I am wondering if there is anything wrong with my syntax or I am missing something else.

My python code is attached below

import sys
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5 import uic

Ui_MainWindow, QtBaseClass = uic.loadUiType("simple.ui")

class MyApp(QMainWindow):

    def __init__(self):
        super(MyApp, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.pushButton.clicked.connect(self.DisplayName)

    def DisplayName(self):
        name = 'Hello' + str(self.lineEdit.text())
        self.lineEdit.setText(name)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MyApp()
    window.show()
    sys.exit(app.exec_())

Here is the Ui file

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>800</width>
    <height>600</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <widget class="QLineEdit" name="lineEdit">
    <property name="geometry">
     <rect>
      <x>282</x>
      <y>130</y>
      <width>121</width>
      <height>31</height>
     </rect>
    </property>
   </widget>
   <widget class="QLabel" name="label">
    <property name="geometry">
     <rect>
      <x>200</x>
      <y>140</y>
      <width>71</width>
      <height>20</height>
     </rect>
    </property>
    <property name="text">
     <string>Message</string>
    </property>
   </widget>
   <widget class="QPushButton" name="pushButton">
    <property name="geometry">
     <rect>
      <x>410</x>
      <y>130</y>
      <width>93</width>
      <height>28</height>
     </rect>
    </property>
    <property name="text">
     <string>Welcome</string>
    </property>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>800</width>
     <height>26</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

Thanks

python-3.x
pyqt5
qt-designer
qpushbutton
asked on Stack Overflow Oct 4, 2018 by Polyhedronic

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0