Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python qt raise syntax error

Tags:

python

qt

qt4

pyqt4

I have a top level widget that is producing a syntax error in python. raise() on line 15. This is using the python Qt bindings. I know that raise is a python reserved word. I am looking for how to call the Qt "raise()" function with the python bindings.

#!/usr/bin/python

# simple.py

import sys 
from PyQt4 import QtGui

app = QtGui.QApplication(sys.argv)

widget = QtGui.QWidget()
widget.resize(250, 150)
widget.setWindowTitle('simple')
widget.show()
widget.activateWindow ()
widget.raise() 

sys.exit(app.exec_())
like image 435
Philip Schlump Avatar asked Jan 02 '10 20:01

Philip Schlump


1 Answers

"raise" is a keyword (reserved word) in Python. So, you can't use it. And PyQt4 certainly doesn't use it as you think, because, well, it's a keyword, so no extension can. It's like you can't use "from" for a variable name (pet peeve: Python doesn't have variables, but I digress...)

As a hint, it's also highlighted by the syntax highlighter of SO.

Just a bit of interactive pythoneering... and it's raise_. Yep, with an underscore tacked on at the end. Pretty standard method when you have a keyword as a method/function.

like image 157
Jürgen A. Erhard Avatar answered Sep 23 '22 01:09

Jürgen A. Erhard