Created
April 12, 2016 16:55
-
-
Save arkenidar/0c54ce0ee84736a4bad62cb516504344 to your computer and use it in GitHub Desktop.
simple pyside test app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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