KonTrax
8/19/2013 - 2:24 PM

Python QT Boilerplates

Python QT Boilerplates

#!/usr/bin/python3
#Initialize PyQT
from PyQt4.QtCore import *
from PyQt4.QtGui import *
#The fondamental for working with python
import os,sys,signal

from ui_mainWindow import Ui_MainWindow

class MainWindow ( QMainWindow , Ui_MainWindow):

    #Create settings for the software
    settings = QSettings('Your Name','Name of the software')
    settings.setFallbacksEnabled(False)
    version = 'Your version'

    def __init__ ( self, parent = None ):
        QMainWindow.__init__( self, parent )
        #Load the ui
        self.ui = Ui_MainWindow()
        self.ui.setupUi( self )
        #Set the MainWindow Title
        self.setWindowTitle('name of the software - ' + self.version)
        #When the software are closed on console the software are closed
        signal.signal(signal.SIGINT, signal.SIG_DFL)
        #Show the form
        self.show()


def main():
  #Start the software
    app = QApplication(sys.argv)
    MainWindow_ = QMainWindow()
    ui = MainWindow()
    ui.setupUi(MainWindow_)
    #Add the close feature at the program with the X
    sys.exit(app.exec_())
    
#Execute the software
main()
#!/usr/bin/env python
 
#import third-party libraries
from PySide import QtCore, QtGui
 
APP_TITLE = 'PySideAppBoilerplate' # replace string with the title of your application
APP_X = 100
APP_Y = 100
APP_W = 1280
APP_H = 720
 
class MainWindow(QtGui.QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        
        self.setGeometry(APP_X, APP_Y, APP_W, APP_H)
        self.setWindowTitle(APP_TITLE)
 
 
if __name__ == '__main__':
 
    import sys
 
    app = QtGui.QApplication(sys.argv)
    mainWin = MainWindow()
    mainWin.show()
    sys.exit(app.exec_())