Rapid GUI Programming with Python and Qt (Prentice Hall Open Source Software Development)

Category: Programming
Author: Mark Summerfield
4.0
This Year Stack Overflow 2
This Month Stack Overflow 4

Comments

by anonymous   2019-07-21

Rapid GUI Programming with Python and QT by Mark Summerfield is a good book about PyQt4.

AFAIK it uses python 2.x, but I think that's less important. Many people are still using python 2.x, there are lots of libraries that are not ported to python 3.x yet and when python 3.x finally gains traction, there are good chances that this book will be revised to remain actual.

by anonymous   2019-07-21

I strongly recommend the Rapid GUI Programming python development book. Author's Page.

I recall that Elsevier has released a Python-GUI book book but the link and the name escape me now.

by anonymous   2019-07-21

In terms of GUI design, I depend heavily on QT right now (py and c++ QT). I recommend an excellent book: Rapid GUI Design with QT

by anonymous   2017-08-20

Linux is the most accessible and has the most mature desktop functionality. BSD (in its various flavours) has less userspace baggage and would be easier to understand at a fundamental level. In this regard it is more like a traditional Unix than a modern Linux distribution. Some might view this as a good thing (and from certain perspectives it is) but will be more alien to someone familiar with Windows.

The main desktop distributions are Ubuntu and Fedora. These are both capable systems but differ somewhat in their userspace architecture The tooling for the desktop environment and default configuration for system security works a bit differently on Ubuntu than it does on most other Linux or Unix flavours but this is of little relevance to development. From a user perspective either of these would be a good start.

From a the perspective of a developer, all modern flavours of Unix and Linux are very similar and share essentially the same developer tool chain. If you want to learn about the system from a programmer's perspective there is relatively little to choose.

Most unix programming can be accomplished quite effectively with a programmer's editor such as vim or emacs, both of which come in text mode and windowing flavours. These editors are very powerful and have rather quirky user interfaces - the user interfaces are ususual but contribute significantly to the power of the tools. If you are not comfortable with these tools, this posting discusses several other editors that offer a user experience closer to common Windows tooling.

There are several IDEs such as Eclipse that might be of more interest to someone coming off Windows/Visual Studio.

Some postings on Stackoverflow that discuss linux/unix resources are:

  • What are good linux-unix books for an advancing user

  • What are some good resources for learning C beyond K&R

  • Resources for learning C program design

If you have the time and want to do a real tour of the nuts and bolts Linux From Scratch is a tutorial that goes through building a linux installation by hand. This is quite a good way to learn in depth.

For programming, get a feel for C/unix from K&R and some of the resources mentioned in the questions linked above. The equivalent of Petzold, Prosise and Richter in the Unix world are W Richard Stevens' Advanced Programming in the Unix Environment and Unix Network Programming vol. 1 and 2.

Learning one of the dynamic languages such as Perl or Python if you are not already familiar with these is also a useful thing to do. As a bonus you can get good Windows ports of both the above from Activestate which means that these skills are useful on both platforms.

If you're into C++ take a look at QT. This is arguably the best cross-platform GUI toolkit on the market and (again) has the benefit of a skill set and tool chain that is transferrable back into Windows. There are also several good books on the subject and (as a bonus) it also works well with Python.

Finally, Cygwin is a unix emulation layer that runs on Windows and gives substantially unix-like environment. Architecturally, Cygwin is a port of glibc and the crt (the GNU tool chain's base libraries) as an adaptor on top of Win32. This emulation layer makes it easy to port unix/linux apps onto Cygwin. The platform comes with a pretty complete set of software - essentially a full linux distribution hosted on a Windows kernel. It allows you to work in a unix-like way on Windows without having to maintain a separate operating system installations. If you don't want to run VMs, multiple boots or multiple PCs it may be a way of easing into unix.

by anonymous   2017-08-20

My Python and PyQt is rusty, but here's a translation with possible small errors in syntax:

def SetTextInteraction(self, on, selectAll):
    if on and self.textInteractionFlags() == Qt.NoTextInteraction:
        self.setTextInteractionFlags(Qt.TextEditorInteraction)
        self.setFocus(Qt.MouseFocusReason)
        self.setSelected(True) 
        if selectAll:
            c = self.textCursor()
            c.select(QTextCursor.Document)
            self.setTextCursor(c)
    elif not on and self.textInteractionFlags() == Qt.TextEditorInteraction:
        self.setTextInteractionFlags(Qt.NoTextInteraction)
        c = self.textCursor()
        c.clearSelection()
        self.setTextCursor(c)
        self.clearFocus()

There are two reasons you're confused about what's happening in the code you linked to:

  1. C++ handles implicit scope resolution at compile time; Python requires explicit declarations. Local scope (the member function) is checked first, then the surrounding class, then (I believe) the local translation unit/local non-member functions, and finally up the namespace/scope heirarchy until it finds the function or variable being referenced.

    textCursor is a member function of the parent class for TextItem. Calling textCursor() is the same as calling this->textCursor(), which in Python would be self.textCursor().

  2. The code provided intermingles explicit usage of this with implicit calls. Using this where not necessary is considered bad form in C++ and made it appear as if textCursor() is not the same as this->textCursor(). Hopefully in reading through the Python version I provided, you'll see there is no difference.

Resources for the future
The C++ tag has great links to FAQs on C++. I recommend a stroll through the C++ Super-FAQ. You'll learn things you didn't expect you needed to know and things you didn't know were not clear will be clarified. There is also The Definitive C++ Book Guide and List here on SO.

For PyQt development, Mark Summerfield's Rapid GUI Programming with Python and Qt is a great reference with working code.