diff --git a/playground/pyqt5/res/test.txt b/playground/pyqt5/res/test.txt new file mode 100644 index 00000000..9b227d91 --- /dev/null +++ b/playground/pyqt5/res/test.txt @@ -0,0 +1,2 @@ +change me to see qrc dependencies! + diff --git a/playground/pyqt5/sampleRes.qrc b/playground/pyqt5/sampleRes.qrc new file mode 100644 index 00000000..687c5100 --- /dev/null +++ b/playground/pyqt5/sampleRes.qrc @@ -0,0 +1,5 @@ + + + res/test.txt + + diff --git a/playground/pyqt5/src/firstgui.ui b/playground/pyqt5/src/firstgui.ui new file mode 100644 index 00000000..cb7f9d30 --- /dev/null +++ b/playground/pyqt5/src/firstgui.ui @@ -0,0 +1,130 @@ + + + myfirstgui + + + + 0 + 0 + 411 + 247 + + + + My First Gui! + + + + + 20 + 210 + 381 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + 10 + 10 + 101 + 21 + + + + + + + 120 + 10 + 281 + 192 + + + + + + + 10 + 180 + 101 + 23 + + + + clear + + + + + + 10 + 40 + 101 + 23 + + + + add + + + + + + + buttonBox + accepted() + myfirstgui + accept() + + + 258 + 274 + + + 157 + 274 + + + + + buttonBox + rejected() + myfirstgui + reject() + + + 316 + 260 + + + 286 + 274 + + + + + clearBtn + clicked() + listWidget + clear() + + + 177 + 253 + + + 177 + 174 + + + + + diff --git a/playground/pyqt5/src/sample.py b/playground/pyqt5/src/sample.py new file mode 100644 index 00000000..80335e7c --- /dev/null +++ b/playground/pyqt5/src/sample.py @@ -0,0 +1,24 @@ +import sys +from PyQt5 import QtCore, QtGui, QtWidgets +from firstgui import Ui_myfirstgui + +class MyFirstGuiProgram(Ui_myfirstgui): + def __init__(self, dialog): + Ui_myfirstgui.__init__(self) + self.setupUi(dialog) + + # Connect "add" button with a custom function (addInputTextToListbox) + self.addBtn.clicked.connect(self.addInputTextToListbox) + + def addInputTextToListbox(self): + txt = self.myTextInput.text() + self.listWidget.addItem(txt) + +if __name__ == '__main__': + app = QtWidgets.QApplication(sys.argv) + dialog = QtWidgets.QDialog() + + prog = MyFirstGuiProgram(dialog) + + dialog.show() + sys.exit(app.exec_()) diff --git a/playground/pyqt5/wscript b/playground/pyqt5/wscript new file mode 100644 index 00000000..8a5379be --- /dev/null +++ b/playground/pyqt5/wscript @@ -0,0 +1,29 @@ +#! /usr/bin/env python +# encoding: utf-8# +# Federico Pellegrin, 2016 (fedepell) + +""" +Python QT5 helper tools example: +converts QT5 Designer tools files (UI and QRC) into python files with +the appropriate tools (pyqt5 and pyside2 searched) and manages their +python compilation and installation using standard python waf Tool + +""" +def options(opt): + # Load also python to demonstrate mixed calls + opt.load('python pyqt5') + +def configure(conf): + # Load also python to demonstrate mixed calls + conf.load('python pyqt5') + conf.check_python_version((2,7,4)) + +def build(bld): + # Demostrates mixed usage of py and pyqt5 module, and tests also install_path and install_from + # (since generated files go into build it has to be reset inside the pyqt5 tool) + bld(features="py pyqt5", source="src/sample.py src/firstgui.ui", install_path="${PREFIX}/play/", install_from="src/") + + # Simple usage on a resource file. If a file referenced inside the resource changes it will be rebuilt + # as the qrc XML is parsed and dependencies are calculated + bld(features="pyqt5", source="sampleRes.qrc") +