Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/EricThomson/PySideSummer
PySide port of Summerfield's book 'Rapid GUI Programming with Python and Qt.'
https://github.com/EricThomson/PySideSummer
Last synced: 2 days ago
JSON representation
PySide port of Summerfield's book 'Rapid GUI Programming with Python and Qt.'
- Host: GitHub
- URL: https://github.com/EricThomson/PySideSummer
- Owner: EricThomson
- Created: 2014-07-31T03:24:54.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-03-17T14:27:42.000Z (over 4 years ago)
- Last Synced: 2024-08-01T16:43:05.981Z (3 months ago)
- Language: Python
- Homepage:
- Size: 998 KB
- Stars: 48
- Watchers: 8
- Forks: 25
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- my-awesome-github-stars - EricThomson/PySideSummer - PySide port of Summerfield's book 'Rapid GUI Programming with Python and Qt.' (Python)
README
# PySideSummer
Annotated PySide port of code from Mark Summerfield's 'Rapid GUI Programming with Python and Qt' (2008). The book's web site is at:
http://www.qtrac.eu/pyqtbook.html.The programs should run without mishap in your favorite Python environment, as long as you have PySide installed. It has thus far been tested on Python 2.7 in Windows 7. Unless otherwise noted, if the original name of Summerfield's script was _name.pyw_, the name of the adapted PySide script is _namePyside.py_.
Annotations include comments in code, but each chapter also contains _README.md_ and _usefulStuff.md_ files (the latter contains curated excerpts from PySide documentation and links from other relevant resources). When possible, we link to PySide documentation, but sometimes we have to go with Qt or PyQt when it is better.
Thanks to Mark Summerfield for encouragement, suggestions for improvement in innumerable places.
## Table of contents
**Chapter 4**: Introduction to GUI Programming**Chapter 5**: Dialogs
**Chapter 6**: Main Windows
**Chapter 7**: Using Qt Designer
**Chapter 8**: Data Handling and Custom File Formats
**Chapter 9**: Layouts and Multiple Documents
**Chapter 10**: Events, the Clipboard, and Drag and Drop
**Chapter 11**: Custom Widgets
**Chapter 12**: Item-Based Graphics
**Chapter 13**: Rich Text and Printing
**Chapter 14**: Model/View Programming
**Chapter 15**: Databases
**Chapter 16**: Advanced Model/View Programming
**Chapter 17**: Online Help and Internationalization
**Chapter 18**: Networking
**Chapter 19**: Multithreading
### Some of the guidelines followed
1. Follow Summerfield's recommendations for converting to Pyside, unless that would conflict with the remaining guidelines.2. Change old-style to new-style signals and slots.
3. Replace `from PyQt4.QtCore import *`-type imports with `from PySide import QtGui`-type imports.
4. Replace `Qt.escape()`, which is not used in PySide, with `xml.sax.saxutils.escape()` (see http://srinikom.github.io/pyside-bz-archive/229.html ).
5. When opening files with `codecs` module, change the mode from "wt" to "w".
6. Replace `QtGui.QWorkspace` (deprecated) with `QtGui.QMdiArea.` This entails a great deal of other relatively minor changes (see Chapter 9 texteditor code).
7. For drawpolygon to work (Chapter 11) change list of numbers to list of QPoints.
For instance, change:
drawPolygon(QtGui.QPolygon([x1, y1, x2, y2]))
to:
drawPolygon(QtGui.QPolygon([QtCore.QPoint(x1, y1), QtCore.QPoint(x2,y2)]))
8. Replace deprecated `QMatrix` and `.matrix()` with 'QTransform' and '.transform()` (Chapter 12).9. Replace the single line:
self.assetView.selectionModel().currentRowChanged.connect(self.assetChanged)
With the two lines:selectionModel = self.assetView.selectionModel()
selectionModel.currentRowChanged.connect(self.assetChanged)
This seems to be due to a bug in PySide (Chapter 15).10. Get sqlite to work by adding:
site_pack_path = site.getsitepackages()[1]
QtGui.QApplication.addLibraryPath('{0}\\PySide\\plugins'.format(site_pack_path))Before `QtSql.QSqlDatabase.adDatabase("QSQLITE")`. Be sure to `import site`. Not sure how platform-dependent this problem is. (Chapter 15)
11. Replace obsolete `Qt.TextColorRole` with `Qt.ForegroundRole`.
12. Replace `.toPyDateTime()` with `.toPython()`
13. For Chapter 17, to get the *_fr.html pages to show up in the help pages, add:
QtCore.QLocale.setDefault(QtCore.QLocale(locale))
Where 'locale' is the value entered by the user at the command line. Note this may not be required on all systems. I needed it in Python 2.7.6, Qt 4.8.4, PySide 1.2.1 on Windows 7.
14. Replace `isAlive(qObj)` function, which uses sip, with:
from Shiboken import shiboken
def isAlive(qObj):
return shiboken.isValid(qObj)If you get the error that shiboken is not installed, in Windows command line:
pip install --use-wheel -U shiboken
Not sure what to do in Linux/Mac.
15. At least in the first few chapters, we replace 'super' with explicit base class initialization, just to try it both ways (see http://stackoverflow.com/questions/23981625/why-is-super-used-so-much-in-pyside-pyqt).
### LICENSE
PySideSummer is under the GPL license (http://www.gnu.org/copyleft/gpl.html)