You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -193,6 +201,45 @@ Using the OS path separator (`os.pathsep`) which is `:` on Unix systems and `;`
193
201
194
202
<br>
195
203
204
+
##### QtSiteConfig.py
205
+
206
+
Add or remove members from Qt.py at run-time.
207
+
208
+
-[Examples](/examples/QtSiteConfig)
209
+
210
+
<br>
211
+
212
+
If you need to expose a module that isn't included in Qt.py by default or wish to remove something from being exposed in Qt.py you can do so by creating a `QtSiteConfig.py` module and making it available to Python.
213
+
214
+
1. Create a new file `QtSiteConfig.py`
215
+
2. Implement `update_members`
216
+
3. Expose to Python
217
+
218
+
```python
219
+
# QtSiteConfig.py
220
+
defupdate_members(members):
221
+
"""Called by Qt.py at run-time to modify the modules it makes available.
222
+
223
+
Arguments:
224
+
members (dict): The members considered by Qt.py
225
+
226
+
"""
227
+
228
+
members.pop("QtCore")
229
+
```
230
+
231
+
Finally, expose the module to Python.
232
+
233
+
```bash
234
+
$ set PYTHONPATH=/path/to
235
+
$ python -c "import Qt.QtCore"
236
+
ImportError: No module named Qt.QtCore
237
+
```
238
+
239
+
> Linux and MacOS users, replace `set` with `export`
240
+
241
+
<br>
242
+
196
243
##### Compile Qt Designer files
197
244
198
245
> WARNING - ALPHA FUNCTIONALITY<br>
@@ -406,15 +453,15 @@ if binding("PyQt4"):
406
453
Below are some of the conventions that used throughout the Qt.py module and tests.
407
454
408
455
-**Etiquette: PEP8**
409
-
- All code is written in PEP8. It is recommended you use a linter as you work, flake8 and pylinter are both good options. Anaconda if using Sublime is another good option.
456
+
- All code is written in PEP8. It is recommended you use a linter as you work, flake8 and pylinter are both good options. Anaconda if using Sublime is another good option.
410
457
-**Etiquette: Double quotes**
411
458
- " = yes, ' = no.
412
459
-**Etiquette: Napoleon docstrings**
413
-
- Any docstrings are made in Google Napoleon format. See [Napoleon](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for details.
460
+
- Any docstrings are made in Google Napoleon format. See [Napoleon](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for details.
414
461
-**Etiquette: Semantic Versioning**
415
-
- This project follows [semantic versioning](http://semver.org).
462
+
- This project follows [semantic versioning](http://semver.org).
416
463
-**Etiquette: Underscore means private**
417
-
- Anything prefixed with an underscore means that it is internal to Qt.py and not for public consumption.
464
+
- Anything prefixed with an underscore means that it is internal to Qt.py and not for public consumption.
This example illustrates how to make a QtSiteConfig module and how it affects Qt.py at run-time.
4
+
5
+
<br>
6
+
7
+
**Usage**
8
+
9
+
```bash
10
+
$ cd to/this/directory
11
+
$ python main.py
12
+
# Qt.QtCore was successfully removed by QSideConfig.py
13
+
```
14
+
15
+
Because `QtSiteConfig.py` is in the current working directory, it is available to import by Python. If running from a different directory, then you can append this directory to your `PYTHONPATH`
16
+
17
+
```bash
18
+
$ set PYTHONPATH=path/to/QtSiteConfig/
19
+
$ python main.py
20
+
# Qt.QtCore was successfully removed by QSideConfig.py
21
+
```
22
+
23
+
> Linux and MacOS users: Replace `set` with `export`
24
+
25
+
<br>
26
+
27
+
**Advanced example**
28
+
29
+
If you need to you can also add modules that are not in the standard Qt.py.
30
+
31
+
```python
32
+
defupdate_members_example(members):
33
+
"""An example of adding QJsonDocument to QtCore and the Qsci.
34
+
35
+
Remove "_example" from the function name to use this example.
36
+
37
+
Arguments:
38
+
members (dict): The default list of members in Qt.py.
39
+
Update this dict with any modifications needed.
40
+
41
+
"""
42
+
43
+
# Include QJsonDocument module
44
+
members["QtCore"].append("QJsonDocument")
45
+
46
+
# Include Qsci module for scintilla lexer support.
0 commit comments