Skip to content

EricThomson/PySideSummer

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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).

  1. 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)

  1. Replace obsolete Qt.TextColorRole with Qt.ForegroundRole.

  2. Replace .toPyDateTime() with .toPython()

  3. 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.

  1. 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.

  1. 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)

About

PySide port of Summerfield's book 'Rapid GUI Programming with Python and Qt.'

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages