[1306] | 1 | #------------------------------------------------------------------------------- |
---|
| 2 | # Name: ParamGuiEdit4 |
---|
| 3 | # Purpose: |
---|
| 4 | # |
---|
| 5 | # Author: Kelvin |
---|
| 6 | # |
---|
| 7 | # Created: 27/11/2013 |
---|
| 8 | # Copyright: (c) Kelvin 2013 |
---|
| 9 | # Licence: <your licence> |
---|
| 10 | #------------------------------------------------------------------------------- |
---|
| 11 | |
---|
| 12 | # Basic GUI widgets are located in the QtGui module. |
---|
| 13 | import sys |
---|
| 14 | from PyQt4 import QtGui |
---|
| 15 | |
---|
| 16 | # Define a class of windows inheriting from the QtGui.QWidget class. |
---|
| 17 | class Window(QtGui.QWidget): |
---|
| 18 | |
---|
| 19 | # This defines how the class is initialised. |
---|
| 20 | # The initialising sequence takes no arguments. |
---|
| 21 | def __init__(self): |
---|
| 22 | super(Window, self).__init__() |
---|
| 23 | self.initUI() |
---|
| 24 | |
---|
| 25 | # This defines the initialising configurations. |
---|
| 26 | def initUI(self): |
---|
| 27 | |
---|
| 28 | QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 12)) |
---|
| 29 | |
---|
| 30 | self.setToolTip('This is a <b>QWidget</b> widget') |
---|
| 31 | |
---|
| 32 | btn = QtGui.QPushButton('Button', self) |
---|
| 33 | btn.setToolTip('This is a <b>QPushButton</b> widget') |
---|
| 34 | btn.resize(btn.sizeHint()) |
---|
| 35 | btn.move(500, 500) |
---|
| 36 | |
---|
| 37 | # This sets the position, size and title of the window, and displays it. |
---|
| 38 | def initialiseWindow(self): |
---|
| 39 | |
---|
| 40 | self.setGeometry(0, 0, 600, 600) |
---|
| 41 | self.setWindowTitle('Duchamp: Parameters') |
---|
| 42 | self.show() |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | initialiseWindow(self) |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | # This determines what happens when the window is closed. |
---|
| 49 | def closeEvent(self, event): |
---|
| 50 | |
---|
| 51 | reply = QtGui.QMessageBox.question(self, 'Quit Message', |
---|
| 52 | 'Exit Parameter Edit?', QtGui.QMessageBox.Yes | |
---|
| 53 | QtGui.QMessageBox.No, QtGui.QMessageBox.No) |
---|
| 54 | |
---|
| 55 | if reply == QtGui.QMessageBox.Yes: |
---|
| 56 | event.accept() |
---|
| 57 | else: |
---|
| 58 | event.ignore() |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | def main(): |
---|
| 62 | |
---|
| 63 | app = QtGui.QApplication(sys.argv) |
---|
| 64 | ex = Window() |
---|
| 65 | sys.exit(app.exec_()) |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | if __name__ == '__main__': |
---|
| 69 | main() |
---|