diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-23 16:53:13 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-24 08:44:21 +0000 |
commit | 5cec7b8926fd12daa3bdca72cd2dfaadf5eda4b1 (patch) | |
tree | 791b74d6ccf819dc2390e2ec441a32b23f75584f /sources | |
parent | 8f74adea7cffdf2e1158df15ba0105dc40b24fa3 (diff) |
Tutorials: Fix some sphinx warnings about unexpected indentation
Change-Id: I1415417ab761c57e64c0f031a9b63b5f85c9c7c7
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources')
5 files changed, 23 insertions, 2 deletions
diff --git a/sources/pyside2/doc/faq.rst b/sources/pyside2/doc/faq.rst index e09d98999..aabd017e9 100644 --- a/sources/pyside2/doc/faq.rst +++ b/sources/pyside2/doc/faq.rst @@ -29,11 +29,11 @@ Frequently Asked Questions **Does PySide2 have support for embedded Linux (Raspberry Pi, i.MX6 etc)?** Not at the moment. -**There are three wheels (pyside2, shiboken2, and shiboken2_generator) - what is the different between them?** +**There are three wheels (pyside2, shiboken2, and shiboken2_generator), what is the different between them?** Before the official release, everything was in one big wheel, but it made sense to split the projects in three different wheels: + * **pyside2**: contains all the PySide2 modules to use the Qt framework. Also depends on the shiboken2 module. * **shiboken2**: contains the shiboken2 module with helper functions for PySide2. diff --git a/sources/pyside2/doc/tutorials/basictutorial/clickablebutton.rst b/sources/pyside2/doc/tutorials/basictutorial/clickablebutton.rst index afec6d84f..accb54aea 100644 --- a/sources/pyside2/doc/tutorials/basictutorial/clickablebutton.rst +++ b/sources/pyside2/doc/tutorials/basictutorial/clickablebutton.rst @@ -11,6 +11,7 @@ click it. Let's start by importing the necessary PySide2 classes and python `sys` module: :: + import sys from PySide2.QtWidgets import QApplication, QPushButton from PySide2.QtCore import Slot @@ -31,12 +32,14 @@ console: Now, as mentioned in previous examples you must create the `QApplication` to run your PySide2 code: :: + # Create the Qt Application app = QApplication(sys.argv) Let's create the clickable button, which is a `QPushButton` instance. To label the button, we pass a python string to the constructor: :: + # Create a button button = QPushButton("Click me") @@ -52,11 +55,13 @@ The `QPushButton` has a predefined signal called **clicked**, which is triggered every time the button is clicked. We'll connect this signal to the `say_hello()` function: :: + # Connect the button to the function button.clicked.connect(say_hello) Finally, we show the button and start the Qt main loop: :: + # Show the button button.show() # Run the main Qt loop @@ -64,6 +69,7 @@ Finally, we show the button and start the Qt main loop: Here is the complete code for this example: :: + #!/usr/bin/python import sys diff --git a/sources/pyside2/doc/tutorials/basictutorial/dialog.rst b/sources/pyside2/doc/tutorials/basictutorial/dialog.rst index 1daa6b89d..cdb356b91 100644 --- a/sources/pyside2/doc/tutorials/basictutorial/dialog.rst +++ b/sources/pyside2/doc/tutorials/basictutorial/dialog.rst @@ -10,6 +10,7 @@ Let us just start with a simple stub that creates and shows a dialog. This stub is updated during the course of this tutorial, but you can use this stub as is if you need to: :: + import sys from PySide2.QtWidgets import QApplication, QDialog, QLineEdit, QPushButton @@ -49,6 +50,7 @@ enter their name, and a `QPushButton` that prints the contents of the `QLineEdit`. So, let's add the following code to the `init()` method of our Form: :: + # Create widgets self.edit = QLineEdit("Write my name here..") self.button = QPushButton("Show Greetings") @@ -64,6 +66,7 @@ in your application. In this case, let's use `QVBoxLayout` to lay out the widgets vertically. Add the following code to the `init()` method, after creating the widgets: :: + # Create layout and add widgets layout = QVBoxLayout() layout.addWidget(self.edit) @@ -82,6 +85,7 @@ Finally, we just have to add a function to our custom **Form** and *connect* our button to it. Our function will be a part of the Form, so you have to add it after the `init()` function: :: + # Greets the user def greetings(self): print ("Hello {}".format(self.edit.text())) @@ -94,6 +98,7 @@ Now that we have everything, we just need to *connect* the `QPushButton` to the `Form.greetings()` method. To do so, add the following line to the `init()` method: :: + # Add button signal to greetings slot self.button.clicked.connect(self.greetings) @@ -105,6 +110,7 @@ Complete code Here is the complete code for this tutorial: :: + import sys from PySide2.QtWidgets import (QLineEdit, QPushButton, QApplication, QVBoxLayout, QDialog) diff --git a/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst b/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst index 00731abc3..b00437bcb 100644 --- a/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst +++ b/sources/pyside2/doc/tutorials/basictutorial/uifiles.rst @@ -15,6 +15,7 @@ Add a `QPushButton` to the center of the centralwidget. Your file (mainwindow.ui) should look something like this: :: + <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> @@ -79,11 +80,13 @@ 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: :: + 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: :: + from ui_mainwindow import Ui_MainWindow Now to use it, we should create a personalized class for our widget @@ -91,6 +94,7 @@ to **setup** this generated design. To understand the idea, let's take a look at the whole code: :: + import sys from PySide2.QtWidgets import QApplication, QMainWindow from PySide2.QtCore import QFile @@ -115,6 +119,7 @@ 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: :: + self.ui = Ui_MainWindow() self.ui.setupUi(self) @@ -127,6 +132,7 @@ Loading it directly To load the UI file directly, we will need a class from the **QtUiTools** module: :: + from PySide2.QtUiTools import QUiLoader The `QUiLoader` lets us load the **ui file** dynamically @@ -141,6 +147,7 @@ and use it right away: The complete code of this example looks like this: :: + # File: main.py import sys from PySide2.QtUiTools import QUiLoader @@ -163,4 +170,5 @@ The complete code of this example looks like this: Then to execute it we just need to run the following on a command prompt: :: + python main.py diff --git a/sources/pyside2/doc/tutorials/examples/tabbedbrowser.rst b/sources/pyside2/doc/tutorials/examples/tabbedbrowser.rst index d291e8399..c34c50647 100644 --- a/sources/pyside2/doc/tutorials/examples/tabbedbrowser.rst +++ b/sources/pyside2/doc/tutorials/examples/tabbedbrowser.rst @@ -5,6 +5,7 @@ Web Browser Example The example demonstrates the power and simplicity offered by |project| to developers. It uses several |pymodname| submodules to offer a fluid and modern-looking UI that is apt for a web browser. The application offers the following features: + * Tab-based browsing experience using QTabWidget. * Download manager using a QProgressBar and QWebEngineDownloadItem. * Bookmark manager using QTreeView. |