aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/doc/gettingstarted.rst
diff options
context:
space:
mode:
authorVenugopal Shivashankar <Venugopal.Shivashankar@qt.io>2018-03-14 14:29:19 +0100
committerVenugopal Shivashankar <Venugopal.Shivashankar@qt.io>2018-04-27 12:42:47 +0000
commit76f1ae210a14d57174c429e50df519dfe6d350d0 (patch)
tree5efe6dd8d704f7582a156d029e87620f6c46cfcc /sources/pyside2/doc/gettingstarted.rst
parent4035c45e58896329e5b8b72913ff7f30d387c3dc (diff)
Doc: Add top-level index and getting started information
- Updated the copyright text in the config file - Added the copyright to the footer in the template Change-Id: Iaadc293af524abea41873d04206516caec189c53 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside2/doc/gettingstarted.rst')
-rw-r--r--sources/pyside2/doc/gettingstarted.rst86
1 files changed, 86 insertions, 0 deletions
diff --git a/sources/pyside2/doc/gettingstarted.rst b/sources/pyside2/doc/gettingstarted.rst
new file mode 100644
index 000000000..bb58c1734
--- /dev/null
+++ b/sources/pyside2/doc/gettingstarted.rst
@@ -0,0 +1,86 @@
+===============
+Getting Started
+===============
+
+To get started with |project|, install the following prerequisites:
+
+* Python v3.5 or later
+* libclang v3.9 or later
+* Optional: a virtual environment, such as `venv <https://docs.python.org/3/library/venv.html>`_ or `virtualenv <https://virtualenv.pypa.io/en/stable/installation>`_
+
+With these installed, you are ready to install the |project|
+packages using the pip wheel. Run the following command from your command
+prompt to install::
+
+ python -m pip install --index-url=http://download.qt.io/snapshots/ci/pyside/5.9/latest pyside2 --trusted-host download.qt.io
+
+Now that you have |project| installed, you can test your setup by running the following Python
+constructs to print version information:
+
+.. include:: pysideversion.rst
+ :start-line: 5
+ :end-line: 32
+
+Your |project| setup is ready, so try exploring 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.
+
+ ::
+
+ import sys
+ import random
+ from PySide2 import QtCore, QtWidgets, QtGui
+
+ These imports should provide access to the APIs specific to those Qt modules.
+
+* Define a class named :code:`MyWidget`, which extends QWidget and includes a QPushButton and QLabel.
+
+ ::
+
+ class MyWidget(QtWidgets.QWidget):
+ def __init__(self):
+ super().__init__()
+
+ self.hello = ["Hallo Welt", "你好,世界", "Hei maailma",\
+ "Hola Mundo", "Привет мир"]
+
+ self.button = QtWidgets.QPushButton("Click me!")
+ self.text = QtWidgets.QLabel("Hello World")
+ self.text.setAlignment(QtCore.Qt.AlignCenter)
+
+ self.text.setFont(QtGui.QFont("Titillium", 30))
+ self.button.setFont(QtGui.QFont("Titillium", 20))
+
+ self.layout = QtWidgets.QVBoxLayout()
+ self.layout.addWidget(self.text)
+ self.layout.addWidget(self.button)
+ self.setLayout(self.layout)
+
+ self.button.clicked.connect(self.magic)
+
+
+ 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.
+
+* Now, add a main function where you instantiate :code:`MyWidget` and
+ :code:`show` it.
+
+ ::
+
+ if __name__ == "__main__":
+ app = QtWidgets.QApplication([])
+
+ widget = MyWidget()
+ widget.resize(800, 600)
+ widget.show()
+
+ sys.exit(app.exec_())
+
+Your example is ready to be run. Try clicking the button at the bottom
+and see which greeting you get.