aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/doc/tutorials/basictutorial
diff options
context:
space:
mode:
authorVenugopal Shivashankar <Venugopal.Shivashankar@qt.io>2019-10-30 15:26:17 +0100
committerVenugopal Shivashankar <Venugopal.Shivashankar@qt.io>2019-11-01 13:19:04 +0100
commit4af52ffcfd89a636eff09a500836e14a7ad4d877 (patch)
tree4f88955a63aca65857ffcee791d6f5c309da3733 /sources/pyside2/doc/tutorials/basictutorial
parent25b06b8df797b3edb88f9d6054f8a7e9e77a280d (diff)
Doc: Fix sphinx warnings about indentation and linking
Change-Id: I22fc8b60d9c9209224eddbd8255f8e2b834da0ae Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside2/doc/tutorials/basictutorial')
-rw-r--r--sources/pyside2/doc/tutorials/basictutorial/qml.rst8
-rw-r--r--sources/pyside2/doc/tutorials/basictutorial/uifiles.rst31
-rw-r--r--sources/pyside2/doc/tutorials/basictutorial/widgets.rst12
3 files changed, 34 insertions, 17 deletions
diff --git a/sources/pyside2/doc/tutorials/basictutorial/qml.rst b/sources/pyside2/doc/tutorials/basictutorial/qml.rst
index 81583096b..fb168410a 100644
--- a/sources/pyside2/doc/tutorials/basictutorial/qml.rst
+++ b/sources/pyside2/doc/tutorials/basictutorial/qml.rst
@@ -14,7 +14,9 @@ that loads the QML file. To make things easier, let's save both files in
the same directory.
Here is a simple QML file called `view.qml`:
-::
+
+.. code-block:: javascript
+
import QtQuick 2.0
Rectangle {
@@ -39,7 +41,9 @@ is the Rectangle in this case.
Now, let's see how the code looks on the PySide2.
Let's call it `main.py`:
-::
+
+.. code-block:: python
+
from PySide2.QtWidgets import QApplication
from PySide2.QtQuick import QQuickView
from PySide2.QtCore import QUrl
diff --git a/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst b/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst
index b00437bcb..a45bfc18c 100644
--- a/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst
+++ b/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst
@@ -78,14 +78,12 @@ Generating a Python class
Another option to interact with a **UI file** is to generate a Python
class from it. This is possible thanks to the `pyside2-uic` tool.
-To use this tool, you need to run the following command on a console:
-::
+To use this tool, you need to run the following command on a console::
pyside2-uic mainwindow.ui > ui_mainwindow.py
We redirect all the output of the command to a file called `ui_mainwindow.py`,
-which will be imported directly:
-::
+which will be imported directly::
from ui_mainwindow import Ui_MainWindow
@@ -93,7 +91,8 @@ Now to use it, we should create a personalized class for our widget
to **setup** this generated design.
To understand the idea, let's take a look at the whole code:
-::
+
+.. code-block:: python
import sys
from PySide2.QtWidgets import QApplication, QMainWindow
@@ -118,26 +117,32 @@ What is inside the *if* statement is already known from the previous
examples, and our new basic class contains only two new lines
that are in charge of loading the generated python class from the UI
file:
-::
+
+.. code-block:: python
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
-.. note:: You must run `pyside2-uic` again every time you make changes
-to the **UI file**.
+.. note::
+
+ You must run `pyside2-uic` again every time you make changes
+ to the **UI file**.
Loading it directly
====================
To load the UI file directly, we will need a class from the **QtUiTools**
module:
-::
+
+.. code-block:: python
from PySide2.QtUiTools import QUiLoader
The `QUiLoader` lets us load the **ui file** dynamically
and use it right away:
-::
+
+.. code-block:: python
+
ui_file = QFile("mainwindow.ui")
ui_file.open(QFile.ReadOnly)
@@ -146,7 +151,8 @@ and use it right away:
window.show()
The complete code of this example looks like this:
-::
+
+.. code-block:: python
# File: main.py
import sys
@@ -169,6 +175,7 @@ The complete code of this example looks like this:
Then to execute it we just need to run the following on a
command prompt:
-::
+
+.. code-block:: python
python main.py
diff --git a/sources/pyside2/doc/tutorials/basictutorial/widgets.rst b/sources/pyside2/doc/tutorials/basictutorial/widgets.rst
index c864e3d47..41e474227 100644
--- a/sources/pyside2/doc/tutorials/basictutorial/widgets.rst
+++ b/sources/pyside2/doc/tutorials/basictutorial/widgets.rst
@@ -5,7 +5,9 @@ As with any other programming framework,
you start with the traditional "Hello World" program.
Here is a simple example of a Hello World application in PySide2:
-::
+
+.. code-block:: python
+
import sys
from PySide2.QtWidgets import QApplication, QLabel
@@ -22,13 +24,17 @@ After the imports, you create a `QApplication` instance. As Qt can
receive arguments from command line, you may pass any argument to
the QApplication object. Usually, you don't need to pass any
arguments so you can leave it as is, or use the following approach:
-::
+
+.. code-block:: python
+
app = QApplication([])
After the creation of the application object, we have created a
`QLabel` object. A `QLabel` is a widget that can present text
(simple or rich, like html), and images:
-::
+
+.. code-block:: python
+
# This HTML approach will be valid too!
label = QLabel("<font color=red size=40>Hello World!</font>")