I am writing a program which checks if user is root. If not an input dialog shows up for password. I have done this earlier too (inside some class) but lost the file somewhere.
if os.name == 'posix':
if not os.getuid() == 0:
input, ok = QtGui.QInputDialog.getText(None, 'Password',
'Enter password:', QtGui.QLineEdit.Password)
if ok:
#remaining code
The issue here is that this produces an error QWidget: Must construct a QApplication before a QPaintDevice
Is it only possible to bring up input dialog using UI class? or Is there any other solution to this?