1

Could someone review where's my error of that code?

import sys
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QMainWindow, QFormLayout, QLineEdit, QComboBox, QSpinBox, QGroupBox, QVBoxLayout, QDialogButtonBox


class MyForm(QMainWindow):
    def __init__(self):
        QMainWindow.__init__(self)

        self.first = QLineEdit("Name")
        self.secnd = QLineEdit("Surname")        
        self.gendr = QComboBox()
        self.gendr.addItems(['Male','Female','Shemale'])
        self.age = QSpinBox()
        self.age.setMinimum(15)

        self.fgLayout = QFormLayout()
        self.fgLayout.addRow('First', self.first)
        self.fgLayout.addRow('Second', self.secnd)
        self.fgLayout.addRow('Gender', self.gendr)
        self.fgLayout.addRow('Age', self.age)

        self.setLayout(self.fgLayout)
        self.setWindowTitle("My Form") 
        self.setGeometry(500,300,250,150)



if __name__ == "__main__":
    def run_app():
        app = QtWidgets.QApplication(sys.argv)
        mainWin = MyForm()
        mainWin.show()
        app.exec_()
    run_app()

I run it but it result with blank window. I can't find an error besides looking thru examples with PyQt5 scripts. Maybe some component I use in a wrong way?

I've changed the recommended settings like described at this link [https://github.com/spyder-ide/spyder/wiki/How-to-run-PyQt-applications-within-Spyder] but still get error:

\Anaconda3\lib\site-packages\ipykernel\parentpoller.py:116: UserWarning: Parent poll failed.  If the frontend dies,
                the kernel may be left running.  Please let us know
                about your system (bitness, Python, etc.) at
                ipython-dev@scipy.org
  ipython-dev@scipy.org""")


Kernel died, restarting

This must be some installation issue. I've just uninstalled previous version of Anaconda and installed a new one (Windows 7 Sp1). It may be also something wrong with my code because those examples from above link works fine; I've just added some features.

Peter.k
  • 1,475
  • 23
  • 40
  • see https://github.com/spyder-ide/spyder/wiki/How-to-run-PyQt-applications-within-Spyder – eyllanesc Dec 22 '18 at 17:25
  • 1
    It isn't a duplicate! – Cpp Forever Dec 22 '18 at 17:35
  • Yes. Thanks, I missed this while watching those examples. I've set the `automatic` setting but: \Anaconda3\lib\site-packages\ipykernel\parentpoller.py:116: UserWarning: Parent poll failed. If the frontend dies, the kernel may be left running. Please let us know about your system (bitness, Python, etc.) at ipython-dev@scipy.org ipython-dev@scipy.org""") Kernel died, restarting – Peter.k Dec 22 '18 at 17:43

0 Answers0