Skip to content

Instantly share code, notes, and snippets.

@T31337
Last active March 26, 2017 05:31
Show Gist options
  • Save T31337/8ea650bce854fa4b4ba887cc04c29176 to your computer and use it in GitHub Desktop.
Save T31337/8ea650bce854fa4b4ba887cc04c29176 to your computer and use it in GitHub Desktop.
Python Qt4 Template
import sys
import PyQt4.QtGui as QtGui
class Template:
def __init__(self):
app = QtGui.QApplication(sys.argv)
self.gui()
sys.exit(app.exec_())
def doStuff(self):
msg = QtGui.QMessageBox()
msg.setText("doStuff()")
msg.setDetailedText("doStuff()\r\nMethod Was Called...")
msg.setIcon(2)
msg.exec_()
def gui(self):
win = QtGui.QDialog()
layout = QtGui.QGridLayout()
layout.setSpacing(10)
w = QtGui.QLabel("Qt4 Template")
b = QtGui.QPushButton()
b.setText("Click Me!")
b.clicked.connect(self.doStuff)
layout.addWidget(w,2,3,2,2)
layout.addWidget(b,3,3,2,2)
win.setWindowTitle("Qt4Template")
win.setLayout(layout)
win.setGeometry(100, 100, 200,100)
win.exec_()
sys.exit()
if __name__ == '__main__':
app = Template()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment