Python Forum
QApplication: Invalid Display* argument
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QApplication: Invalid Display* argument
#1
Hi,

Following this tutorial: https://bitesofcode.blogspot.co.uk/2011/...3633820729

Once this code it run, the window opens, but there is an error message and the application can't be closed properly i.e. the only way to get out of it is to quit terminal.
The following code is exactly the only difference is the shebang, as I use python3 so use that shebang. I have been working with Qt4 now for a couple of weeks and have not come across this problem before, but I am only just now learning about making sure that only one instance of QApplication is running etc. So there must be something in the code that is causing the problem. Unfortunately I have not found any info on what a display argument is. Any help would be much appreciated.

#!/usr/bin/python3 

""" Main entry point to the nexsys application. """

# define authorship information
__authors__     = ['Eric Hulser']
__author__      = ','.join(__authors__)
__credits__     = []
__copyright__   = 'Copyright (c) 2011'
__license__     = 'GPL'

# maintanence information
__maintainer__  = 'Eric Hulser'
__email__       = '[email protected]'

from PyQt4 import QtGui

def main(argv = None):
   """
   Creates the main window for the nexsys application and begins the \
   QApplication if necessary.
   
   :param      argv | [, ..] || None
   
   :return      error code
   """
   app = None
   
   # create the application if necessary
   if ( not QtGui.QApplication.instance() ):
       app = QtGui.QApplication(argv)
       app.setStyle('plastique')
   
   # create the main window
   QtGui.QMessageBox.information(None, 'Stub', 'Create the Main Window!')
   
   # run the application if necessary
   if ( app ):
       return app.exec_()
   
   # no errors since we're not running our own event loop
   return 0

if ( __name__ == '__main__' ):
   import sys
   sys.exit(main(sys.argv))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Syntax Error: Positional argument follows keyword argument Rama02 3 4,024 Feb-09-2021, 06:10 PM
Last Post: deanhystad
  What does QApplication do? anne 4 2,883 Aug-02-2020, 08:10 PM
Last Post: deanhystad
  Display and update the label text which display the serial value jenkins43 5 8,988 Feb-04-2019, 04:36 AM
Last Post: Larz60+
  Display more than one button in GUI to display MPU6000 Sensor readings barry76 4 3,833 Jan-05-2019, 01:48 PM
Last Post: wuf

Forum Jump:

User Panel Messages

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