Sandbox:Piffpoof2a

Entry Level PySide Examples 3 types of windows

what is a widget

list some sites to read up on

PySide is not loaded with Python by default, it must be requested prior to using it. The following command:

causes the 2 parts of PySide to be loaded - QtGui holds classes for managing the Graphic User Interface while QtCore contains classes that do not directly relate to management of the GUI (e.g. timers and geometry). Although it is possible to only import the one that is needed, generally they are both needed and both imported.

Note : the 'import' statement is not repeated in each code snippet below, it is assumed that it is already in the Python file.

The simplest interaction with PySide is to present a message to the user which they can only accept:

The next most simple interaction is to ask for a yes/no answer:

QtGui.QMessageBox.No, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes:       # this is where the code relevant to a 'Yes' answer goes         pass if reply == QtGui.QMessageBox.No:         # this is where the code relevant to a 'No' answer goes         pass

The next code snippet asks the user for a piece of text - note this can be any key on the keyboard really:

Remember that even if the user enters only digits, "1234" for example, they are strings and must be converted to number representation with either of the following:

ask for text input QLineEdit

ask for numeric input QlineEdit with mask

}}