Skip to content

Commit d40d0e2

Browse files
committed
Firs dev version.
1 parent 21492ff commit d40d0e2

27 files changed

Lines changed: 456 additions & 1 deletion

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

README.md

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,96 @@
1-
# PysideSetupMacro
1+
![PySide Setup Macro](logo.png)
2+
3+
## Introduction
24
Build tools to compile and generate QT qresource files and .ui files at build time (Pyside).
5+
6+
Are you tired of maintaining a qresource files and converting .ui? Then your at the right place.
7+
PysideSetupMacro converts all qresource files and .ui files for you at build time.
8+
All you have to do is to import the module in your `setup.py` and use it.
9+
10+
**example**
11+
```python
12+
13+
from setuptools import find_packages, setup
14+
15+
from pyside_setup_macro import QtBuildPackage
16+
17+
setup(
18+
...,
19+
packages=find_packages(exclude=("test*", "tests*")),
20+
...,
21+
cmdclass={
22+
"build_py": QtBuildPackage, # This is all you need to add.
23+
},
24+
)
25+
```
26+
27+
28+
If your lazy like me and don't want to maintain a qresource file then I have introduced qmacro.
29+
30+
The qmacro has 2 parts.
31+
A mandatory name of the qresource file to ge created.
32+
```python
33+
name="resource" # Name of resource file to be created.
34+
```
35+
36+
A built-in function call for creating the resources.
37+
```python
38+
add_files("*.png", prefix="/images") # Individually specify the prefixes.
39+
```
40+
41+
42+
With the following dir structure you can create the resource file in 2 ways.
43+
```
44+
├── __init__.py
45+
├── flags
46+
│ ├── denmark.png
47+
│ ├── norway.png
48+
│ └── sweden.png
49+
├── pen.png
50+
└── qmacro
51+
```
52+
### Option 1
53+
`qmacro`
54+
```python
55+
name = "qresource"
56+
add_files("flags/*.png", prefix="flags")
57+
add_files("*.png")
58+
```
59+
60+
**Resulting qresource file**
61+
```xml
62+
<?xml version="1.0" ?>
63+
<RCC>
64+
<qresource prefix="">
65+
<file alias="pen.png">pen.png</file>
66+
</qresource>
67+
<qresource prefix="flags">
68+
<file alias="denmark.png">flags/denmark.png</file>
69+
<file alias="norway.png">flags/norway.png</file>
70+
<file alias="sweden.png">flags/sweden.png</file>
71+
</qresource>
72+
</RCC>
73+
```
74+
75+
### Option 2
76+
77+
`qmacro`
78+
```python
79+
name = "qresource"
80+
walk()
81+
```
82+
83+
**Resulting qresource file**
84+
```xml
85+
<?xml version="1.0" ?>
86+
<RCC>
87+
<qresource prefix="">
88+
<file alias="pen.png">pen.png</file>
89+
</qresource>
90+
<qresource prefix="flags">
91+
<file alias="denmark.png">flags/denmark.png</file>
92+
<file alias="norway.png">flags/norway.png</file>
93+
<file alias="sweden.png">flags/sweden.png</file>
94+
</qresource>
95+
</RCC>
96+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "1.0.0"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
from PySide6 import QtGui, QtWidgets
3+
4+
import email_app.icons.qresource
5+
6+
7+
class SendMailWidget(QtWidgets.QWidget):
8+
def __init__(self, parent: QtWidgets.QWidget = None):
9+
super().__init__(parent=parent)
10+
self.create_email_button = QtWidgets.QPushButton()
11+
self.send_email_button = QtWidgets.QPushButton()
12+
13+
self.create_email_button.setIcon(QtGui.QIcon(":/icons/mail.png"))
14+
self.send_email_button.setIcon(QtGui.QIcon(":/icons/send.png"))
15+
16+
layout = QtWidgets.QHBoxLayout()
17+
layout.addWidget(self.create_email_button)
18+
layout.addWidget(self.send_email_button)
19+
self.setLayout(layout)
20+
21+
22+
if __name__ == "__main__":
23+
app = QtWidgets.QApplication(sys.argv)
24+
win = SendMailWidget()
25+
win.show()
26+
sys.exit(app.exec())

examples/email_app/email_app/icons/__init__.py

Whitespace-only changes.
2.85 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE RCC>
2+
<RCC version="1.0">
3+
<qresource prefix="/icons">
4+
<file>mail.png</file>
5+
<file>send.png</file>
6+
</qresource>
7+
</RCC>
2.83 KB
Loading

examples/email_app/setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from setuptools import find_packages, setup
2+
3+
from pyside_setup_macro import QtBuildPackage
4+
import email_app
5+
6+
7+
setup(
8+
name="email_app",
9+
version=email_app.__version__,
10+
packages=find_packages(exclude=("test*", "tests*")),
11+
url="",
12+
license="Apache License, Version 2.0",
13+
author="Max Wiklund",
14+
author_email="",
15+
description="Demo project",
16+
cmdclass={
17+
"build_py": QtBuildPackage,
18+
},
19+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from setuptools import find_packages, setup
2+
3+
from pyside_setup_macro import QtBuildPackage
4+
import skandinavia_flag_picker
5+
6+
7+
setup(
8+
name="skandinavia_flag_picker",
9+
version=skandinavia_flag_picker.__version__,
10+
packages=find_packages(exclude=("test*", "tests*")),
11+
url="",
12+
license="Apache License, Version 2.0",
13+
author="Max Wiklund",
14+
author_email="",
15+
description="Demo project",
16+
cmdclass={
17+
"build_py": QtBuildPackage,
18+
},
19+
)

0 commit comments

Comments
 (0)