Window is closing immediately after I run program in PyQt 4 (anaconda) [PyCharm 4.5]

Jesus Ramos

So, I am trying to run a very simple program (a window) in Pycharm that is running anaconda 2.7 & PyQt4. Whenever I click the Run button it opens my program but closes the window too fast for me to even see it. May anyone, please help? Thank you!

P.S.

I'm very new to programming.

{__author__ = 'Jay'

import sys
from PyQt4 import QtGui

app = QtGui.QApplication(sys.argv)

window = QtGui.QWidget()

window.show()}
qurban

You need to block the execution of the program after you call window.show() so that the window object remains active otherwise it will be garbage collected. app.exec_() does this for you.

{__author__ = 'Jay'

import sys
from PyQt4 import QtGui

app = QtGui.QApplication(sys.argv)

window = QtGui.QWidget()

window.show()
app.exec_()}     # added this line

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Console window closes immediately when I run the program

From Dev

How do I execute more code after closing a PyQt window?

From Dev

PyQt4 to launch system tray icon immediately after login

From Dev

Tkinter window closes automatically after Python program has run in PyCharm

From Dev

Tkinter window closes automatically after Python program has run in PyCharm

From Dev

Python Kernel crashes after closing an PyQt4 Gui Application

From Dev

GUI window in Python (PyQT) flashing and closing down immediately?

From Dev

[PyQt]Open second window every time i push the button without closing the program

From Dev

No autocomplete for PyQt4 in PyCharm

From Dev

Run a program with GNU screen and immediately detach after

From Dev

PyQt Windows installer with Anaconda Python--PyQt4 not found; how do I troubleshoot?

From Dev

xcode when i run program on iphone 5 screen looks iphone 4

From Dev

In PyQt4 how do i initiate a window

From Dev

How to install PyQt4 in anaconda?

From Dev

PyCharm Cannot Run Program C:\\Anaconda\\python.exe

From Dev

How to close serial port when closing window with pyqt5

From Dev

Run immediately then every 4 hours in cron

From Dev

PyQt4 to PyQt5 migration

From Dev

Python output window disappears immediately in eclipse after run

From Dev

PyQt4 center window on active screen

From Dev

How to run a python program in the background even after closing the terminal?

From Dev

How to run a python program in the background even after closing the terminal?

From Dev

Exception after closing the program

From Dev

How do I prevent Pyro4 from closing the connection after COMMTIMEOUT

From Dev

After the program is run, the window generated by the program is blank and has no components

From Dev

How can I make link on web page in window using pyqt4?

From Dev

PyCharm not recognizing PyQT4 and PyQt4 not allowing me to 'view code'

From Dev

Clear PyCharm Run Window

From Dev

Thread not run immediately when using more than 4 BackgroundWorker

Related Related

  1. 1

    Console window closes immediately when I run the program

  2. 2

    How do I execute more code after closing a PyQt window?

  3. 3

    PyQt4 to launch system tray icon immediately after login

  4. 4

    Tkinter window closes automatically after Python program has run in PyCharm

  5. 5

    Tkinter window closes automatically after Python program has run in PyCharm

  6. 6

    Python Kernel crashes after closing an PyQt4 Gui Application

  7. 7

    GUI window in Python (PyQT) flashing and closing down immediately?

  8. 8

    [PyQt]Open second window every time i push the button without closing the program

  9. 9

    No autocomplete for PyQt4 in PyCharm

  10. 10

    Run a program with GNU screen and immediately detach after

  11. 11

    PyQt Windows installer with Anaconda Python--PyQt4 not found; how do I troubleshoot?

  12. 12

    xcode when i run program on iphone 5 screen looks iphone 4

  13. 13

    In PyQt4 how do i initiate a window

  14. 14

    How to install PyQt4 in anaconda?

  15. 15

    PyCharm Cannot Run Program C:\\Anaconda\\python.exe

  16. 16

    How to close serial port when closing window with pyqt5

  17. 17

    Run immediately then every 4 hours in cron

  18. 18

    PyQt4 to PyQt5 migration

  19. 19

    Python output window disappears immediately in eclipse after run

  20. 20

    PyQt4 center window on active screen

  21. 21

    How to run a python program in the background even after closing the terminal?

  22. 22

    How to run a python program in the background even after closing the terminal?

  23. 23

    Exception after closing the program

  24. 24

    How do I prevent Pyro4 from closing the connection after COMMTIMEOUT

  25. 25

    After the program is run, the window generated by the program is blank and has no components

  26. 26

    How can I make link on web page in window using pyqt4?

  27. 27

    PyCharm not recognizing PyQT4 and PyQt4 not allowing me to 'view code'

  28. 28

    Clear PyCharm Run Window

  29. 29

    Thread not run immediately when using more than 4 BackgroundWorker

HotTag

Archive