-
-
Save 0xnbk/e04af3913a755c5d7856 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4 import QtCore, QtGui | |
class Dialog(QtGui.QDialog): | |
def __init__(self, parent=None): | |
super(Dialog, self).__init__(parent) | |
self.resize(300,200) | |
def showEvent(self, event): | |
geom = self.frameGeometry() | |
geom.moveCenter(QtGui.QCursor.pos()) | |
self.setGeometry(geom) | |
super(Dialog, self).showEvent(event) | |
def keyPressEvent(self, event): | |
if event.key() == QtCore.Qt.Key_Escape: | |
self.hide() | |
event.accept() | |
else: | |
super(Dialog, self).keyPressEvent(event) | |
if __name__ == "__main__": | |
app = QtGui.QApplication([]) | |
d = Dialog() | |
d.show() | |
d.raise_() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment