From 6f79beb23aace35170d155517b9d901567a7f675 Mon Sep 17 00:00:00 2001 From: Kavindra Palaraja Date: Fri, 15 Nov 2019 16:18:09 +0100 Subject: docs: Simplify the Quick Start topic Change-Id: I11651033783052591f38cd8eb02ec47719c91dbf Reviewed-by: Cristian Maureira-Fredes --- .../pyside-examples/images/screenshot_hello.png | Bin 0 -> 21193 bytes sources/pyside2/doc/quickstart.rst | 42 ++++++++++----------- 2 files changed, 19 insertions(+), 23 deletions(-) create mode 100644 sources/pyside2/doc/pyside-examples/images/screenshot_hello.png diff --git a/sources/pyside2/doc/pyside-examples/images/screenshot_hello.png b/sources/pyside2/doc/pyside-examples/images/screenshot_hello.png new file mode 100644 index 000000000..41ebbf01b Binary files /dev/null and b/sources/pyside2/doc/pyside-examples/images/screenshot_hello.png differ diff --git a/sources/pyside2/doc/quickstart.rst b/sources/pyside2/doc/quickstart.rst index a9288442f..5d8ddfe2d 100644 --- a/sources/pyside2/doc/quickstart.rst +++ b/sources/pyside2/doc/quickstart.rst @@ -4,17 +4,18 @@ Requirements ------------ -Before you can install |project|, you must install the following software: +Before you can install |project|, first you must install the following software: * Python 2.7 or 3.5+, - * Recommended: a virtual environment, such as + * We recommend using a virtual environment, such as `venv `_ or `virtualenv `_ Installation ------------ -Run the following command from your command prompt to install:: +Now you are ready to install the |project| packages using ``pip``. +From the terminal, run the following command:: pip install PySide2 # For the latest version on PyPi @@ -22,8 +23,8 @@ or:: pip install --index-url=http://download.qt.io/snapshots/ci/pyside/5.14/latest pyside2 --trusted-host download.qt.io -Testing the Installation -------------------------- +Test your Installation +---------------------- Now that you have |project| installed, you can test your setup by running the following Python constructs to print version information:: @@ -46,16 +47,14 @@ constructs to print version information:: # e.g. (5, 11, 2) print(PySide2.QtCore.__version_info__) -Creating a Simple Application ------------------------------- +Create a Simple Application +--------------------------- -Your |project| setup is ready, so try exploring it further by developing a simple application +Your |project| setup is ready. You can explore it further by developing a simple application that prints "Hello World" in several languages. The following instructions will guide you through the development process: -* Create a new file named :code:`hello_world.py`, and add the following imports to it. - - :: +1. Create a new file named :code:`hello_world.py`, and add the following imports to it.:: import sys import random @@ -64,9 +63,8 @@ guide you through the development process: The |pymodname| Python module provides access to the Qt APIs as its submodule. In this case, you are importing the :code:`QtCore`, :code:`QtWidgets`, and :code:`QtGui` submodules. -* Define a class named :code:`MyWidget`, which extends QWidget and includes a QPushButton and QLabel. - - :: +2. Define a class named :code:`MyWidget`, which extends QWidget and includes a QPushButton and + QLabel.:: class MyWidget(QtWidgets.QWidget): def __init__(self): @@ -89,14 +87,10 @@ guide you through the development process: def magic(self): self.text.setText(random.choice(self.hello)) - The MyWidget class has the :code:`magic` member function that - randomly chooses an item from the list :code:`hello`. This function - is called when you click the button. + The MyWidget class has the :code:`magic` member function that randomly chooses an item from the + :code:`hello` list. When you click the button, the :code:`magic` function is called. -* Now, add a main function where you instantiate :code:`MyWidget` and - :code:`show` it. - - :: +3. Now, add a main function where you instantiate :code:`MyWidget` and :code:`show` it.:: if __name__ == "__main__": app = QtWidgets.QApplication([]) @@ -107,5 +101,7 @@ guide you through the development process: sys.exit(app.exec_()) -Your example is ready to be run. Try clicking the button at the bottom -and see which greeting you get. +Run your example. Try clicking the button at the bottom to see which greeting you get. + +.. image:: pyside-examples/images/screenshot_hello.png + :alt: Hello World application -- cgit v1.2.3