Skip to content

Instantly share code, notes, and snippets.

@arkenidar
Created April 12, 2016 16:55
Show Gist options
  • Save arkenidar/0c54ce0ee84736a4bad62cb516504344 to your computer and use it in GitHub Desktop.
Save arkenidar/0c54ce0ee84736a4bad62cb516504344 to your computer and use it in GitHub Desktop.
simple pyside test app
#!/usr/bin/env python
'''
required:
sudo apt-get install python python-pyside pyside-tools
'''
import sys
from PySide.QtGui import *
app = QApplication(sys.argv)
win = QWidget()
win.resize(320, 240)
win.setWindowTitle("window title")
# Create a Label and show it
label = QLabel("label", win)
label.show()
n = 0
def sayHello():
global n
n += 1
text = "Hello"+'!'*n
label.setText(text)
# Create a button
button = QPushButton("Click me", win)
# Connect the button to the function
button.clicked.connect(sayHello)
# Show the button
button.show()
okButton = QPushButton("OK")
cancelButton = QPushButton("Cancel")
hbox = QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(okButton)
hbox.addWidget(cancelButton)
vbox = QVBoxLayout()
vbox.addWidget(label)
vbox.addWidget(button)
vbox.addStretch(1)
vbox.addLayout(hbox)
win.setLayout(vbox)
win.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment