mirror of https://gitlab.com/ita1024/waf.git
Added pyqt5 playground example
This commit is contained in:
parent
f4e1b59bbc
commit
47ac970d15
|
@ -0,0 +1,2 @@
|
|||
change me to see qrc dependencies!
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file alias="test.txt">res/test.txt</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -0,0 +1,130 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>myfirstgui</class>
|
||||
<widget class="QDialog" name="myfirstgui">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>411</width>
|
||||
<height>247</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>My First Gui!</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>210</y>
|
||||
<width>381</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="myTextInput">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>101</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>10</y>
|
||||
<width>281</width>
|
||||
<height>192</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="clearBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>180</y>
|
||||
<width>101</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="addBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>101</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>myfirstgui</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>258</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>myfirstgui</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>clearBtn</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>listWidget</receiver>
|
||||
<slot>clear()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>177</x>
|
||||
<y>253</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>177</x>
|
||||
<y>174</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -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_())
|
|
@ -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")
|
||||
|
Loading…
Reference in New Issue