#------------------------------------------------------------------------------- # Name: ParamGuiEdit4 # Purpose: # # Author: Kelvin # # Created: 27/11/2013 # Copyright: (c) Kelvin 2013 # Licence: #------------------------------------------------------------------------------- # Basic GUI widgets are located in the QtGui module. import sys from PyQt4 import QtGui # Define a class of windows inheriting from the QtGui.QWidget class. class Window(QtGui.QWidget): # This defines how the class is initialised. # The initialising sequence takes no arguments. def __init__(self): super(Window, self).__init__() self.initUI() # This defines the initialising configurations. def initUI(self): QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 12)) self.setToolTip('This is a QWidget widget') btn = QtGui.QPushButton('Button', self) btn.setToolTip('This is a QPushButton widget') btn.resize(btn.sizeHint()) btn.move(500, 500) # This sets the position, size and title of the window, and displays it. def initialiseWindow(self): self.setGeometry(0, 0, 600, 600) self.setWindowTitle('Duchamp: Parameters') self.show() initialiseWindow(self) # This determines what happens when the window is closed. def closeEvent(self, event): reply = QtGui.QMessageBox.question(self, 'Quit Message', 'Exit Parameter Edit?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: event.accept() else: event.ignore() def main(): app = QtGui.QApplication(sys.argv) ex = Window() sys.exit(app.exec_()) if __name__ == '__main__': main()